TITLE:
  Ch 6: Random Slope12, Random Slope26 Model + Fixed Quadratic Slope26

DATA:
  FILE = MPLUS_Chapter6.csv;
  FORMAT = FREE;

DEFINE:
  ! Rescale rt so Mplus will show all results
  rt = rt/10;
  slope12=0; slope26=0;
  IF session GE 2 THEN slope12=1;
  IF session GE 2 THEN slope26=session-2;
  slope26sq=slope26*slope26;

VARIABLE:
  NAMES = PersonID session rt;
  USEVARIABLES = rt slope12 slope26 slope26sq;
  MISSING = ALL (-9999);
  CLUSTER = PersonID;
  WITHIN = slope12 slope26 slope26sq;

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

MODEL:

%WITHIN%
  rt;
  slope1 | rt ON slope12;
  slope2 | rt ON slope26;
  slope2sq | rt ON slope26sq;

%BETWEEN%
  [rt slope1 slope2 slope2sq];
  rt slope1 slope2 slope2sq@0;
  rt slope1 slope2 WITH rt slope1 slope2;