diff --git a/NEWS.md b/NEWS.md index dab53560..553b7f7c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -3,6 +3,11 @@ ## New features - `oddsratio_to_d()` and related functions gain a `p0` argument for exact conversion between odds ratios and Cohen's _d_ (thanks @KohlRaphael for the suggestion). +- `interpret*()` now accept (and return) matrices and arrays. + +## Breaking Changes + +- `interpret_oddsratio()` drops the default `"chen2010"` as it was used incorrectly (thanks to @KohlRaphael). # effectsize 0.8.9 diff --git a/R/interpret_bf.R b/R/interpret_bf.R index f420dd51..95cfc586 100644 --- a/R/interpret_bf.R +++ b/R/interpret_bf.R @@ -69,7 +69,7 @@ interpret_bf <- function(bf, ) ) - interpretation <- interpret(bf, rules, transform = function(.x) exp(abs(.x))) + interpretation <- interpret(bf, rules, transform = function(.x) exp(ifelse(.x < 0, -.x, .x))) interpretation[bf == 0] <- "no" # interpret direction diff --git a/R/interpret_oddsratio.R b/R/interpret_oddsratio.R index 0d4851c4..fd878622 100644 --- a/R/interpret_oddsratio.R +++ b/R/interpret_oddsratio.R @@ -1,26 +1,23 @@ #' Interpret Odds Ratio #' #' @param OR Value or vector of (log) odds ratio values. -#' @param rules Can be "`chen2010"` (default), `"cohen1988"` (through -#' transformation to standardized difference, see [oddsratio_to_d()]) or custom set -#' of [rules()]. +#' @param rules If `"cohen1988"` (default), `OR` is transformed to a +#' standardized difference (via [oddsratio_to_d()]) and interpreted according +#' to Cohen's rules (see [interpret_cohens_d()]; see Chen et al., 2010). If a +#' custom set of [rules()] is used, OR is interperted as is. #' @param log Are the provided values log odds ratio. #' @inheritParams interpret +#' @inheritParams oddsratio_to_d #' #' @section Rules: #' #' Rules apply to OR as ratios, so OR of 10 is as extreme as a OR of 0.1 (1/10). #' -#' - Chen et al. (2010) (`"chen2010"`; default) -#' - **OR < 1.68** - Very small -#' - **1.68 <= OR < 3.47** - Small -#' - **3.47 <= OR < 6.71** - Medium -#' - **OR >= 6.71 ** - Large #' - Cohen (1988) (`"cohen1988"`, based on the [oddsratio_to_d()] conversion, see [interpret_cohens_d()]) #' - **OR < 1.44** - Very small #' - **1.44 <= OR < 2.48** - Small #' - **2.48 <= OR < 4.27** - Medium -#' - **OR >= 4.27 ** - Large +#' - **OR >= 4.27** - Large #' #' @examples #' interpret_oddsratio(1) @@ -40,28 +37,15 @@ #' #' @keywords interpreters #' @export -interpret_oddsratio <- function(OR, rules = "chen2010", log = FALSE, ...) { - if (log) { - f_transform <- function(.x) exp(abs(.x)) - } else { - f_transform <- function(.x) exp(abs(log(.x))) - } - - +interpret_oddsratio <- function(OR, rules = "cohen1988", p0, log = FALSE, ...) { if (is.character(rules) && rules == "cohen1988") { - d <- oddsratio_to_d(OR, log = log) + d <- oddsratio_to_d(OR, p0, log = log) return(interpret_cohens_d(d, rules = rules)) } - rules <- .match.rules( - rules, - list( - chen2010 = rules(c(1.68, 3.47, 6.71), c("very small", "small", "medium", "large"), - name = "chen2010", right = FALSE - ), - cohen1988 = NA # for correct error msg - ) - ) + if (log) { + OR <- exp(OR) + } - interpret(OR, rules, transform = f_transform) + interpret(OR, rules, transform = function(.x) ifelse(.x < 1, 1/.x, .x)) } diff --git a/man/interpret_oddsratio.Rd b/man/interpret_oddsratio.Rd index 39da032e..68c99801 100644 --- a/man/interpret_oddsratio.Rd +++ b/man/interpret_oddsratio.Rd @@ -4,14 +4,17 @@ \alias{interpret_oddsratio} \title{Interpret Odds Ratio} \usage{ -interpret_oddsratio(OR, rules = "chen2010", log = FALSE, ...) +interpret_oddsratio(OR, rules = "cohen1988", p0, log = FALSE, ...) } \arguments{ \item{OR}{Value or vector of (log) odds ratio values.} -\item{rules}{Can be "\verb{chen2010"} (default), \code{"cohen1988"} (through -transformation to standardized difference, see \code{\link[=oddsratio_to_d]{oddsratio_to_d()}}) or custom set -of \code{\link[=rules]{rules()}}.} +\item{rules}{If \code{"cohen1988"} (default), \code{OR} is transformed to a +standardized difference (via \code{\link[=oddsratio_to_d]{oddsratio_to_d()}}) and interpreted according +to Cohen's rules (see \code{\link[=interpret_cohens_d]{interpret_cohens_d()}}; see Chen et al., 2010). If a +custom set of \code{\link[=rules]{rules()}} is used, OR is interperted as is.} + +\item{p0}{Baseline risk. If not specified, the \emph{d} to \emph{OR} conversion uses am approximation (see details).} \item{log}{Are the provided values log odds ratio.} @@ -25,19 +28,12 @@ Interpret Odds Ratio Rules apply to OR as ratios, so OR of 10 is as extreme as a OR of 0.1 (1/10). \itemize{ -\item Chen et al. (2010) (\code{"chen2010"}; default) -\itemize{ -\item \strong{OR < 1.68} - Very small -\item \strong{1.68 <= OR < 3.47} - Small -\item \strong{3.47 <= OR < 6.71} - Medium -\item **OR >= 6.71 ** - Large -} \item Cohen (1988) (\code{"cohen1988"}, based on the \code{\link[=oddsratio_to_d]{oddsratio_to_d()}} conversion, see \code{\link[=interpret_cohens_d]{interpret_cohens_d()}}) \itemize{ \item \strong{OR < 1.44} - Very small \item \strong{1.44 <= OR < 2.48} - Small \item \strong{2.48 <= OR < 4.27} - Medium -\item **OR >= 4.27 ** - Large +\item \strong{OR >= 4.27} - Large } } }