TITLE:
  Ch 10b: Piecewise Session Slopes, Linear Burst, Slope12 by Burst1or2
  Add Random Slope12*b1or2 across Persons for Positive Affect

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

VARIABLE:
  NAMES = PersonID burst session symptoms posaff slope12 slope26 burst1 b1or2;
  USEVARIABLES = posaff slope12 slope26 burst1 b1or2;
  MISSING = ALL (-9999);
  CLUSTER = PersonID burst;
  WITHIN = slope12 slope26;
  BETWEEN = (burst) burst1 b1or2;

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

MODEL:

%WITHIN%
  posaff;
  slope1 | posaff ON slope12;
  slope2 | posaff ON slope26;

%BETWEEN burst%
  posaff slope1 slope2@0;
  posaff WITH slope1;
  lin  | posaff ON burst1;
  mb12 | posaff ON b1or2;
  b12sd12 | slope1 ON b1or2;

%BETWEEN PersonID%
  [posaff slope1 slope2 lin mb12@0 b12sd12] (int bslope12 bslope26 blin bmb12 bb12sd12);
  posaff slope1 slope2@0 lin mb12@0 b12sd12;
  posaff lin slope1 b12sd12 WITH posaff lin slope1 b12sd12;