TITLE:
  Eq 8.9: Adding a Random Effect of Negative Mood to the Model for the Variance
  Using Person-Mean-Centering for Negative Mood

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

DEFINE:
  sexage = women*age80;

VARIABLE:
  NAMES = PersonID women baseage session studyday dayweek weekend symp mood stress
          PMmood PMstr age80 mood2 WPmood PMmood2 WPstr PMstr40;
  USEVARIABLES = symp women age80 PMmood2 WPmood sexage;
  MISSING = ALL (-9999);
  CLUSTER = PersonID;
  WITHIN = WPmood;
  BETWEEN = women age80 PMmood2 sexage;

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

MODEL:

%WITHIN%
  symp;
  L1mood | symp ON WPmood;

%BETWEEN%
  [symp L1mood] (int bWPmood);
  symp L1mood;
  symp WITH L1mood;
  symp ON women age80 sexage (bwomen bage80 bsexage);
  symp ON PMmood2 (bPMmood2);