Macro for T-Test

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

Macro for T-Test

Keval Khichadia
Hi,
 
I am trying to run a paired t-test for 23 different questions comparing course-evaluations prior to the course and post-course. Can someone tell me what is wrong with the following syntax. Im guessing it is something in the PAIRS part, not sure how to include all 23 questions. There are 23 unique questions (Q1_Pre, Q1_Post up to Q23_Pre, Q23_Post )
 

DEFINE @TTEST(VAR=!ENCLOSE("<",">"))

!DO !i !IN(!VAR)

TEMP.

SELECT IF GENDER = "F" AND GRADUG = "UG".

T-TEST

PAIRS = !ipre WITH !ipost (PAIRED)

/CRITERIA = CI(.95)

/MISSING = ANALYSIS.

!DOEND

!ENDDEFINE.

@TTEST VAR < Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q8 Q9 Q10 Q11 Q12 Q13 Q14 Q15 Q16 Q17 Q18 Q19 Q20 Q21 Q22 Q23 >.

 

 

Thanks,

 

Keval


Reply | Threaded
Open this post in threaded view
|

Re: Macro for T-Test

Marta Garcia-Granero
Keval Khichadia wrote:
I am trying to run a paired t-test for 23 different questions comparing
course-evaluations prior to the course and post-course. Can someone tell
me what is wrong with the following syntax. Im guessing it is something
in the PAIRS part, not sure how to include all 23 questions. There are
23 unique questions (Q1_Pre, Q1_Post up to Q23_Pre, Q23_Post )

DEFINE @TTEST(VAR=!ENCLOSE("<",">"))
!DO !i !IN(!VAR)
TEMP.
SELECT IF GENDER = "F" AND GRADUG = "UG".
T-TEST
PAIRS = !ipre WITH !ipost (PAIRED)
/CRITERIA = CI(.95)
/MISSING = ANALYSIS.
!DOEND
!ENDDEFINE.

@TTEST VAR < Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q8 Q9 Q10 Q11 Q12 Q13 Q14 Q15 Q16 Q17
Q18 Q19 Q20 Q21 Q22 Q23 >.

There are several things to be corrected in your macro (!ipre and !ipost
must be created using !CONCAT(!i,'_Pre') & !CONCAT(!i,_Post'), for
instance), but I don't think you need one at all. You can get the 23
paired t-tests in one go. Provided the order of the variables in the
dataset is all "_Pre" questions first, all together, then all 2_Post"
questions, all together, you can simplify your code to:

TEMP.
SELECT IF GENDER = "F" AND GRADUG = "UG".
T-TEST PAIRS = Q1_Pre TO Q23_Pre  WITH  Q1_Post TO Q23_Post  (PAIRED).

If the order in the dataset is every pair of Pre-Post questions
together, then you can't use the keyword TO and the list of variables
must be written:

TEMP.
SELECT IF GENDER = "F" AND GRADUG = "UG".
T-TEST PAIRS = Q1_Pre Q2_Pre Q3_Pre Q4_Pre Q5_Pre Q6_Pre Q7_Pre Q8_Pre
Q9_Pre Q10_Pre Q11_Pre Q12_Pre Q13_Pre Q14_Pre Q15_Pre Q16_Pre Q17_Pre
Q18_Pre Q19_Pre Q20_Pre Q21_Pre Q22_Pre Q23_Pre  WITH  Q1_Post Q2_Post
Q3_Post Q4_Post Q5_Post Q6_Post Q7_Post Q8_Post Q9_Post Q10_Post
Q11_Post Q12_Post Q13_Post Q14_Post Q15_Post Q16_Post Q17_Post Q18_Post
Q19_Post Q20_Post Q21_Post Q22_Post Q23_Post (PAIRED).

Any of the two versions of the code will give you the 23 pairedt-tests,
without a macro.
HTH,
Marta GarcĂ­a-Granero

PS: Untested, but I think your macro should be something like that:
DEFINE @TTEST(VAR=!ENCLOSE("<",">"))
!DO !i !IN(!VAR).
!LET !ipre=!CONCAT(!QUOTE(!i),'_Pre').
!LET !ipost=!CONCAT(!QUOTE(!i),'_Post').
TEMP.
SELECT IF GENDER = "F" AND GRADUG = "UG".
T-TEST
PAIRS = !ipre WITH !ipost (PAIRED)
 /CRITERIA = CI(.95)
 /MISSING = ANALYSIS.
!DOEND.
!ENDDEFINE.


--
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