TITLE:
  Eq 10a.2: Fixed Quadratic, Random Linear Model using Years to Death
  Controlling for Death Cohort

DATA:
  ! Prior necessary data manipulation conducted using other programs
  FILE = MPLUS_Chapter10a.csv;
  FORMAT = FREE;

DEFINE:
  tvytdsq = tvytd7*tvytd7;
  ytdT0sq = ytdT07*ytdT07;

VARIABLE:
  NAMES = PersonID occasion ageT0 tvage ytdT0 tvytd recall time
          roundage tvage84 ageT084 roundytd tvytd7 ytdT07;
  USEVARIABLES = recall tvytd7 ytdT07 tvytdsq ytdT0sq;
  MISSING = ALL (-9999);
  CLUSTER = PersonID;
  WITHIN = tvytd7 tvytdsq;
  BETWEEN = ytdT07 ytdT0sq;

ANALYSIS:
  ESTIMATOR = ML;
  PROCESSORS = 4;
  TYPE = TWOLEVEL RANDOM;

MODEL:

%WITHIN%
  recall;
  linear | recall ON tvytd7;
  quad | recall ON tvytdsq;

%BETWEEN%
  [recall linear quad] (int btvytd7 btvytdsq);
  recall linear quad@0;
  recall WITH linear;
  recall ON ytdT07 ytdT0sq (bdint bdsqint);
  linear ON ytdT07 (bdlin);

MODEL TEST:
  ! Multivariate Test of Death Cohort Contextual Effects
  0=bdint;
  0=bdsqint;
  0=bdlin;

MODEL CONSTRAINT:
  NEW(est1-est6);
! est1: Contextual Linear Death Cohort on Intercept
  est1 = bdint*1;
! est2: Contextual Quadratic Death Cohort on Intercept
  est2 = bdsqint*1;
! est3: Contextual Linear Death Cohort on Linear Slope
  est3 = bdlin*1;
! est4: Total Linear Death Cohort on Intercept
  est4 = bdint*1 + btvytd7*1;
! est5: Total Quadratic Death Cohort on Intercept
  est5 = bdsqint*1 + bdlin*1 + btvytdsq*1;
! est6: Total Linear Death Cohort on Linear Slope
  est6 = bdlin*1 + btvytdsq*2;