TITLE:
  Ch 9: Fixed Quadratic, Random Linear Age Model for Risky Behavior
  Conditional Baseline with Attitudes Predicting Linear Age Slope

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 agesq;
  MISSING = ALL (-9999);
  CLUSTER = PersonID;
  WITHIN = agec18 agesq;
  BETWEEN = att4;

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);