TITLE:
  Ch 10b: Piecewise Session Slopes (Slope26 by Quadratic Burst Only)
  Add Random Linear Slope26 Across Persons for Symptoms

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 = symptoms slope12 slope26 burst1 b1sq;
  MISSING = ALL (-9999);
  CLUSTER = PersonID burst;
  WITHIN = slope12 slope26;
  BETWEEN = (burst) burst1 b1sq;

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

MODEL:

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

%BETWEEN burst%
  symptoms slope1 slope2;
  symptoms slope1 slope2 WITH symptoms slope1 slope2;
  lin  | symptoms ON burst1;
  quad | symptoms ON b1sq;
  slope2 ON burst1 b1sq (bLsdif26 bQsdif26);

%BETWEEN PersonID%
  [symptoms slope1 slope2 lin quad] (int bslope12 bslope26 blin bquad);
  symptoms slope1@0 slope2 lin quad@0;
  symptoms lin slope2 WITH symptoms lin slope2;