TITLE:
  Eq 9.1: Predicting Quadratic Change in Risky Behavior
  From Person Mean Monitoring 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 PMmon3 agesq;
  MISSING = ALL (-9999);
  CLUSTER = PersonID;
  WITHIN = agec18 agesq;
  BETWEEN = att4 PMmon3;

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 PMmon3 (bPMint bPMlin bPMquad);

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