SET PRINTBACK=NONE HEADER=NO.
FILE HANDLE filesave /NAME = "C:\Dropbox\PilesOfVariance\Chapter7b\SPSS".
GET FILE = "filesave/SPSS_Chapter7b.sav".
DATASET NAME Chapter7bmultiv WINDOW=FRONT.
EXECUTE.
OUTPUT NAME SPSS_Chapter7b_Output.
DATASET ACTIVATE Chapter7bmultiv.
ECHO "Chapter 7b: Descriptive Statistics for Time-Invariant Variables".
SUMMARIZE
/TABLES = attitude12
/FORMAT = NOLIST TOTAL
/CELLS = COUNT MEAN STDDEV MIN MAX.
VARSTOCASES
/MAKE age FROM age12 TO age18
/MAKE risky FROM risky12 TO risky18
/MAKE monitor FROM monitor12 TO monitor18
/INDEX = wave (7)
/KEEP = ALL.
DATASET NAME Chapter7b WINDOW=FRONT.
COMPUTE occasion = wave + 11.
VARIABLE LABELS
wave "wave: Wave of Study (1-7)"
occasion "occasion: Occasion of Measurement (12-18)"
age "age: Exact Age at Occasion"
risky "risky: Risky Behavior at Occasion"
monitor "monitor: Monitoring at Occasion".
COMPUTE agec18 = age - 18.
COMPUTE att4 = attitude12 - 4.
VARIABLE LABELS
agec18 "agec18: Exact Age (0=18)"
att4 "att4: Age 12 Attitudes (0=4)".
SELECT IF NVALID(agec18, att4, risky, monitor)=4.
EXECUTE.
DATASET ACTIVATE Chapter7b.
ECHO "Chapter 7b: Descriptive Statistics for Time-Varying Variables".
SUMMARIZE
/TABLES = age risky
/FORMAT = NOLIST TOTAL
/CELLS = COUNT MEAN STDDEV MIN MAX.
DATA LIST FREE / PersonID agec18 att4.
BEGIN DATA.
-99 -6 -2
-99 -5 -2
-99 -4 -2
-99 -3 -2
-99 -2 -2
-99 -1 -2
-99 0 -2
-99 -6 1
-99 -5 1
-99 -4 1
-99 -3 1
-99 -2 1
-99 -1 1
-99 0 1
END DATA.
DATASET NAME FakeAgeAtt.
ADD FILES FILE=Chapter7b /FILE=FakeAgeAtt.
DATASET NAME PlotAgeAtt.
SORT CASES BY PersonID.
DATASET CLOSE FakeAgeAtt.
DATASET ACTIVATE Chapter7b WINDOW=FRONT.
ECHO 'Ch 7b: Empty Means, Random Intercept Model'.
MIXED risky BY PersonID
/METHOD = ML
/PRINT = SOLUTION TESTCOV
/FIXED =
/RANDOM = INTERCEPT | COVTYPE(UN) SUBJECT(PersonID)
.
DATASET ACTIVATE Chapter7b WINDOW=FRONT.
ECHO 'Ch 7b: Saturated Means by Rounded Occasion, Unstructured Variance Model'.
MIXED risky BY PersonID occasion
/METHOD = ML
/PRINT = SOLUTION TESTCOV R
/FIXED = occasion
/REPEATED = occasion | COVTYPE(UN) SUBJECT(PersonID)
/EMMEANS = TABLES(occasion) COMPARE(occasion)
.
DATASET ACTIVATE Chapter7b WINDOW=FRONT.
ECHO 'Ch 7b: Fixed Linear Age, Random Intercept Model'.
MIXED risky BY PersonID WITH agec18
/METHOD = ML
/PRINT = SOLUTION TESTCOV
/FIXED = agec18
/RANDOM = INTERCEPT | COVTYPE(UN) SUBJECT(PersonID)
/TEST = 'Intercept at Age=12' intercept 1 agec18 -6
/TEST = 'Intercept at Age=13' intercept 1 agec18 -5
/TEST = 'Intercept at Age=14' intercept 1 agec18 -4
/TEST = 'Intercept at Age=15' intercept 1 agec18 -3
/TEST = 'Intercept at Age=16' intercept 1 agec18 -2
/TEST = 'Intercept at Age=17' intercept 1 agec18 -1
/TEST = 'Intercept at Age=18' intercept 1 agec18 0
.
DATASET ACTIVATE Chapter7b WINDOW=FRONT.
ECHO 'Ch 7b: Random Linear Age Model'.
MIXED risky BY PersonID WITH agec18
/METHOD = ML
/PRINT = SOLUTION TESTCOV
/FIXED = agec18
/RANDOM = INTERCEPT agec18 | COVTYPE(UN) SUBJECT(PersonID)
/TEST = 'Intercept at Age=12' intercept 1 agec18 -6
/TEST = 'Intercept at Age=13' intercept 1 agec18 -5
/TEST = 'Intercept at Age=14' intercept 1 agec18 -4
/TEST = 'Intercept at Age=15' intercept 1 agec18 -3
/TEST = 'Intercept at Age=16' intercept 1 agec18 -2
/TEST = 'Intercept at Age=17' intercept 1 agec18 -1
/TEST = 'Intercept at Age=18' intercept 1 agec18 0
.
DATASET ACTIVATE Chapter7b WINDOW=FRONT.
ECHO 'Eq 7b.8: Fixed Quadratic, Random Linear Age Model'.
MIXED risky BY PersonID WITH agec18
/METHOD = ML
/PRINT = SOLUTION TESTCOV
/FIXED = agec18 agec18*agec18
/RANDOM = INTERCEPT agec18 | COVTYPE(UN) SUBJECT(PersonID)
/TEST = 'Intercept at Age=12' intercept 1 agec18 -6 agec18*agec18 36
/TEST = 'Intercept at Age=13' intercept 1 agec18 -5 agec18*agec18 25
/TEST = 'Intercept at Age=14' intercept 1 agec18 -4 agec18*agec18 16
/TEST = 'Intercept at Age=15' intercept 1 agec18 -3 agec18*agec18 9
/TEST = 'Intercept at Age=16' intercept 1 agec18 -2 agec18*agec18 4
/TEST = 'Intercept at Age=17' intercept 1 agec18 -1 agec18*agec18 1
/TEST = 'Intercept at Age=18' intercept 1 agec18 0 agec18*agec18 0
/TEST = 'Linear Slope at Age=12' agec18 1 agec18*agec18 -12
/TEST = 'Linear Slope at Age=13' agec18 1 agec18*agec18 -10
/TEST = 'Linear Slope at Age=14' agec18 1 agec18*agec18 -8
/TEST = 'Linear Slope at Age=15' agec18 1 agec18*agec18 -6
/TEST = 'Linear Slope at Age=16' agec18 1 agec18*agec18 -4
/TEST = 'Linear Slope at Age=17' agec18 1 agec18*agec18 -2
/TEST = 'Linear Slope at Age=18' agec18 1 agec18*agec18 0
/SAVE = FIXPRED(PredAge)
.
CORRELATIONS risky PredAge.
DATASET ACTIVATE Chapter7b WINDOW=FRONT.
ECHO 'Ch 7b: Random Quadratic Age Model'.
MIXED risky BY PersonID WITH agec18
/METHOD = ML
/PRINT = SOLUTION TESTCOV
/FIXED = agec18 agec18*agec18
/RANDOM = INTERCEPT agec18 agec18*agec18 | COVTYPE(UN) SUBJECT(PersonID)
/TEST = 'Intercept at Age=12' intercept 1 agec18 -6 agec18*agec18 36
/TEST = 'Intercept at Age=13' intercept 1 agec18 -5 agec18*agec18 25
/TEST = 'Intercept at Age=14' intercept 1 agec18 -4 agec18*agec18 16
/TEST = 'Intercept at Age=15' intercept 1 agec18 -3 agec18*agec18 9
/TEST = 'Intercept at Age=16' intercept 1 agec18 -2 agec18*agec18 4
/TEST = 'Intercept at Age=17' intercept 1 agec18 -1 agec18*agec18 1
/TEST = 'Intercept at Age=18' intercept 1 agec18 0 agec18*agec18 0
/TEST = 'Linear Slope at Age=12' agec18 1 agec18*agec18 -12
/TEST = 'Linear Slope at Age=13' agec18 1 agec18*agec18 -10
/TEST = 'Linear Slope at Age=14' agec18 1 agec18*agec18 -8
/TEST = 'Linear Slope at Age=15' agec18 1 agec18*agec18 -6
/TEST = 'Linear Slope at Age=16' agec18 1 agec18*agec18 -4
/TEST = 'Linear Slope at Age=17' agec18 1 agec18*agec18 -2
/TEST = 'Linear Slope at Age=18' agec18 1 agec18*agec18 0
.
DATASET ACTIVATE Chapter7b WINDOW=FRONT.
ECHO 'Ch 7b: Fixed Cubic, Random Linear Age Model'.
MIXED risky BY PersonID WITH agec18
/METHOD = ML
/PRINT = SOLUTION TESTCOV
/FIXED = agec18 agec18*agec18 agec18*agec18*agec18
/RANDOM = INTERCEPT agec18 | COVTYPE(UN) SUBJECT(PersonID)
.
DATASET ACTIVATE Chapter7b WINDOW=FRONT.
ECHO 'Ch 7b: Fixed Quadratic, Random Linear Age Model;'.
ECHO 'Attitudes Predicting Intercept'.
MIXED risky BY PersonID WITH agec18 att4
/METHOD = ML
/PRINT = SOLUTION TESTCOV
/FIXED = agec18 agec18*agec18
att4
/RANDOM = INTERCEPT agec18 | COVTYPE(UN) SUBJECT(PersonID)
/SAVE = FIXPRED(PredAttInt)
.
CORRELATIONS risky PredAttInt.
DATASET ACTIVATE PlotAgeAtt WINDOW=FRONT.
ECHO 'Ch 7b: Fixed Quadratic, Random Linear Age Model;'.
ECHO 'Attitudes Predicting Linear Age Slope'.
MIXED risky BY PersonID WITH agec18 att4
/METHOD = ML
/PRINT = SOLUTION TESTCOV
/FIXED = agec18 agec18*agec18
att4 agec18*att4
/RANDOM = INTERCEPT agec18 | COVTYPE(UN) SUBJECT(PersonID)
/SAVE = FIXPRED(PredAttLin)
.
CORRELATIONS risky PredAttLin.
ECHO 'Predicted Outcomes for Fake People will be in PlotAgeAtt dataset'.
DATASET ACTIVATE Chapter7b WINDOW=FRONT.
ECHO 'Eq 7b.9: Fixed Quadratic, Random Linear Age Model;'.
ECHO 'Attitudes Predicting Quadratic Age Slope'.
MIXED risky BY PersonID WITH agec18 att4
/METHOD = ML
/PRINT = SOLUTION TESTCOV
/FIXED = agec18 agec18*agec18
att4 agec18*att4 agec18*agec18*att4
/RANDOM = INTERCEPT agec18 | COVTYPE(UN) SUBJECT(PersonID)
/SAVE = FIXPRED(PredAttQuad)
.
CORRELATIONS risky PredAttQuad.
OUTPUT EXPORT NAME=SPSS_Chapter7b_Output
/CONTENTS EXPORT=VISIBLE LAYERS=VISIBLE MODELVIEWS=VISIBLE
/HTML DOCUMENTFILE='C:\Dropbox\PilesOfVariance\Chapter7b\SPSS\SPSS_Chapter7b_Output.html'
IMAGEFORMAT=PNG STYLING=YES.