Moderators: statman, Analyst Techy, andris, Fierce, GerineL, Smash
Code: Select all
http://www.spss.com/devcentral/
[/u]*(Q) I have ran a series of t tests on groups with unequal ns and would like to
compute Cohen's d. I see that SPSS doesn't have option available. How do I
compute the ds from the given SPSS output? Is there a macro available?
*(A) Posted by Marta to SPSSX-L list on 2002/06/05; improved on 2004/10/08.
* I have updated a code I posted to the list 2 years ago. It
* calculates Glass, Hedges & Cohen standardised effect sizes, with their
* standard errors. These values are then added to the dataset.
* Marta 2004/10/08 mailto:biostatistics@terra.es
Cohen's d is simply=(mean1-mean2)/Sp.
Where Sp is the pooled standard deviation:
Sp=sqrt((n1-1)*var1+(n2-1)*var2)/(n1+n2-2)).
- var1=variance of sample 1 (Sd1^2)
- var2=variance of sample 2 (Sd2^2)
If the sample sizes in your study are small, then it's better to use an
unbiased estimator called Hedges' g:
hedges g=cohen&*(1-(3/(4*(n1+n2)-9)))
If variances are unequal, sometimes another standardized mean difference
is used, called
Glass' d=(mean1-mean2)/Sd2
(Sd2= standard deviation from control group).
You can get all the required information from the statistics table in
the output.
* Improved code *.
* Example dataset (replace by your own but keep variable names) *.
* Data for treatment group go first place, and control group 2nd.
DATA LIST LIST /test(A7) meantr sdtr(2F8.2) ntr(F8.0)
meanco sdco(2F8.2) nco(F8.0).
BEGIN DATA
1 35 9 17 24 8 18
2 43 10 15 37 7 16
3 40 2.3 18 32 2.54 19
END DATA.
* Analysis *.
MATRIX.
GET test /VAR=test.
GET mean1 /VAR=meantr.
GET sd1 /VAR=sdtr.
GET n1 /VAR=ntr.
GET mean2 /VAR=meanco.
GET sd2 /VAR=sdco.
GET n2 /VAR=nco.
PRINT {mean1,sd1,n1,mean2,sd2,n2}
/FORMAT='F8.1'
/TITLE='Original data'
/RNAMES=test
/CLABELS='Mean1','SD1','N1','Mean2','SD2','N2'.
COMPUTE n=n1+n2.
COMPUTE poolvar=((n1-1)&*(sd1&**2)+(n2-1)&*(sd2&**2))/(n-2) .
COMPUTE glass=(mean1-mean2)/sd2.
COMPUTE se_glass=SQRT((n/(n1&*n2))+((glass&**2)/(2&*(n2-1)))).
COMPUTE cohen=(mean1-mean2)/SQRT(poolvar).
COMPUTE se_cohen=SQRT((n/(n1&*n2))+((cohen&**2)/(2&*(n-2)))).
COMPUTE hedges=cohen&*(1-(3/(4&*(n)-9))).
COMPUTE se_hedge=SQRT((n/(n1&*n2))+((hedges&**2)/(2&*(n-3.94)))).
PRINT {glass,se_glass,cohen,se_cohen,hedges,se_hedge}
/FORMAT='F8.3'
/RNAMES=test
/CLABELS='Glass','SE(D)','Cohen','SE(d)','Hedges','SE(g)'
/TITLE='Standardized effects sizes'.
COMPUTE data={glass,se_glass,cohen,se_cohen,hedges,se_hedge}.
COMPUTE namevec={'glass','seglass','cohen','secohen','hedges','sehedges'}.
SAVE data /OUTFILE='c:\temp\data.sav' /NAMES=namevec.
END MATRIX.
MATCH FILES /FILE=*
/FILE='c:\temp\data.sav'.
EXECUTE.
Users browsing this forum: No registered users and 1 guest