TITLE:
  Eq 7b.8: Fixed Quadratic, Random Linear Age Model

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

DEFINE:
  agesq = agec18*agec18;

VARIABLE:
  NAMES = PersonID att12 copymon18 occasion age risky monitor agec18 att4;
  USEVARIABLES = risky agec18 agesq;
  MISSING = ALL (-9999);
  CLUSTER = PersonID;
  WITHIN = agec18 agesq;

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

MODEL:

%WITHIN%
  risky;
  linear | risky ON agec18;
  quad | risky ON agesq;

%BETWEEN%
  [risky linear quad] (int bagec18 bagesq);
  risky linear quad@0;
  risky WITH linear;

MODEL CONSTRAINT:
  NEW(est1-est14);
! est1: Intercept at Age=12
  est1 = int*1 - bagec18*6 + bagesq*36;
! est2: Intercept at Age=13
  est2 = int*1 - bagec18*5 + bagesq*25;
! est3: Intercept at Age=14
  est3 = int*1 - bagec18*4 + bagesq*16;
! est4: Intercept at Age=15
  est4 = int*1 - bagec18*3 + bagesq*9;
! est5: Intercept at Age=16
  est5 = int*1 - bagec18*2 + bagesq*4;
! est6: Intercept at Age=17
  est6 = int*1 - bagec18*1 + bagesq*1;
! est7: Intercept at Age=18
  est7 = int*1 - bagec18*0 + bagesq*0;
! est8: Linear Slope at Age=12
  est8 = bagec18*1 - bagesq*12;
! est9: Linear Slope at Age=13
  est9 = bagec18*1 - bagesq*10;
! est10: Linear Slope at Age=14
  est10 = bagec18*1 - bagesq*8;
! est11: Linear Slope at Age=15
  est11 = bagec18*1 - bagesq*6;
! est12: Linear Slope at Age=16
  est12 = bagec18*1 - bagesq*4;
! est13: Linear Slope at Age=17
  est13 = bagec18*1 - bagesq*2;
! est14: Linear Slope at Age=18
  est14 = bagec18*1 - bagesq*0;