TITLE:
  Eq 10b.10: Piecewise Session Slopes (Slope26 by Quadratic Burst Only)
  Add Random Linear Slope26 Across Bursts 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@0 lin quad@0;
  symptoms WITH lin;

MODEL CONSTRAINT:
  NEW(est1-est5);
! est1: Slope26 at Burst 1
  est1 = bslope26*1 + bLsdif26*0 + bQsdif26*0;
! est2: Slope26 at Burst 2
  est2 = bslope26*1 + bLsdif26*1 + bQsdif26*1;
! est3: Slope26 at Burst 3
  est3 = bslope26*1 + bLsdif26*2 + bQsdif26*4;
! est4: Slope26 at Burst 4
  est4 = bslope26*1 + bLsdif26*3 + bQsdif26*9;
! est5: Slope26 at Burst 5
  est5 = bslope26*1 + bLsdif26*4 + bQsdif26*16;