* Stop syntax and large titles from printing to output. SET PRINTBACK=NONE HEADER=NO. ***********************************************************************************. ******* BEGIN DATA MANIPULATION OF CHAPTER 6 EXAMPLE *******. ******* CHANGE "filesave" to your directory *******. ***********************************************************************************. * Define location of files used in code below. FILE HANDLE filesave /NAME = "C:\Dropbox\PilesOfVariance\Chapter6\SPSS". * Import chapter 3 stacked data and create time predictor variables. GET FILE = "filesave/SPSS_Chapter6.sav". DATASET NAME Chapter6 WINDOW=FRONT. * Predictors for polynomial time models. COMPUTE time1 = session - 1. COMPUTE time6 = session - 6. VARIABLE LABELS time1 "time1: Session (0=1)" time6 "time6: Session (0=6)". * Predictors for piecewise time models. RECODE session (1=0) (2 THRU HI=1) INTO slope12. RECODE session (LO THRU 2=0) (3=1) (4=2) (5=3) (6=4) INTO slope26. VARIABLE LABELS slope12 "slope12: Early Practice Slope (Session 1-2)" slope26 "slope26: Later Practice Slope (Session 2-6)". EXECUTE. ***********************************************************************************. ******* BEGIN CHAPTER 6 MODELS *******. ******* NOTE: NEGATIVE EXPONENTIAL MODELS ARE NOT POSSIBLE IN SPSS *******. ***********************************************************************************. * Open output directory. OUTPUT NAME SPSS_Chapter6_Output. ECHO "Chapter 6 Example: Means by session for RT outcome". SUMMARIZE /TABLES = rt BY session /FORMAT = NOLIST TOTAL /CELLS = COUNT MEAN SEMEAN MIN MAX. DATASET ACTIVATE Chapter6 WINDOW=FRONT. ECHO 'Ch 6: 0: Saturated Means, Unstructured Variance Model;'. ECHO 'TOTAL ANSWER KEY'. MIXED rt BY PersonID session /METHOD = REML /PRINT = SOLUTION TESTCOV R /FIXED = session /REPEATED = session | COVTYPE(UN) SUBJECT(PersonID) /EMMEANS = TABLES(session) COMPARE(session) . DATASET ACTIVATE Chapter6 WINDOW=FRONT. ECHO 'Ch 6: 1a: Empty Means, E-Only Variance Model'. MIXED rt BY PersonID session /METHOD = REML /PRINT = SOLUTION TESTCOV R /FIXED = /REPEATED = session | COVTYPE(ID) SUBJECT(PersonID) . DATASET ACTIVATE Chapter6 WINDOW=FRONT. ECHO 'Ch 6: 1b: Empty Means, Random Intercept Model'. MIXED rt BY PersonID session /METHOD = REML /PRINT = SOLUTION TESTCOV G R /FIXED = /RANDOM = INTERCEPT | COVTYPE(UN) SUBJECT(PersonID) /REPEATED = session | COVTYPE(ID) SUBJECT(PersonID) . DATASET ACTIVATE Chapter6 WINDOW=FRONT. ECHO 'Ch 6: 2a: Fixed Linear Time, Random Intercept Model'. MIXED rt BY PersonID session WITH time1 /METHOD = REML /PRINT = SOLUTION TESTCOV G R /FIXED = time1 /RANDOM = INTERCEPT | COVTYPE(UN) SUBJECT(PersonID) /REPEATED = session | COVTYPE(ID) SUBJECT(PersonID) /TEST = 'Intercept at Session=1 Time=0' intercept 1 time1 0 /TEST = 'Intercept at Session=2 Time=1' intercept 1 time1 1 /TEST = 'Intercept at Session=3 Time=2' intercept 1 time1 2 /TEST = 'Intercept at Session=4 Time=3' intercept 1 time1 3 /TEST = 'Intercept at Session=5 Time=4' intercept 1 time1 4 /TEST = 'Intercept at Session=6 Time=5' intercept 1 time1 5 . DATASET ACTIVATE Chapter6 WINDOW=FRONT. ECHO 'Ch 6: 2b: Random Linear Time Model'. MIXED rt BY PersonID session WITH time1 /METHOD = REML /PRINT = SOLUTION TESTCOV G R /FIXED = time1 /RANDOM = INTERCEPT time1 | COVTYPE(UN) SUBJECT(PersonID) /REPEATED = session | COVTYPE(ID) SUBJECT(PersonID) /TEST = 'Intercept at Session=1 Time=0' intercept 1 time1 0 /TEST = 'Intercept at Session=2 Time=1' intercept 1 time1 1 /TEST = 'Intercept at Session=3 Time=2' intercept 1 time1 2 /TEST = 'Intercept at Session=4 Time=3' intercept 1 time1 3 /TEST = 'Intercept at Session=5 Time=4' intercept 1 time1 4 /TEST = 'Intercept at Session=6 Time=5' intercept 1 time1 5 . DATASET ACTIVATE Chapter6 WINDOW=FRONT. ECHO 'Ch 6: 3a: Fixed Quadratic, Random Linear Time Model'. MIXED rt BY PersonID session WITH time1 /METHOD = REML /PRINT = SOLUTION TESTCOV G R /FIXED = time1 time1*time1 /RANDOM = INTERCEPT time1 | COVTYPE(UN) SUBJECT(PersonID) /REPEATED = session | COVTYPE(ID) SUBJECT(PersonID) /TEST = 'Intercept at Session=1 Time=0' intercept 1 time1 0 time1*time1 0 /TEST = 'Intercept at Session=2 Time=1' intercept 1 time1 1 time1*time1 1 /TEST = 'Intercept at Session=3 Time=2' intercept 1 time1 2 time1*time1 4 /TEST = 'Intercept at Session=4 Time=3' intercept 1 time1 3 time1*time1 9 /TEST = 'Intercept at Session=5 Time=4' intercept 1 time1 4 time1*time1 16 /TEST = 'Intercept at Session=6 Time=5' intercept 1 time1 5 time1*time1 25 /TEST = 'Linear Slope at Session=1 Time=0' time1 1 time1*time1 0 /TEST = 'Linear Slope at Session=2 Time=1' time1 1 time1*time1 2 /TEST = 'Linear Slope at Session=3 Time=2' time1 1 time1*time1 4 /TEST = 'Linear Slope at Session=4 Time=3' time1 1 time1*time1 6 /TEST = 'Linear Slope at Session=5 Time=4' time1 1 time1*time1 8 /TEST = 'Linear Slope at Session=6 Time=5' time1 1 time1*time1 10 . DATASET ACTIVATE Chapter6 WINDOW=FRONT. ECHO 'Ch 6: 3b: Random Quadratic Time Model'. MIXED rt BY PersonID session WITH time1 /METHOD = REML /PRINT = SOLUTION TESTCOV G R /FIXED = time1 time1*time1 /RANDOM = INTERCEPT time1 time1*time1 | COVTYPE(UN) SUBJECT(PersonID) /REPEATED = session | COVTYPE(ID) SUBJECT(PersonID) /TEST = 'Intercept at Session=1 Time=0' intercept 1 time1 0 time1*time1 0 /TEST = 'Intercept at Session=2 Time=1' intercept 1 time1 1 time1*time1 1 /TEST = 'Intercept at Session=3 Time=2' intercept 1 time1 2 time1*time1 4 /TEST = 'Intercept at Session=4 Time=3' intercept 1 time1 3 time1*time1 9 /TEST = 'Intercept at Session=5 Time=4' intercept 1 time1 4 time1*time1 16 /TEST = 'Intercept at Session=6 Time=5' intercept 1 time1 5 time1*time1 25 /TEST = 'Linear Slope at Session=1 Time=0' time1 1 time1*time1 0 /TEST = 'Linear Slope at Session=2 Time=1' time1 1 time1*time1 2 /TEST = 'Linear Slope at Session=3 Time=2' time1 1 time1*time1 4 /TEST = 'Linear Slope at Session=4 Time=3' time1 1 time1*time1 6 /TEST = 'Linear Slope at Session=5 Time=4' time1 1 time1*time1 8 /TEST = 'Linear Slope at Session=6 Time=5' time1 1 time1*time1 10 . DATASET ACTIVATE Chapter6 WINDOW=FRONT. ECHO 'Ch 6: 3b: Random Quadratic Time Model (0=Session 6)'. MIXED rt BY PersonID session WITH time6 /METHOD = REML /PRINT = SOLUTION TESTCOV G R /FIXED = time6 time6*time6 /RANDOM = INTERCEPT time6 time6*time6 | COVTYPE(UN) SUBJECT(PersonID) /REPEATED = session | COVTYPE(ID) SUBJECT(PersonID) /TEST = 'Intercept at Session=1 Time=-5' intercept 1 time6 -5 time6*time6 25 /TEST = 'Intercept at Session=2 Time=-4' intercept 1 time6 -4 time6*time6 16 /TEST = 'Intercept at Session=3 Time=-3' intercept 1 time6 -3 time6*time6 9 /TEST = 'Intercept at Session=4 Time=-2' intercept 1 time6 -2 time6*time6 4 /TEST = 'Intercept at Session=5 Time=-1' intercept 1 time6 -1 time6*time6 1 /TEST = 'Intercept at Session=6 Time= 0' intercept 1 time6 0 time6*time6 0 /TEST = 'Linear Slope at Session=1 Time=-5' time6 1 time6*time6 -10 /TEST = 'Linear Slope at Session=2 Time=-4' time6 1 time6*time6 -8 /TEST = 'Linear Slope at Session=3 Time=-3' time6 1 time6*time6 -6 /TEST = 'Linear Slope at Session=4 Time=-2' time6 1 time6*time6 -4 /TEST = 'Linear Slope at Session=5 Time=-1' time6 1 time6*time6 -2 /TEST = 'Linear Slope at Session=6 Time= 0' time6 1 time6*time6 0 . DATASET ACTIVATE Chapter6 WINDOW=FRONT. ECHO 'Ch 6: 4a: Fixed Slope12, Fixed Slope26, Random Intercept Model'. MIXED rt BY PersonID session WITH slope12 slope26 /METHOD = REML /PRINT = SOLUTION TESTCOV G R /FIXED = slope12 slope26 /RANDOM = INTERCEPT | COVTYPE(UN) SUBJECT(PersonID) /REPEATED = session | COVTYPE(ID) SUBJECT(PersonID) /TEST = 'Intercept at Session=1 Time=0' intercept 1 slope12 0 slope26 0 /TEST = 'Intercept at Session=2 Time=1' intercept 1 slope12 1 slope26 0 /TEST = 'Intercept at Session=3 Time=2' intercept 1 slope12 1 slope26 1 /TEST = 'Intercept at Session=4 Time=3' intercept 1 slope12 1 slope26 2 /TEST = 'Intercept at Session=5 Time=4' intercept 1 slope12 1 slope26 3 /TEST = 'Intercept at Session=6 Time=5' intercept 1 slope12 1 slope26 4 /TEST = 'Difference between slope12 and slope26' slope12 -1 slope26 1 . DATASET ACTIVATE Chapter6 WINDOW=FRONT. ECHO 'Ch 6: 4b: Random Slope12, Fixed Slope26 Model'. MIXED rt BY PersonID session WITH slope12 slope26 /METHOD = REML /PRINT = SOLUTION TESTCOV G R /FIXED = slope12 slope26 /RANDOM = INTERCEPT slope12 | COVTYPE(UN) SUBJECT(PersonID) /REPEATED = session | COVTYPE(ID) SUBJECT(PersonID) /TEST = 'Intercept at Session=1 Time=0' intercept 1 slope12 0 slope26 0 /TEST = 'Intercept at Session=2 Time=1' intercept 1 slope12 1 slope26 0 /TEST = 'Intercept at Session=3 Time=2' intercept 1 slope12 1 slope26 1 /TEST = 'Intercept at Session=4 Time=3' intercept 1 slope12 1 slope26 2 /TEST = 'Intercept at Session=5 Time=4' intercept 1 slope12 1 slope26 3 /TEST = 'Intercept at Session=6 Time=5' intercept 1 slope12 1 slope26 4 /TEST = 'Difference between slope12 and slope26' slope12 -1 slope26 1 . DATASET ACTIVATE Chapter6 WINDOW=FRONT. ECHO 'Ch 6: 4c: Random Slope12, Random Slope26 Model'. MIXED rt BY PersonID session WITH slope12 slope26 /METHOD = REML /PRINT = SOLUTION TESTCOV G R /FIXED = slope12 slope26 /RANDOM = INTERCEPT slope12 slope26 | COVTYPE(UN) SUBJECT(PersonID) /REPEATED = session | COVTYPE(ID) SUBJECT(PersonID) /TEST = 'Intercept at Session=1 Time=0' intercept 1 slope12 0 slope26 0 /TEST = 'Intercept at Session=2 Time=1' intercept 1 slope12 1 slope26 0 /TEST = 'Intercept at Session=3 Time=2' intercept 1 slope12 1 slope26 1 /TEST = 'Intercept at Session=4 Time=3' intercept 1 slope12 1 slope26 2 /TEST = 'Intercept at Session=5 Time=4' intercept 1 slope12 1 slope26 3 /TEST = 'Intercept at Session=6 Time=5' intercept 1 slope12 1 slope26 4 /TEST = 'Difference between slope12 and slope26' slope12 -1 slope26 1 . DATASET ACTIVATE Chapter6 WINDOW=FRONT. ECHO 'Ch 6: Random Slope12, Random Slope26 Model + Fixed Quadratic Slope26'. MIXED rt BY PersonID session WITH slope12 slope26 /METHOD = REML /PRINT = SOLUTION TESTCOV G R /FIXED = slope12 slope26 slope26*slope26 /RANDOM = INTERCEPT slope12 slope26 | COVTYPE(UN) SUBJECT(PersonID) /REPEATED = session | COVTYPE(ID) SUBJECT(PersonID) . DATASET ACTIVATE Chapter6 WINDOW=FRONT. ECHO 'Ch 6: 5a: Fixed Time, Fixed Slope26, Random Intercept Model'. MIXED rt BY PersonID session WITH time1 slope26 /METHOD = REML /PRINT = SOLUTION TESTCOV G R /FIXED = time1 slope26 /RANDOM = INTERCEPT | COVTYPE(UN) SUBJECT(PersonID) /REPEATED = session | COVTYPE(ID) SUBJECT(PersonID) /TEST = 'Intercept at Session=1 Time=0' intercept 1 time1 0 slope26 0 /TEST = 'Intercept at Session=2 Time=1' intercept 1 time1 1 slope26 0 /TEST = 'Intercept at Session=3 Time=2' intercept 1 time1 2 slope26 1 /TEST = 'Intercept at Session=4 Time=3' intercept 1 time1 3 slope26 2 /TEST = 'Intercept at Session=5 Time=4' intercept 1 time1 4 slope26 3 /TEST = 'Intercept at Session=6 Time=5' intercept 1 time1 5 slope26 4 /TEST = 'Rate of change from session 2 to 6' time1 1 slope26 1 . DATASET ACTIVATE Chapter6 WINDOW=FRONT. ECHO 'Ch 6: 5b: Random Time, Fixed Slope26 Model'. MIXED rt BY PersonID session WITH time1 slope26 /METHOD = REML /PRINT = SOLUTION TESTCOV G R /FIXED = time1 slope26 /RANDOM = INTERCEPT time1 | COVTYPE(UN) SUBJECT(PersonID) /REPEATED = session | COVTYPE(ID) SUBJECT(PersonID) /TEST = 'Intercept at Session=1 Time=0' intercept 1 time1 0 slope26 0 /TEST = 'Intercept at Session=2 Time=1' intercept 1 time1 1 slope26 0 /TEST = 'Intercept at Session=3 Time=2' intercept 1 time1 2 slope26 1 /TEST = 'Intercept at Session=4 Time=3' intercept 1 time1 3 slope26 2 /TEST = 'Intercept at Session=5 Time=4' intercept 1 time1 4 slope26 3 /TEST = 'Intercept at Session=6 Time=5' intercept 1 time1 5 slope26 4 /TEST = 'Rate of change from session 2 to 6' time1 1 slope26 1 . DATASET ACTIVATE Chapter6 WINDOW=FRONT. ECHO 'Ch 6: 5c: Random Time, Random Slope26 Model'. MIXED rt BY PersonID session WITH time1 slope26 /METHOD = REML /PRINT = SOLUTION TESTCOV G R /FIXED = time1 slope26 /RANDOM = INTERCEPT time1 slope26 | COVTYPE(UN) SUBJECT(PersonID) /REPEATED = session | COVTYPE(ID) SUBJECT(PersonID) /TEST = 'Intercept at Session=1 Time=0' intercept 1 time1 0 slope26 0 /TEST = 'Intercept at Session=2 Time=1' intercept 1 time1 1 slope26 0 /TEST = 'Intercept at Session=3 Time=2' intercept 1 time1 2 slope26 1 /TEST = 'Intercept at Session=4 Time=3' intercept 1 time1 3 slope26 2 /TEST = 'Intercept at Session=5 Time=4' intercept 1 time1 4 slope26 3 /TEST = 'Intercept at Session=6 Time=5' intercept 1 time1 5 slope26 4 /TEST = 'Rate of change from session 2 to 6' time1 1 slope26 1 . DATASET ACTIVATE Chapter6 WINDOW=FRONT. ECHO 'Ch 6: 0: Saturated Means, Unstructured Variance Model;'. ECHO 'Using ML Instead of REML'. MIXED rt BY PersonID session /METHOD = ML /PRINT = SOLUTION TESTCOV /FIXED = session /REPEATED = session | COVTYPE(UN) SUBJECT(PersonID) . DATASET ACTIVATE Chapter6 WINDOW=FRONT. ECHO 'Ch 6: 1b: Empty Means, Random Intercept Model;'. ECHO 'Using ML Instead of REML'. MIXED rt BY PersonID session /METHOD = ML /PRINT = SOLUTION TESTCOV /FIXED = /RANDOM = INTERCEPT | COVTYPE(UN) SUBJECT(PersonID) /REPEATED = session | COVTYPE(ID) SUBJECT(PersonID) . DATASET ACTIVATE Chapter6 WINDOW=FRONT. ECHO 'Ch 6: 3b: Random Quadratic Time Model;'. ECHO 'Using ML instead of REML'. MIXED rt BY PersonID session WITH time1 /METHOD = ML /PRINT = SOLUTION TESTCOV /FIXED = time1 time1*time1 /RANDOM = INTERCEPT time1 time1*time1 | COVTYPE(UN) SUBJECT(PersonID) /REPEATED = session | COVTYPE(ID) SUBJECT(PersonID) . DATASET ACTIVATE Chapter6 WINDOW=FRONT. ECHO 'Ch 6: 4c: Random Slope12, Random Slope26 Model;'. ECHO 'Using ML instead of REML'. MIXED rt BY PersonID session WITH slope12 slope26 /METHOD = ML /PRINT = SOLUTION TESTCOV /FIXED = slope12 slope26 /RANDOM = INTERCEPT slope12 slope26 | COVTYPE(UN) SUBJECT(PersonID) /REPEATED = session | COVTYPE(ID) SUBJECT(PersonID) . ****** END CHAPTER 6 MODELS ******. * Close output directory. OUTPUT EXPORT NAME=SPSS_Chapter6_Output /CONTENTS EXPORT=VISIBLE LAYERS=VISIBLE MODELVIEWS=VISIBLE /HTML DOCUMENTFILE='C:\Dropbox\PilesOfVariance\Chapter6\SPSS\SPSS_Chapter6_Output.html' IMAGEFORMAT=PNG STYLING=YES.