TITLE:
  Ch 8: Adding Random WP Effect of Stressors to the Model for the Variance
  Using Person-Mean-Centering for Negative Mood, Grand-Mean-Centering for Stressors

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 stress PMstr40 sexage;
  MISSING = ALL (-9999);
  CLUSTER = PersonID;
  WITHIN = WPmood stress;
  BETWEEN = women age80 PMmood2 PMstr40 sexage;

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

MODEL:

%WITHIN%
  symp;
  L1mood | symp ON WPmood;
  L1str | symp ON stress;

%BETWEEN%
  [symp L1mood L1str] (int bWPmood bstress);
  symp L1mood@0 L1str;
  symp WITH L1str;
  symp ON women age80 sexage (bwomen bage80 bsexage);
  symp ON PMmood2 PMstr40 (bPMmood2 bPMstr40);