# Converting Between Indices of Effect Size

The `effectsize` package contains function to convert among indices of effect size. This can be useful for meta-analyses, or any comparison between different types of statistical analyses.

## Converting Between d, r, and OR

The most basic conversion is between r values, a measure of standardized association between two continuous measures, and d values (such as Cohen’s d), a measure of standardized differences between two groups / conditions.

Let’s simulate some data:

    set.seed(1)
    data <- bayestestR::simulate_difference(
      n = 10,
      d = 0.2,
      names = c("Group", "Outcome")
    )

    >    Group Outcome
    > 1      0  -0.942
    > 2      0  -0.485
    > 3      0  -0.100
    > 4      0   0.285
    > 5      0   0.742
    > 6      1  -0.742
    > 7      1  -0.285
    > 8      1   0.100
    > 9      1   0.485
    > 10     1   0.942

We can compute Cohen’s d between the two groups:

    cohens_d(Outcome ~ Group, data = data)

    > Cohen's d |        95% CI
    > -------------------------
    > -0.31     | [-1.54, 0.95]
    >
    > - Estimated using pooled SD.

But we can also treat the 2-level `group` variable as a numeric variable, and compute Pearson’s r:

    correlation::correlation(data, include_factors = TRUE)[2, ]

    > # Correlation Matrix (pearson-method)
    >
    > Parameter1 | Parameter2 |     r |        95% CI |  t(8) |      p
    > ----------------------------------------------------------------
    > Group.0    |    Outcome | -0.17 | [-0.72, 0.52] | -0.48 | > .999
    >
    > p-value adjustment method: Holm (1979)
    > Observations: 10

But what if we only have summary statistics? Say, we only have \(d=-0.37\) and we want to know what the r would have been? We can approximate r using the following formula (Borenstein et al. 2009):

\[ r \approx \frac{d}{\sqrt{d^2 + 4}} \] And indeed, if we use `d_to_r()`, we get a pretty decent approximation:

    d_to_r(-0.31)

    > [1] -0.153

(Which also works in the other way, with `r_to_d(0.17)` gives `r round(r_to_d(-0.17),3)`)

As we can see, these are rough approximations, but they can be useful when we don’t have the raw data on hand.

### In multiple regression

Although not exactly a classic Cohen’s d, we can also approximate a partial-d value (that is, the standardized difference between two groups / conditions, with variance from other predictors partilled out). For example:

    fit <- lm(mpg ~ am + hp, data = mtcars)

    parameters::model_parameters(fit)

    > Parameter   | Coefficient |       SE |         95% CI | t(29) |      p
    > ----------------------------------------------------------------------
    > (Intercept) |       26.58 |     1.43 | [23.67, 29.50] | 18.65 | < .001
    > am          |        5.28 |     1.08 | [ 3.07,  7.48] |  4.89 | < .001
    > hp          |       -0.06 | 7.86e-03 | [-0.07, -0.04] | -7.50 | < .001

    >
    > Uncertainty intervals (equal-tailed) and p values (two-tailed) computed using a
    >   Wald t-distribution approximation.

    # A couple of ways to get partial-d:
    5.28 / sigma(fit)

    > [1] 1.81

    t_to_d(4.89, df_error = 29)[[1]]

    > [1] 1.82

We can convert these semi-d values to r values, but in this case these represent the partial correlation:

    t_to_r(4.89, df_error = 29)

    > r    |       95% CI
    > -------------------
    > 0.67 | [0.43, 0.80]

    correlation::correlation(mtcars[, c("mpg", "am", "hp")], partial = TRUE)[1, ]

    > # Correlation Matrix (pearson-method)
    >
    > Parameter1 | Parameter2 |    r |       95% CI | t(30) |         p
    > -----------------------------------------------------------------
    > mpg        |         am | 0.67 | [0.42, 0.83] |  4.97 | < .001***
    >
    > p-value adjustment method: Holm (1979)
    > Observations: 32

    # all close to:
    d_to_r(1.81)

    > [1] 0.671

## From Odds ratios

