TITLE:
  Eq 8.13: Adding 5 Intra-Variable Interactions to the Model for the Means
  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;
  sexPMs = women*PMstr40;
  PMmsq = PMmood2*PMmood2;
  WPmsq = WPmood*WPmood;
  PMssq = PMstr40*PMstr40;

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

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

MODEL:

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

%BETWEEN%
  [symp L1mood L1str L1msq] (int bWPmood bstress bWPmsq);
  symp L1mood@0 L1str@0 L1msq@0;
  symp ON women age80 sexage (bwomen bage80 bsexage);
  symp ON PMmood2 PMstr40 (bPMmood2 bPMstr40);
  symp ON sexPMs PMmsq PMssq (bsexPMs bPMmsq bPMssq);
  L1mood ON PMmood2 (bL1mPMm);
  L1str ON women PMstr40 (bsexL1s bPMsL1s);

MODEL TEST:
  ! Multivariate Test of 5 Intra-Variable Interactions
  0=bPMmsq;
  0=bWPmsq;
  0=bL1mPMm;
  0=bPMssq;
  0=bPMsL1s;

MODEL CONSTRAINT:
  NEW(est1-est16);
! est1: BP Negative Mood: Linear
  est1 = bPMmood2*1;
! est2: BP Negative Mood: Quadratic
  est2 = bPMmsq*1;
! est3: Contextual Negative Mood: Linear
  est3 = bPMmood2*1 - bWPmood*1;
! est4: Contextual Negative Mood: Quadratic
  est4 = bPMmsq*1 - bL1mPMm*1 + bWPmsq*1;
! est5: WP Negative Mood: Linear
  est5 = bWPmood*1;
! est6: WP Negative Mood: Quadratic
  est6 = bWPmsq*1;
! est7: BP by WP Negative Mood
  est7 = bL1mPMm*1;
! est8: Contextual by WP Negative Mood
  est8 = bL1mPMm*1 - bWPmsq*2;
! est9: BP Stressor: Linear
  est9 = bPMstr40*1 + bstress*1;
! est10: BP Stressor: Quadratic
  est10 = bPMssq*1 + bPMsL1s*1;
! est11: Contextual Stressors: Linear
  est11 = bPMstr40*1;
! est12: Contextual Stressors: Quadratic
  est12 = bPMssq*1;
! est13: WP Stressors: Linear
  est13 = bstress*1;
! est14: BP/Contextual by WP Stressors
  est14 = bPMsL1s*1;
! est15: BP Negative Mood: Linear at 1
  est15 = bPMmood2*1 - bPMmsq*2;
! est16: BP Negative Mood: Linear at 3
  est16 = bPMmood2*1 + bPMmsq*2;