TITLE:
  Eq 10b.8: Piecewise Session Slopes by Quadratic Burst
  Three-Level Model for the Variance 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@0 slope2@0;
  lin  | symptoms ON burst1;
  quad | symptoms ON b1sq;
  slope1 slope2 ON burst1 (bLsdif12 bLsdif26);
  slope1 slope2 ON b1sq   (bQsdif12 bQsdif26);

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

MODEL CONSTRAINT:
  NEW(est1-est10);
! est1: Slope12 at Burst 1
  est1 = bslope12*1 + bLsdif12*0 + bQsdif12*0;
! est2: Slope12 at Burst 2
  est2 = bslope12*1 + bLsdif12*1 + bQsdif12*1;
! est3: Slope12 at Burst 3
  est3 = bslope12*1 + bLsdif12*2 + bQsdif12*4;
! est4: Slope12 at Burst 4
  est4 = bslope12*1 + bLsdif12*3 + bQsdif12*9;
! est5: Slope12 at Burst 5
  est5 = bslope12*1 + bLsdif12*4 + bQsdif12*16;
! est6: Slope26 at Burst 1
  est6 = bslope26*1 + bLsdif26*0 + bQsdif26*0;
! est7: Slope26 at Burst 2
  est7 = bslope26*1 + bLsdif26*1 + bQsdif26*1;
! est8: Slope26 at Burst 3
  est8 = bslope26*1 + bLsdif26*2 + bQsdif26*4;
! est9: Slope26 at Burst 4
  est9 = bslope26*1 + bLsdif26*3 + bQsdif26*9;
! est10: Slope26 at Burst 5
  est10 = bslope26*1 + bLsdif26*4 + bQsdif26*16;