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

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

DEFINE:
  b1sq = burst1*burst1;

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

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

MODEL:

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

%BETWEEN burst%
  posaff slope1@0 slope2@0;
  lin  | posaff ON burst1;
  quad | posaff ON b1sq;
  mb12 | posaff ON b1or2;
  slope1 ON b1or2 (b12sd12);

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