In binomial regression (more specifically in logistic regression), Odds ratios (OR) are themselves measures of effect size; they indicate the expected change in the odds of a some event.

In some fields, it is common to dichotomize outcomes in order to be able to analyze them with logistic models. For example, if the outcome is the count of white blood cells, it can be more useful (medically) to predict the crossing of the threshold rather than the raw count itself. And so, where some scientists would maybe analyze the above data with a t-test and present Cohen’s d, others might analyze it with a logistic regression model on the dichotomized outcome, and present OR. So the question can be asked: given such a OR, what would Cohen’s d have been?

Fortunately, there is a formula to approximate this (Sánchez-Meca, Marı́n-Martı́nez, and Chacón-Moscoso 2003):

\[ d = log(OR) \times \frac{\sqrt{3}}{\pi} \]

which is implemented in the `oddsratio_to_d()` function.

Let’s give it a try:

    # 1. Set a threshold
    thresh <- 0

    # 2. dichotomize the outcome
    data$Outcome_binom <- data$Outcome < thresh

    # 3. Fit a logistic regression:
    fit <- glm(Outcome_binom ~ Group,
      data = data,
      family = binomial()
    )

    parameters::model_parameters(fit)

    > Parameter   | Log-Odds |   SE |        95% CI |     z |     p
    > -------------------------------------------------------------
    > (Intercept) |     0.41 | 0.91 | [-1.39, 2.43] |  0.44 | 0.657
    > Group [1]   |    -0.81 | 1.29 | [-3.54, 1.70] | -0.63 | 0.530

    >
    > Uncertainty intervals (profile-likelihood) and p values (two-tailed) computed
    >   using a Wald z-distribution approximation.

    # Convert log(OR) (the coefficient) to d
    oddsratio_to_d(-0.81, log = TRUE)

    > [1] -0.447

### Odds ratios to Risk Ratios

Odds ratio, although popular, are not very intuitive in their interpretations. We don’t often think about the chances of catching a disease in terms of odds, instead we instead tend to think in terms of probability or some event - or the risk. Talking about risks we can also talk about the change in risk, knows as the risk ratio (RR).

For example, if we find that for individual suffering from a migraine, for every bowl of brussels sprouts they eat, they’re odds of reducing the migraine increase by an \(OR = 3.5\) over a period of an hour. So, should people eat brussels sprouts to effectively reduce pain? Well, hard to say… Maybe if we look at RR we’ll get a clue.

We can convert between OR and RR for the following formula (Grant 2014):

\[ RR = \frac{OR}{(1 - p0 + (p0 \times OR))} \]

Where \(p0\) is the base-rate risk - the probability of the event without the intervention (e.g., what is the probability of the migraine subsiding within an hour without eating any brussels sprouts). If it the base-rate risk is, say, 85%, we get a RR of:

    OR <- 3.5
    baserate <- 0.85

    oddsratio_to_riskratio(OR, baserate)

    > [1] 1.12

That is - for every bowl of brussels sprouts, we increase the chances of reducing the migraine by a mere 12%! Is if worth it? Depends on you affinity to brussels sprouts…

Note that the base-rate risk is crucial here. If instead of 85% it was only 4%, then the RR would be:

    OR <- 3.5
    baserate <- 0.04

    oddsratio_to_riskratio(OR, baserate)

    > [1] 3.18

That is - for every bowl of brussels sprouts, we increase the chances of reducing the migraine by a whopping 318%! Is if worth it? I guess that still depends on your affinity to brussels sprouts…

# References

Borenstein, Michael, Larry V Hedges, JPT Higgins, and Hannah R Rothstein. 2009. “Converting Among Effect Sizes.” Introduction to Meta-Analysis, 45–49.
Grant, Robert L. 2014. “Converting an Odds Ratio to a Range of Plausible Relative Risks for Better Communication of Research Findings.” Bmj 348: f7450.
Sánchez-Meca, Julio, Fulgencio Marı́n-Martı́nez, and Salvador Chacón-Moscoso. 2003. “Effect-Size Indices for Dichotomized Outcomes in Meta-Analysis.” Psychological Methods 8 (4): 448.