TITLE:
  Eq 10b.6: Saturated Means for Burst by Session
  Three-Level Model for the Variance for Positive Affect

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

DEFINE:
  ! Dummy code burst and session
  DO (1, 4) b#=0;
  DO (1, 4) IF burst==# THEN b#=1;
  DO (1, 5) s#=0;
  DO (1, 5) IF session==# THEN s#=1;

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

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

MODEL:

%WITHIN%
  posaff;
  sdif1 | posaff ON s1;
  sdif2 | posaff ON s2;
  sdif3 | posaff ON s3;
  sdif4 | posaff ON s4;
  sdif5 | posaff ON s5;

%BETWEEN burst%
  posaff sdif1-sdif5@0;
  bdif1 | posaff ON b1;
  bdif2 | posaff ON b2;
  bdif3 | posaff ON b3;
  bdif4 | posaff ON b4;
  sdif1-sdif5 ON b1 (b1sdif1-b1sdif5);
  sdif1-sdif5 ON b2 (b2sdif1-b2sdif5);
  sdif1-sdif5 ON b3 (b3sdif1-b3sdif5);
  sdif1-sdif5 ON b4 (b4sdif1-b4sdif5);

%BETWEEN PersonID%
  [posaff sdif1-sdif5 bdif1-bdif4] (int bsdif1-bsdif5 bbdif1-bbdif4);
  posaff sdif1-sdif5@0 bdif1-bdif4@0;

MODEL CONSTRAINT:
  NEW(est1-est30);
! est1: Burst1 Session 1 Mean
  est1 = int + bbdif1 + bsdif1 + b1sdif1;
! est2: Burst1 Session 2 Mean
  est2 = int + bbdif1 + bsdif2 + b1sdif2;
! est3: Burst1 Session 3 Mean
  est3 = int + bbdif1 + bsdif3 + b1sdif3;
! est4: Burst1 Session 4 Mean
  est4 = int + bbdif1 + bsdif4 + b1sdif4;
! est5: Burst1 Session 5 Mean
  est5 = int + bbdif1 + bsdif5 + b1sdif5;
! est6: Burst1 Session 6 Mean
  est6 = int + bbdif1;
! est7: Burst2 Session 1 Mean
  est7 = int + bbdif2 + bsdif1 + b2sdif1;
! est8: Burst2 Session 2 Mean
  est8 = int + bbdif2 + bsdif2 + b2sdif2;
! est9: Burst2 Session 3 Mean
  est9 = int + bbdif2 + bsdif3 + b2sdif3;
! est10: Burst2 Session 4 Mean
  est10 = int + bbdif2 + bsdif4 + b2sdif4;
! est11: Burst2 Session 5 Mean
  est11 = int + bbdif2 + bsdif5 + b2sdif5;
! est12: Burst2 Session 6 Mean
  est12 = int + bbdif2;
! est13: Burst3 Session 1 Mean
  est13 = int + bbdif3 + bsdif1 + b3sdif1;
! est14: Burst3 Session 2 Mean
  est14 = int + bbdif3 + bsdif2 + b3sdif2;
! est15: Burst3 Session 3 Mean
  est15 = int + bbdif3 + bsdif3 + b3sdif3;
! est16: Burst3 Session 4 Mean
  est16 = int + bbdif3 + bsdif4 + b3sdif4;
! est17: Burst3 Session 5 Mean
  est17 = int + bbdif3 + bsdif5 + b3sdif5;
! est18: Burst4 Session 6 Mean
  est18 = int + bbdif3;
! est19: Burst4 Session 1 Mean
  est19 = int + bbdif4 + bsdif1 + b4sdif1;
! est20: Burst4 Session 2 Mean
  est20 = int + bbdif4 + bsdif2 + b4sdif2;
! est21: Burst4 Session 3 Mean
  est21 = int + bbdif4 + bsdif3 + b4sdif3;
! est22: Burst4 Session 4 Mean
  est22 = int + bbdif4 + bsdif4 + b4sdif4;
! est23: Burst4 Session 5 Mean
  est23 = int + bbdif4 + bsdif5 + b4sdif5;
! est24: Burst4 Session 6 Mean
  est24 = int + bbdif4;
! est25: Burst5 Session 1 Mean
  est25 = int + bsdif1;
! est26: Burst5 Session 2 Mean
  est26 = int + bsdif2;
! est27: Burst5 Session 3 Mean
  est27 = int + bsdif3;
! est28: Burst5 Session 4 Mean
  est28 = int + bsdif4;
! est29: Burst5 Session 5 Mean
  est29 = int + bsdif5;
! est30: Burst5 Session 6 Mean
  est30 = int;