Learn R Programming

effectsize (version 0.4.5)

cohens_d: Effect size for differences

Description

Compute effect size indices for standardized differences: Cohen's d, Hedges' g and Glass<U+2019>s delta. (This function returns the population estimate.)

Both Cohen's d and Hedges' g are the estimated the standardized difference between the means of two populations. Hedges' g provides a bias correction (using the exact method) to Cohen's d for small sample sizes. For sample sizes > 20, the results for both statistics are roughly equivalent. Glass<U+2019>s delta is appropriate when the standard deviations are significantly different between the populations, as it uses only the second group's standard deviation.

Usage

cohens_d(
  x,
  y = NULL,
  data = NULL,
  pooled_sd = TRUE,
  mu = 0,
  paired = FALSE,
  ci = 0.95,
  verbose = TRUE,
  ...
)

hedges_g( x, y = NULL, data = NULL, pooled_sd = TRUE, mu = 0, paired = FALSE, ci = 0.95, verbose = TRUE, ..., correction )

glass_delta( x, y = NULL, data = NULL, mu = 0, ci = 0.95, verbose = TRUE, ..., iterations )

Arguments

x

A formula, a numeric vector, or a character name of one in data.

y

A numeric vector, a grouping (character / factor) vector, a or a character name of one in data. Ignored if x is a formula.

data

An optional data frame containing the variables.

pooled_sd

If TRUE (default), a sd_pooled() is used (assuming equal variance). Else the mean SD from both groups is used instead.

mu

a number indicating the true value of the mean (or difference in means if you are performing a two sample test).

paired

If TRUE, the values of x and y are considered as paired. This produces an effect size that is equivalent to the one-sample effect size on x - y.

ci

Confidence Interval (CI) level

verbose

Toggle warnings and messages on or off.

...

Arguments passed to or from other methods.

iterations, correction

deprecated.

Value

A data frame with the effect size ( Cohens_d, Hedges_g, Glass_delta) and their CIs (CI_low and CI_high).

Confidence Intervals

Unless stated otherwise, confidence intervals are estimated using the Noncentrality parameter method; These methods searches for a the best non-central parameters (ncps) of the noncentral t-, F- or Chi-squared distribution for the desired tail-probabilities, and then convert these ncps to the corresponding effect sizes. (See full effectsize-CIs for more.)

CI Contains Zero

Keep in mind that ncp confidence intervals are inverted significance tests, and only inform us about which values are not significantly different than our sample estimate. (They do not inform us about which values are plausible, likely or compatible with our data.) Thus, when CIs contain the value 0, this should not be taken to mean that a null effect size is supported by the data; Instead this merely reflects a non-significant test statistic - i.e. the p-value is greater than alpha (Morey et al., 2016).

For positive only effect sizes (Eta squared, Cramer's V, etc.; Effect sizes associated with Chi-squared and F distributions), this applies also to cases where the lower bound of the CI is equal to 0. Even more care should be taken when the upper bound is equal to 0 - this occurs when p-value is greater than 1-alpha/2 making, the upper bound cannot be estimated, and the upper bound is arbitrarily set to 0 (Steiger, 2004). For example:

eta_squared(aov(mpg ~ factor(gear) + factor(cyl), mtcars[1:7, ]))

## # Effect Size for ANOVA (Type I)
## 
## Parameter    | Eta2 (partial) |       90% CI
## --------------------------------------------
## factor(gear) |           0.58 | [0.00, 0.84]
## factor(cyl)  |           0.46 | [0.00, 0.78]

Details

Set pooled_sd = FALSE for effect sizes that are to accompany a Welch's t-test (Delacre et al, 2021).

References

  • Algina, J., Keselman, H. J., & Penfield, R. D. (2006). Confidence intervals for an effect size when variances are not equal. Journal of Modern Applied Statistical Methods, 5(1), 2.

  • Cohen, J. (1988). Statistical power analysis for the behavioral sciences (2nd Ed.). New York: Routledge.

  • Delacre, M., Lakens, D., Ley, C., Liu, L., & Leys, C. (2021, May 7). Why Hedges<U+2019> g*s based on the non-pooled standard deviation should be reported with Welch's t-test. https://doi.org/10.31234/osf.io/tu6mp

  • Hedges, L. V. & Olkin, I. (1985). Statistical methods for meta-analysis. Orlando, FL: Academic Press.

  • Hunter, J. E., & Schmidt, F. L. (2004). Methods of meta-analysis: Correcting error and bias in research findings. Sage.

See Also

d_to_common_language() sd_pooled()

Other effect size indices: effectsize(), eta_squared(), phi(), rank_biserial(), standardize_parameters()

Examples

Run this code
# NOT RUN {
# two-sample tests -----------------------

# using formula interface
cohens_d(mpg ~ am, data = mtcars)
cohens_d(mpg ~ am, data = mtcars, pooled_sd = FALSE)
cohens_d(mpg ~ am, data = mtcars, mu = -5)
hedges_g(mpg ~ am, data = mtcars)
glass_delta(mpg ~ am, data = mtcars)
print(cohens_d(mpg ~ am, data = mtcars), append_CL = TRUE)

# other acceptable ways to specify arguments
glass_delta(sleep$extra, sleep$group)
hedges_g("extra", "group", data = sleep)
cohens_d(sleep$extra[sleep$group == 1], sleep$extra[sleep$group == 2], paired = TRUE)
# cohens_d(Pair(extra[group == 1], extra[group == 2]) ~ 1,
#          data = sleep, paired = TRUE)

# one-sample tests -----------------------

cohens_d("wt", data = mtcars, mu = 3)
hedges_g("wt", data = mtcars, mu = 3)

# interpretation -----------------------

interpret_d(0.4, rules = "cohen1988")
d_to_common_language(0.4)
interpret_g(0.4, rules = "sawilowsky2009")
interpret_delta(0.4, rules = "gignac2016")
# }

Run the code above in your browser using DataLab