TITLE:
  Ch 10b: Piecewise Session Slopes, Linear Burst, Slope12 by Burst1or2
  Add Random Linear Slope26 across Bursts 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;
  posaff slope1 slope2 WITH posaff slope1 slope2;
  lin  | posaff ON burst1;
  mb12 | posaff ON b1or2;
  slope1 ON b1or2 (b12sd12);

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