TITLE:
  Eq 9.1: Predicting Quadratic Change in Risky Behavior
  From Monitoring at Age 18 as Between-Person Monitoring

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

DEFINE:
  agesq = agec18*agec18;

VARIABLE:
  NAMES = PersonID att12 PMmon copymon18 occasion age risky monitor agec18 att4
          mon3 PMmon3 WPmon A18mon3 Ch18mon;
  USEVARIABLES = risky att4 agec18 A18mon3 agesq;
  MISSING = ALL (-9999);
  CLUSTER = PersonID;
  WITHIN = agec18 agesq;
  BETWEEN = att4 A18mon3;

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;
  risky linear ON att4 (battint battlin);
  risky linear quad ON A18mon3 (b18int b18lin b18quad);

MODEL CONSTRAINT:
  NEW(est1-est4);
! est1: Effect of Age 18 Monitoring at Age 12
  est1 = b18int*1 - b18lin*6 + b18quad*36;
! est2: Effect of Age 18 Monitoring at Age 14
  est2 = b18int*1 - b18lin*4 + b18quad*16;
! est3: Effect of Age 18 Monitoring at Age 16
  est3 = b18int*1 - b18lin*2 + b18quad*4;
! est4: Effect of Age 18 Monitoring at Age 18
  est4 = b18int*1 + b18lin*0 + b18quad*0;