cohen.d {psych} | R Documentation |
Given a data.frame or matrix, find the standardized mean difference (Cohen's d) and confidence intervals for each variable depending upon a grouping variable. Convert the d statistic to the r equivalent, report the student's t statistic and associated p values, and return statistics for both values of the grouping variable. The Mahalanobis distance between the centroids of the two groups in the space defined by all the variables ia also found. Confidence intervals for Cohen d for one group (difference from 0) may also be found.
cohen.d(x, group,alpha=.05,std=TRUE) cohen.d.ci(d,n=NULL,n2=NULL,n1=NULL,alpha=.05) d.ci(d,n=NULL,n2=NULL,n1=NULL,alpha=.05) cohen.d.by(x,group,group2,alpha=.05) d2r(d) r2d(rho) d2t(d,n=NULL,n2=NULL,n1=NULL) t2d(t,n=NULL,n2=NULL,n1=NULL)
x |
A data frame or matrix |
group |
Some dichotomous grouping variable |
group2 |
Apply cohen.d for each of the subgroups defined by group2 |
d |
An effect size |
n |
Total sample size (of groups 1 and 2) |
n1 |
Sample size of group 1 (if only one group) |
n2 |
Sample size of group 2 |
t |
Student's t statistic |
alpha |
1-alpha is the width of the confidence interval |
std |
Find the correlation rather covariance matrix |
rho |
A correlation to be converted to an effect size |
There are many ways of reporting how two groups differ. Cohen's d statistic is just the differences of means expressed in terms of the pooled within group standard deviation. This is insensitive to sample size. r is the a universal measure of effect size that is a simple function of d, but is bounded -1 to 1. The t statistic is merely d * sqrt(n)/2 and thus reflects sample size.
Confidence intervals for Cohen's d may be found by converting the d to a t, finding the confidence intervals for t, and then converting those back to ds. This take advantage of the uniroot function and the non-centrality parameter of the t distribution.
In the case of finding the confidence interval for a comparison against 0 (the one sample case), specify n1. This will yield a d = t/sqrt(n1) whereas in the case of the differnece between two samples, d = 2*t/sqrt(n) (for equal sample sizes n = n1+ n2) or d = t/sqrt(1/n1 + 1/n2) for the case of unequal sample sizes.
cohen.d.by
will find Cohen's d for groups for each subset of the data defined by group2. The summary of the output produces a simplified listing of the d values for each variable for each group.
d |
Cohen's d statistic, including the upper and lower confidence levels |
hedges.g |
Hedge's g statistic |
M.dist |
Mahalanobis distance between the two groups |
t |
Student's t statistic |
r |
The point biserial r equivalent of d |
n |
sample size used for each analysis |
p |
The probability of abs(t)>0 |
descriptive |
The descriptive statistics for each group |
William Revelle
Cohen, Jackob (1988) Statistical Power Analysis for the Behavioral Sciences. 2nd Edition, Lawrence Erlbaum Associates.
describeBy
, describe
cohen.d(sat.act,"gender") cd <- cohen.d.by(sat.act,"gender","education") summary(cd) #summarize the output #now show several examples of confidence intervals #one group (d vs 0) #consider the t from the cushny data set t2d( -4.0621,n1=10) d.ci(-1.284549,n1=10) #the confidence interval of the effect of drug on sleep #two groups d.ci(.62,n=64) #equal group size d.ci(.62,n1=35,n2=29) #unequal group size