T-Test & Cohen's d

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

T-Test & Cohen's d

Andrew Piskorowski

Hello All-

 

I need assistance in writing syntax to perform a paired samples t-test and then calculate cohen's d as the effect size measure. I was able to find syntax to do this for an independent samples t-test and it is pasted below:

 

T-TEST
GROUPS=IV(1 2)
/VARIABLES= DV
/CRITERIA= CIN(.99).

 

AGGREGATE/OUTFILE=*/BREAK=IV/m2=MEAN(DV)/sd2=SD(DV)/n2=N.
COMPUTE N1=LAG(N2,1).
COMPUTE M1=LAG(M2,1).
COMPUTE sd1=LAG(sd2,1).
EXECUTE.
SELECT IF(IV=2).
EXECUTE.

 

COMPUTE SP2=(((N1-1)*(sd1**2))+((N2-1)*(sd2**2)))/(N1+N2-2).
COMPUTE T=(M1-M2)/SQR(SP2*((1/N1)+(1/N2))).
COMPUTE DF=(N1+N2-2).
COMPUTE P = CDF.T(t,df) .
COMPUTE d=T*SQR((1/N1)+(1/N2)).
COMPUTE d=ABS(d).
FORMATS ALL(F8.2) DF N1 N2(F8.0) P(F8.4).
SUMMARIZE
/TABLES=d T DF P N1 N2
/FORMAT=NOLIST TOTAL
/TITLE='t test and cohens d'
/CELLS=FIRST.

 

I now need to replicate this with a paired samples t-test in which the cohen's d is calculated as follows: d=t*SQRT(2(1-r)/N) with r = the correlation between the pairs of scores in the data. I know how to write code for the simple paired samples t-test, but cannot figure out how to write the second two sections that appear in the syntax above. Can anyone assist?

-Andrew

 

Reply | Threaded
Open this post in threaded view
|

Re: T-Test & Cohen's d

Marta Garcia-Granero
Andrew Piskorowski wrote:

>
> I need assistance in writing syntax to perform a paired samples t-test
> and then calculate cohen's d as the effect size measure. I was able to
> find syntax to do this for an independent samples t-test and it is
> pasted below:
>
>
>
> T-TEST
> GROUPS=IV(1 2)
> /VARIABLES= DV
> /CRITERIA= CIN(.99).
>
>
>
> AGGREGATE/OUTFILE=*/BREAK=IV/m2=MEAN(DV)/sd2=SD(DV)/n2=N.
> COMPUTE N1=LAG(N2,1).
> COMPUTE M1=LAG(M2,1).
> COMPUTE sd1=LAG(sd2,1).
> EXECUTE.
> SELECT IF(IV=2).
> EXECUTE.
>
>
>
> COMPUTE SP2=(((N1-1)*(sd1**2))+((N2-1)*(sd2**2)))/(N1+N2-2).
> COMPUTE T=(M1-M2)/SQR(SP2*((1/N1)+(1/N2))).
> COMPUTE DF=(N1+N2-2).
> COMPUTE P = CDF.T(t,df) .
> COMPUTE d=T*SQR((1/N1)+(1/N2)).
> COMPUTE d=ABS(d).
> FORMATS ALL(F8.2) DF N1 N2(F8.0) P(F8.4).
> SUMMARIZE
> /TABLES=d T DF P N1 N2
> /FORMAT=NOLIST TOTAL
> /TITLE='t test and cohens d'
> /CELLS=FIRST.
>
>
>
> I now need to replicate this with a paired samples t-test in which the
> cohen's d is calculated as follows: d=t*SQRT(2(1-r)/N) with r = the
> correlation between the pairs of scores in the data. I know how to
> write code for the simple paired samples t-test, but cannot figure out
> how to write the second two sections that appear in the syntax above.
> Can anyone assist?
>

Why don't you extract the relevant info (t, n & r) using OMS?

* Saple dataset *.
DATA LIST LIST /var1 var2 (2 F8.0).
begin data
494    512
395    430
516    520
434    428
476    500
557    600
413    364
442    380
650    658
433    445
417    432
656    626
267    260
478    477
178    259
423    350
427    451
END DATA.

SET OLANG=ENGLISH.
DATASET DECLARE TData.
OMS
 /SELECT TABLES
 /IF COMMANDS = ["T-Test"]
     SUBTYPES = ["Paired Samples Test"]
 /DESTINATION FORMAT = SAV
  OUTFILE = TData.
DATASET DECLARE Corrdata.
OMS
 /SELECT TABLES
 /IF COMMANDS = ["T-Test"]
     SUBTYPES = ["Paired Samples Correlations"]
 /DESTINATION FORMAT = SAV
  OUTFILE = Corrdata.

T-TEST PAIRS = var1 WITH var2.

OMSEND.
DATASET ACTIVATE TData.
DELETE VARIABLES Command_ TO Upper df Sig.2tailed.
MATCH FILES /FILE=*
 /FILE='Corrdata'
 /RENAME (Command_ Label_ Sig Subtype_ Var1 Var2 = d0 d1 d2 d3 d4 d5)
 /DROP= d0 d1 d2 d3 d4 d5.
COMPUTE d=t*SQRT(2*(1-Correlation/N)).
LIST.

HTH,
Marta GarcĂ­a-Granero
>
>
> -*Andrew*
>
>
>


--
For miscellaneous statistical stuff, visit:
http://gjyp.nl/marta/

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD