SET PRINTBACK=NONE HEADER=NO.
FILE HANDLE filesave /NAME = "C:\Dropbox\PilesOfVariance\Chapter10a\SPSS".
GET FILE = "filesave/SPSS_Chapter10a.sav".
DATASET NAME Chapter10a WINDOW=FRONT.
SORT CASES BY PersonID.
DATASET DECLARE PersonMeans10a.
AGGREGATE
/OUTFILE="PersonMeans10a"
/PRESORTED
/BREAK = PersonID
/PMageT0 = MEAN(ageT0)
/PMytdeathT0 = MEAN(ytdeathT0).
DATASET ACTIVATE Chapter10a.
COMPUTE time = tvage-ageT0.
IF (occasion=9) occasion=8.
COMPUTE roundage = RND(tvage,1).
IF (roundage>95) roundage=95.
COMPUTE tvage84 = tvage-84.
COMPUTE ageT084 = ageT0-84.
COMPUTE roundytdeath = RND(tvytdeath,1).
IF (roundytdeath=-16) roundytdeath=-15.
COMPUTE tvytdeath7 = tvytdeath+7.
COMPUTE ytdeathT07 = ytdeathT0+7.
VARIABLE LABELS
time "time: Years since Time 0"
roundage "roundage: Age Rounded to Nearest Year"
tvage84 "tvage84: Time-Varying Age (0=84 years)"
ageT084 "ageT084: Age at Time 0 (0=84 years)"
roundytdeath "roundytdeath: Years to Death Rounded to Nearest Year"
tvytdeath7 "tvytdeath7: Time-Varying Years to Death (0=-7 years)"
ytdeathT07 "ytdeathT07: Years to Death at Time 0 (0=-7 years)".
SELECT IF NVALID(tvage, ageT0, ytdeathT0, tvytdeath, recall)=5.
EXECUTE.
DATA LIST FREE /
PersonID tvage tvage84 tvytdeath tvytdeath7 time.
BEGIN DATA.
-99 82 -2 -11 -4 0
-99 84 0 -9 -2 2
-99 86 2 -7 0 4
-99 88 4 -5 2 6
-99 90 6 -3 4 8
-99 92 8 -1 6 -99
-99 94 10 -99 -99 -99
END DATA.
MISSING VALUES tvytdeath tvytdeath7 time (-99).
DATASET NAME FakeUncTime.
ADD FILES FILE=Chapter10a /FILE=FakeUncTime.
DATASET NAME PlotUncTime.
SORT CASES BY PersonID.
DATASET CLOSE FakeUncTime.
DATA LIST FREE /
PersonID ageT084 tvage tvage84 ytdeathT07 tvytdeath tvytdeath7 time.
BEGIN DATA.
-99 -4 82 -2 -4 -11 -4 0
-99 -4 84 0 -4 -9 -2 2
-99 -4 86 2 -4 -7 0 4
-99 -4 88 4 -4 -5 2 6
-99 -4 90 6 -4 -3 4 8
-99 -4 92 8 -4 -1 6 -99
-99 -4 94 10 -99 -99 -99 -99
-99 0 82 -2 0 -11 -4 0
-99 0 84 0 0 -9 -2 2
-99 0 86 2 0 -7 0 4
-99 0 88 4 0 -5 2 6
-99 0 90 6 0 -3 4 8
-99 0 92 8 0 -1 6 -99
-99 0 94 10 -99 -99 -99 -99
-99 4 82 -2 4 -11 -4 0
-99 4 84 0 4 -9 -2 2
-99 4 86 2 4 -7 0 4
-99 4 88 4 4 -5 2 6
-99 4 90 6 4 -3 4 8
-99 4 92 8 4 -1 6 -99
-99 4 94 10 -99 -99 -99 -99
END DATA.
MISSING VALUES ytdeathT07 tvytdeath tvytdeath7 time (-99).
DATASET NAME FakeCondTime.
ADD FILES FILE=Chapter10a /FILE=FakeCondTime.
DATASET NAME PlotCondTime.
SORT CASES BY PersonID.
DATASET CLOSE FakeCondTime.
DATA LIST FREE /
PersonID ageT084 ytdeathT07 time.
BEGIN DATA.
-99 -4 -4 0
-99 -4 -4 2
-99 -4 -4 4
-99 -4 -4 6
-99 -4 -4 8
-99 -4 0 0
-99 -4 0 2
-99 -4 0 4
-99 -4 0 6
-99 -4 0 8
-99 0 -4 0
-99 0 -4 2
-99 0 -4 4
-99 0 -4 6
-99 0 -4 8
-99 0 0 0
-99 0 0 2
-99 0 0 4
-99 0 0 6
-99 0 0 8
-99 4 -4 0
-99 4 -4 2
-99 4 -4 4
-99 4 -4 6
-99 4 -4 8
-99 4 0 0
-99 4 0 2
-99 4 0 4
-99 4 0 6
-99 4 0 8
END DATA.
DATASET NAME FakeBothTime.
ADD FILES FILE=Chapter10a /FILE=FakeBothTime.
DATASET NAME PlotBothTime.
SORT CASES BY PersonID.
DATASET CLOSE FakeBothTime.
OUTPUT NAME SPSS_Chapter10a_Output.
DATASET ACTIVATE PersonMeans10a.
ECHO "Chapter 10a: Descriptive Statistics for Time-Invariant Variables".
SUMMARIZE
/TABLES = PMageT0 PMytdeathT0
/FORMAT = NOLIST TOTAL
/CELLS = COUNT MEAN STDDEV MIN MAX.
CORRELATIONS VARIABLES= PMageT0 PMytdeathT0.
DATASET CLOSE PersonMeans10a.
DATASET ACTIVATE Chapter10a.
ECHO "Chapter 10a: Descriptive Statistics for Time-Varying Variables".
SUMMARIZE
/TABLES = time tvage tvytdeath recall
/FORMAT = NOLIST TOTAL
/CELLS = COUNT MEAN STDDEV MIN MAX.
DATASET ACTIVATE Chapter10a WINDOW=FRONT.
ECHO 'Ch 10a: Empty Means, Random Intercept Model for Prose Recall'.
MIXED recall BY PersonID
/METHOD = ML
/PRINT = SOLUTION TESTCOV
/FIXED =
/RANDOM = INTERCEPT | COVTYPE(UN) SUBJECT(personid)
.
DATASET ACTIVATE Chapter10a WINDOW=FRONT.
ECHO 'Ch 10a: Saturated Means by Rounded Years in Study, Random Intercept Model for Prose Recall'.
MIXED recall BY PersonID occasion
/METHOD = ML
/PRINT = SOLUTION TESTCOV
/FIXED = occasion | NOINT
/RANDOM = INTERCEPT | COVTYPE(UN) SUBJECT(personid)
.
DATASET ACTIVATE Chapter10a WINDOW=FRONT.
ECHO 'Ch 10a: Saturated Means by Rounded Age, Random Intercept Model for Prose Recall'.
MIXED recall BY PersonID roundage
/METHOD = ML
/PRINT = SOLUTION TESTCOV
/FIXED = roundage | NOINT
/RANDOM = INTERCEPT | COVTYPE(UN) SUBJECT(personid)
.
DATASET ACTIVATE Chapter10a WINDOW=FRONT.
ECHO 'Ch 10a: Saturated Means by Rounded Years to Death, Random Intercept Model for Prose Recall'.
MIXED recall BY PersonID roundytdeath
/METHOD = ML
/PRINT = SOLUTION TESTCOV
/FIXED = roundytdeath | NOINT
/RANDOM = INTERCEPT | COVTYPE(UN) SUBJECT(personid)
.
DATASET ACTIVATE Chapter10a WINDOW=FRONT.
ECHO 'Ch 10a: Empty Means, Random Intercept Model for Years since Birth'.
MIXED tvage BY PersonID
/METHOD = ML
/PRINT = SOLUTION TESTCOV
/FIXED =
/RANDOM = INTERCEPT | COVTYPE(UN) SUBJECT(personid)
.
DATASET ACTIVATE Chapter10a WINDOW=FRONT.
ECHO 'Ch 10a: Empty Means, Random Intercept Model for Years to Death'.
MIXED tvytdeath BY PersonID
/METHOD = ML
/PRINT = SOLUTION TESTCOV
/FIXED =
/RANDOM = INTERCEPT | COVTYPE(UN) SUBJECT(personid)
.
DATASET ACTIVATE Chapter10a WINDOW=FRONT.
ECHO 'Ch 10a: Empty Means, Random Intercept Model for Years in Study'.
MIXED time BY PersonID
/METHOD = ML
/PRINT = SOLUTION TESTCOV
/FIXED =
/RANDOM = INTERCEPT | COVTYPE(UN) SUBJECT(personid)
.
DATASET ACTIVATE Chapter10a WINDOW=FRONT.
ECHO 'Ch 10a: Fixed Quadratic, Random Intercept Model using Years since Birth'.
MIXED recall BY PersonID WITH tvage84
/METHOD = ML
/PRINT = SOLUTION TESTCOV
/FIXED = tvage84 tvage84*tvage84
/RANDOM = INTERCEPT | COVTYPE(UN) SUBJECT(personid)
.
DATASET ACTIVATE Chapter10a WINDOW=FRONT.
ECHO 'Eq 10a.1: Random Linear Model using Years since Birth'.
MIXED recall BY PersonID WITH tvage84
/METHOD = ML
/PRINT = SOLUTION TESTCOV
/FIXED = tvage84
/RANDOM = INTERCEPT tvage84 | COVTYPE(UN) SUBJECT(personid)
.
DATASET ACTIVATE PlotUncTime WINDOW=FRONT.
ECHO 'Eq 10a.1: Fixed Quadratic, Random Linear Model using Years since Birth'.
MIXED recall BY PersonID WITH tvage84
/METHOD = ML
/PRINT = SOLUTION TESTCOV
/FIXED = tvage84 tvage84*tvage84
/RANDOM = INTERCEPT tvage84 | COVTYPE(UN) SUBJECT(personid)
/SAVE = FIXPRED(PredFQRLAge)
.
CORRELATIONS recall PredFQRLAge.
ECHO 'Predicted Outcomes for Fake People will be in PlotUncTime dataset'.
DATASET ACTIVATE Chapter10a WINDOW=FRONT.
ECHO 'Ch 10a: Fixed Quadratic, Random Intercept Model using Years to Death'.
MIXED recall BY PersonID WITH tvytdeath7
/METHOD = ML
/PRINT = SOLUTION TESTCOV
/FIXED = tvytdeath7 tvytdeath7*tvytdeath7
/RANDOM = INTERCEPT | COVTYPE(UN) SUBJECT(personid)
.
DATASET ACTIVATE PlotUncTime WINDOW=FRONT.
ECHO 'Eq 10a.1: Fixed Quadratic, Random Linear Model using Years to Death'.
MIXED recall BY PersonID WITH tvytdeath7
/METHOD = ML
/PRINT = SOLUTION TESTCOV
/FIXED = tvytdeath7 tvytdeath7*tvytdeath7
/RANDOM = INTERCEPT tvytdeath7 | COVTYPE(UN) SUBJECT(personid)
/SAVE = FIXPRED(PredFQRLYTD)
.
CORRELATIONS recall PredFQRLYTD.
ECHO 'Predicted Outcomes for Fake People will be in PlotUncTime dataset'.
DATASET ACTIVATE Chapter10a WINDOW=FRONT.
ECHO 'Ch 10a: Fixed Quadratic, Random Intercept Model using Years in Study'.
MIXED recall BY PersonID WITH time
/METHOD = ML
/PRINT = SOLUTION TESTCOV
/FIXED = time time*time
/RANDOM = INTERCEPT | COVTYPE(UN) SUBJECT(personid)
.
DATASET ACTIVATE PlotUncTime WINDOW=FRONT.
ECHO 'Eq 10a.1: Fixed Quadratic, Random Linear Model using Years in Study'.
MIXED recall BY PersonID WITH time
/METHOD = ML
/PRINT = SOLUTION TESTCOV
/FIXED = time time*time
/RANDOM = INTERCEPT time | COVTYPE(UN) SUBJECT(personid)
/SAVE = FIXPRED(PredFQRLYIS)
.
CORRELATIONS recall PredFQRLYIS.
ECHO 'Predicted Outcomes for Fake People will be in PlotUncTime dataset'.
DATASET ACTIVATE PlotCondTime WINDOW=FRONT.
ECHO 'Eq 10a.2: Fixed Quadratic, Random Linear Model using Years since Birth;'.
ECHO 'Controlling for Birth Cohort'.
MIXED recall BY PersonID WITH tvage84 ageT084
/METHOD = ML
/PRINT = SOLUTION TESTCOV
/FIXED = tvage84 tvage84*tvage84
ageT084 ageT084*ageT084 tvage84*ageT084
/RANDOM = INTERCEPT tvage84 | COVTYPE(UN) SUBJECT(personid)
/TEST = 'Multivariate Test of Birth Cohort Contextual Effects' ageT084 1; ageT084*ageT084 1; tvage84*ageT084 1
/TEST = 'Contextual Linear Birth Cohort on Intercept' ageT084 1
/TEST = 'Contextual Quadratic Birth Cohort on Intercept' ageT084*ageT084 1
/TEST = 'Contextual Linear Birth Cohort on Linear Slope' tvage84*ageT084 1
/TEST = 'Total Linear Birth Cohort on Intercept' ageT084 1 tvage84 1
/TEST = 'Total Quadratic Birth Cohort on Intercept' ageT084*ageT084 1 tvage84*ageT084 1 tvage84*tvage84 1
/TEST = 'Total Linear Birth Cohort on Linear Slope' tvage84*ageT084 1 tvage84*tvage84 2
/SAVE = FIXPRED(PredCohAge)
.
CORRELATIONS recall PredCohAge.
ECHO 'Predicted Outcomes for Fake People will be in PlotCondTime dataset'.
DATASET ACTIVATE PlotCondTime WINDOW=FRONT.
ECHO 'Eq 10a.2: Fixed Quadratic, Random Linear Model using Years in Study;'.
ECHO 'Controlling for Birth Cohort'.
MIXED recall BY PersonID WITH time ageT084
/METHOD = ML
/PRINT = SOLUTION TESTCOV
/FIXED = time time*time
ageT084 ageT084*ageT084 time*ageT084
/RANDOM = INTERCEPT time | COVTYPE(UN) SUBJECT(personid)
/TEST = 'Multivariate Test of Birth Cohort Total Effects' ageT084 1; ageT084*ageT084 1; time*ageT084 1
/TEST = 'Contextual Linear Birth Cohort on Intercept' ageT084 1 time -1
/TEST = 'Contextual Quadratic Birth Cohort on Intercept' ageT084*ageT084 1 time*ageT084 -1 time*time 1
/TEST = 'Contextual Linear Birth Cohort on Linear Slope' time*ageT084 1 time*time -2
/TEST = 'Total Linear Birth Cohort on Intercept' ageT084 1
/TEST = 'Total Quadratic Birth Cohort on Intercept' ageT084*ageT084 1
/TEST = 'Total Linear Birth Cohort on Linear Slope' time*ageT084 1
/SAVE = FIXPRED(PredCohAgeYIS)
.
CORRELATIONS recall PredCohAgeYIS.
ECHO 'Predicted Outcomes for Fake People will be in PlotCondTime dataset'.
DATASET ACTIVATE PlotCondTime WINDOW=FRONT.
ECHO 'Eq 10a.2: Fixed Quadratic, Random Linear Model using Years to Death;'.
ECHO 'Controlling for Death Cohort'.
MIXED recall BY PersonID WITH tvytdeath7 ytdeathT07
/METHOD = ML
/PRINT = SOLUTION TESTCOV
/FIXED = tvytdeath7 tvytdeath7*tvytdeath7
ytdeathT07 ytdeathT07*ytdeathT07 tvytdeath7*ytdeathT07
/RANDOM = INTERCEPT tvytdeath7 | COVTYPE(UN) SUBJECT(personid)
/TEST = 'Multivariate Test of Death Cohort Contextual Effects' ytdeathT07 1; ytdeathT07*ytdeathT07 1; tvytdeath7*ytdeathT07 1
/TEST = 'Contextual Linear Death Cohort on Intercept' ytdeathT07 1
/TEST = 'Contextual Quadratic Death Cohort on Intercept' ytdeathT07*ytdeathT07 1
/TEST = 'Contextual Linear Death Cohort on Linear Slope' tvytdeath7*ytdeathT07 1
/TEST = 'Total Linear Death Cohort on Intercept' ytdeathT07 1 tvytdeath7 1
/TEST = 'Total Quadratic Death Cohort on Intercept' ytdeathT07*ytdeathT07 1 tvytdeath7*ytdeathT07 1 tvytdeath7*tvytdeath7 1
/TEST = 'Total Linear Death Cohort on Linear Slope' tvytdeath7*ytdeathT07 1 tvytdeath7*tvytdeath7 2
/SAVE = FIXPRED(PredCohYTD)
.
CORRELATIONS recall PredCohYTD.
ECHO 'Predicted Outcomes for Fake People will be in PlotCondTime dataset'.
DATASET ACTIVATE PlotCondTime WINDOW=FRONT.
ECHO 'Eq 10a.2: Fixed Quadratic, Random Linear Model using Years in Study;'.
ECHO 'Controlling for Death Cohort'.
MIXED recall BY PersonID WITH time ytdeathT07
/METHOD = ML
/PRINT = SOLUTION TESTCOV
/FIXED = time time*time
ytdeathT07 ytdeathT07*ytdeathT07 time*ytdeathT07
/RANDOM = INTERCEPT time | COVTYPE(UN) SUBJECT(personid)
/TEST = 'Multivariate Test of Death Cohort Total Effects' ytdeathT07 1; ytdeathT07*ytdeathT07 1; time*ytdeathT07 1
/TEST = 'Contextual Linear Birth Cohort on Intercept' ytdeathT07 1 time -1
/TEST = 'Contextual Quadratic Birth Cohort on Intercept' ytdeathT07*ytdeathT07 1 time*ytdeathT07 -1 time*time 1
/TEST = 'Contextual Linear Birth Cohort on Linear Slope' time*ytdeathT07 1 time*time -2
/TEST = 'Total Linear Birth Cohort on Intercept' ytdeathT07 1
/TEST = 'Total Quadratic Birth Cohort on Intercept' ytdeathT07*ytdeathT07 1
/TEST = 'Total Linear Birth Cohort on Linear Slope' time*ytdeathT07 1
/SAVE = FIXPRED(PredCohYTDYIS)
.
CORRELATIONS recall PredCohYTDYIS.
ECHO 'Predicted Outcomes for Fake People will be in PlotCondTime dataset'.
DATASET ACTIVATE PlotBothTime WINDOW=FRONT.
ECHO 'Eq 10a.4: Fixed Quadratic, Random Linear Model using Years in Study;'.
ECHO 'Controlling for Birth Cohort and Death Cohort'.
MIXED recall BY PersonID WITH time ageT084 ytdeathT07
/METHOD = ML
/PRINT = SOLUTION TESTCOV
/FIXED = time time*time
ageT084 ageT084*ageT084 time*ageT084
ytdeathT07 ytdeathT07*ytdeathT07 time*ytdeathT07
/RANDOM = INTERCEPT time | COVTYPE(UN) SUBJECT(personid)
/SAVE = FIXPRED(PredBothYIS)
.
CORRELATIONS recall PredBothYIS.
ECHO 'Predicted Outcomes for Fake People will be in PlotBothTime dataset'.
OUTPUT EXPORT NAME=SPSS_Chapter10a_Output
/CONTENTS EXPORT=VISIBLE LAYERS=VISIBLE MODELVIEWS=VISIBLE
/HTML DOCUMENTFILE='C:\Dropbox\PilesOfVariance\Chapter10a\SPSS\SPSS_Chapter10a_Output.html'
IMAGEFORMAT=PNG STYLING=YES.