CI_smd_ind_contrast: Estimate standardized mean difference (Cohen's d) for an...

View source: R/CI_smd_ind_contrast.R

CI_smd_ind_contrastR Documentation

Estimate standardized mean difference (Cohen's d) for an independent groups contrast

Description

\loadmathjax

CI_smd_ind_contrast returns the point estimate and confidence interval for a standardized mean difference (smd aka Cohen's d aka Hedges g). A standardized mean difference is a difference in means standardized to a standard deviation: \mjdeqnd = \frac \psi sd = psi/s

Usage

CI_smd_ind_contrast(
  means,
  sds,
  ns,
  contrast,
  conf_level = 0.95,
  assume_equal_variance = FALSE,
  correct_bias = TRUE
)

Arguments

means

A vector of 2 or more means

sds

A vector of standard deviations, same length as means

ns

A vector of sample sizes, same length as means

contrast

A vector of group weights, same length as means

conf_level

The confidence level for the confidence interval, in decimal form. Defaults to 0.95.

assume_equal_variance

Defaults to FALSE

correct_bias

Defaults to TRUE; attempts to correct the slight upward bias in d derived from a sample. Correction is not possible for 3 or more groups when equal variance is not assumed, though in such cases, correction should usually be trivial.

Value

Returns a list with these named elements:

  • effect_size - the point estimate from the sample

  • lower - lower bound of the CI

  • upper - upper bound of the CI

  • numerator - the numerator for Cohen's d_biased; the mean difference in the contrast

  • denominator - the denominator for Cohen's d_biased; if equal variance is assumed this is sd_pooled, otherwise sd_avg

  • df - the degrees of freedom used for correction and CI calculation

  • se - the standard error of the estimate; warning not totally sure about this yet

  • moe - margin of error; 1/2 length of the CI

  • d_biased - Cohen's d without correction applied

  • properties - a list of properties for the result

Properties

  • effect_size_name - if equal variance assumed d_s, otherwise d_avg

  • effect_size_name_html - html representation of d_name

  • denominator_name - if equal variance assumed sd_pooled otherwise sd_avg

  • denominator_name_html - html representation of denominator name

  • bias_corrected - TRUE/FALSE if bias correction was applied

  • message - a message explaining denominator and correction status

  • message_html - html representation of message

Details

It's a bit complicated

A standardized mean difference turns out to be complicated.

First, it has many names:

  • standardized mean difference (smd)

  • Cohen's d

  • When bias in a sample d has been corrected, also called Hedge's g

Second, the choice of the standardizer requires thought:

  • sd_pooled - used when assuming all groups have exact same variance

  • sd_avg - does not require assumption of equal variance

  • other possibilities, too, but not dealt with in this function

The choice of standardizer is important, so it's noted in the subscript:

  • d_s – assumes equal variance, standardized to sd_pooled

  • d_avg - does not assume equal variance, standardized to sd_avg

A third complication is the issue of bias: d estimated from a sample has a slight upward bias at smaller sample sizes. With total sample size > 30, this slight bias becomes fairly neglible (kind of like the small upward bias in a sample standard deviation).

This bias can be corrected when equal variance is assumed or when the design of the study is simple (2 groups). For complex designs (>2 groups) without the assumption of equal variance, bias cannot be corrected, but in these cases, sample sizes should typically be large enough for this not to matter much.

Corrections for bias produce a long-run reduction in average bias. Corrections for bias are approximate.

How are d and its CI calculated?

When equal variance is assumed

When equal variance is assumed, the standardized mean difference is d_s, defined in Kline, p. 196: \mjdeqn d_s = \frac \psi sd_pooled d_s = psi / sd_s

where psi is defined in Kline, equation 7.8 \mjdeqn \psi = \sum_i=1^ac_iM_i psi = sum(contrasts*means)

and where sd_pooled is defined in Kline, equation 3.11 \mjdeqn sd_pooled = \frac \sum_i=1^a (n_i -1) s_i^2 \sum_i=1^a (n_i-1) sqrt(sum(variances*dfs) / sum(dfs))

The CI for d_s is derived from lambda-prime transformation from Lecoutre, 2007 with code adapted from Cousineau & Goulet-Pelletier, 2020. Kelley, 2007 explains the general approach for linear contrasts.

This approach to generating the CI is 'exact', meaning coverage should be as desired if all assumptions are met (ha!).

Correction of upward bias can be applied.

When equal variance is not assumed

When equal variance is not assumed, the standardized mean difference is d_avg, defined in Bonett, equation 6: \mjdeqn d_avg = \frac \psi sd_avg d_avg = psi / sd_avg

Where sd_avg is the square root of the average of the group variances, as given in Bonett, explanation of equation 6: \mjdeqn sd_avg = \sqrt \frac \sum_i=1^a s_i^2 a sqrt(mean(variances))

If only 2 groups
  • The CI is derived from lambda-prime transformation using df and se from Huynh, 1989 – see especially Delacre et al., 2021

  • This is also an 'exact' approach, and correction can be applied

If more than 2 groups
  • CI is approximated using the approach from Bonett, 2008

  • No correction is applied

  • If correct_bias is TRUE, a warning is raised

References

See Also

  • estimate_mdiff_ind_contrast for friendly version that returns raw score effect sizes for this design

Examples

# Example from Kline, 2013
#  Data in Table 3.4
#  Worked out in Chapter 7
#  See p. 202, non-central approach
# With equal variance assumed and no correction, should give:
#   d_s = -0.8528028 [-2.121155, 0.4482578]

CI_smd_ind_contrast(
  means = c(13, 11, 15),
  sds = c(2.738613, 2.236068, 2.000000),
  ns = c(5, 5, 5),
  contrast = contrast <- c(1, 0, -1),
  conf_level = 0.95,
  assume_equal_variance = TRUE,
  correct_bias = FALSE
)

# Example from Bonett, 2018, ci.lc.stdmean.bs,
#  https://people.ucsc.edu/~dgbonett/psyc204.html
# Without correction, should give:
#                               Estimate        SE        LL         UL
# Equal Variances Not Assumed: -1.301263 0.3692800 -2.025039 -0.5774878
# Equal Variances Assumed:     -1.301263 0.3514511 -1.990095 -0.6124317

CI_smd_ind_contrast(
  means = c(33.5, 37.9, 38.0, 44.1),
  sds = c(3.84, 3.84, 3.65, 4.98),
  ns = c(10,10,10,10),
  contrast = contrast <- c(.5, .5, -.5, -.5),
  conf_level = 0.95,
  assume_equal_variance = FALSE,
  correct_bias = FALSE
)



rcalinjageman/esci4 documentation built on May 18, 2023, 4:01 a.m.