Skip to contents

This function displays d for two between subjects groups and gives the central and non-central confidence interval using the pooled standard deviation as the denominator.

Usage

calculate_d(
  m1 = NULL,
  m2 = NULL,
  sd1 = NULL,
  sd2 = NULL,
  n1 = NULL,
  n2 = NULL,
  t = NULL,
  model = NULL,
  df = NULL,
  x_col = NULL,
  y_col = NULL,
  d = NULL,
  a = 0.05,
  lower = TRUE
)

Arguments

m1

mean group one

m2

mean group two

sd1

standard deviation group one

sd2

standard deviation group two

n1

sample size group one

n2

sample size group two

t

optional, calculate d from independent t, you must include n1 and n2 for degrees of freedom

model

optional, calculate d from t.test for independent t, you must still include n1 and n2

df

optional dataframe that includes the x_col and y_col

x_col

name of the column that contains the factor levels OR a numeric vector of group 1 scores

y_col

name of the column that contains the dependent score OR a numeric vector of group 2 scores

d

a previously calculated d value from a study

a

significance level

lower

Use this to indicate if you want the lower or upper bound of d for one sided confidence intervals. If d is positive, you generally want lower = TRUE, while negative d values should enter lower = FALSE for the upper bound that is closer to zero.

Value

Provides the effect size (Cohen's *d*) with associated central and non-central confidence intervals, the *t*-statistic, the confidence intervals associated with the means of each group, as well as the standard deviations and standard errors of the means for each group. The one-tailed confidence interval is also included for sensitivity analyses.

d

effect size

dlow

noncentral lower level confidence interval of d value

dhigh

noncentral upper level confidence interval of d value

dlow_central

central lower level confidence interval of d value

dhigh_central

central upper level confidence interval of d value

done_low

noncentral lower bound of one tailed confidence interval

done_low_central

central lower bound of one tailed confidence interval

M1

mean of group one

sd1

standard deviation of group one mean

se1

standard error of group one mean

M1low

lower level confidence interval of group one mean

M1high

upper level confidence interval of group one mean

M2

mean of group two

sd2

standard deviation of group two mean

se2

standard error of group two mean

M2low

lower level confidence interval of group two mean

M2high

upper level confidence interval of group two mean

spooled

pooled standard deviation

sepooled

pooled standard error

n1

sample size of group one

n2

sample size of group two

df

degrees of freedom (n1 - 1 + n2 - 1)

t

t-statistic

p

p-value

estimate

the d statistic and confidence interval in APA style for markdown printing

statistic

the t-statistic in APA style for markdown printing

Details

To calculate \(d_s\), mean two is subtracted from mean one and divided by the pooled standard deviation. $$d_s = \frac{M_1 - M_2}{S_{pooled}}$$

You should provide one combination of the following:

1: m1 through n2

2: t, n1, n2

3: model, n1, n2

4: df, "x_col", "y_col"

5: x_col, y_col as numeric vectors

6: d, n1, n2

You must provide alpha and lower to ensure the right confidence interval is provided for you.

Examples

calculate_d(m1 = 14.37, # neglect mean
   sd1 = 10.716, # neglect sd
   n1 = 71, # neglect n
   m2 = 10.69, # none mean
   sd2 = 8.219, # none sd
   n2 = 3653, # none n
   a = .05, # alpha/confidence interval
   lower = TRUE) # lower or upper bound
#> $d
#> [1] 0.4448249
#> 
#> $dlow
#> [1] 0.2097233
#> 
#> $dhigh
#> [1] 0.6798669
#> 
#> $dlow_central
#> [1] 0.2096767
#> 
#> $dhigh_central
#> [1] 0.6799731
#> 
#> $done_low
#> [1] 0.2475166
#> 
#> $done_low_central
#> [1] 0.2474974
#> 
#> $M1
#> [1] 14.37
#> 
#> $sd1
#> [1] 10.716
#> 
#> $se1
#> [1] 1.271755
#> 
#> $M1low
#> [1] 11.83356
#> 
#> $M1high
#> [1] 16.90644
#> 
#> $M2
#> [1] 10.69
#> 
#> $sd2
#> [1] 8.219
#> 
#> $se2
#> [1] 0.135986
#> 
#> $M2low
#> [1] 10.42338
#> 
#> $M2high
#> [1] 10.95662
#> 
#> $spooled
#> [1] 8.272918
#> 
#> $sepooled
#> [1] 0.9913101
#> 
#> $n1
#> [1] 71
#> 
#> $n2
#> [1] 3653
#> 
#> $df
#> [1] 3722
#> 
#> $t
#> [1] 3.712259
#> 
#> $p
#> [1] 0.0002084243
#> 
#> $estimate
#> [1] "$d_s$ = 0.44, 95\\% CI [0.21, 0.68]"
#> 
#> $statistic
#> [1] "$t$(3722) = 3.71, $p$ < .001"
#>