TITLE:
  Ch 11a: Add All 3 Main Effects of Student Vicitimization Predicting Student Closeness
  Using Constant-Centered Level-1 and Level-2 Victim Predictors

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

VARIABLE:
  NAMES = ClassID grade size StudID girl SMclose SMvic CMclose CMvic CMg CMemo
          size23 grade35 CMg50 CMemo5 CMvic3 WCclose SMvic3 WCvic wave emo vic close
          time1 time2 w3 WSclose vic3 WSvic emo5 WCemo;
  USEVARIABLES = close time1 girl CMg50 CMemo5 vic3 SMvic3 CMvic3;
  MISSING = ALL (-9999);
  CLUSTER = ClassID StudID;
  WITHIN = time1 vic3;
  BETWEEN = (StudID) girl SMvic3 (ClassID) CMg50 CMemo5 CMvic3;

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

MODEL:

%WITHIN%
  close;
  lin | close ON time1;
  intL1v | close ON vic3;

%BETWEEN StudID%
  close lin intL1v@0;
  close WITH lin;
  close lin ON girl (bintL2g blinL2g);
  intL2v | close ON SMvic3;

%BETWEEN ClassID%
  [close lin intL1v intL2v] (int btime1 bintL1v bintL2v);
  close lin intL1v@0 intL2v@0;
  close WITH lin;
  close lin ON CMg50  (bintL3g blinL3g);
  close lin ON CMemo5 (bintL3e blinL3e);
  close     ON CMvic3 (bintL3v);

MODEL CONSTRAINT:
  NEW(est1-est5);
! est1: Level-1 Within-Student Victim Effect
  est1 = bintL1v;
! est2: Level-2 Within-Class   Victim Effect
  est2 = bintL1v + bintL2v;
! est3: Level-3 Between-Class  Victim Effect
  est3 = bintL1v + bintL2v + bintL3v;
! est4: Level-2 Within-Class  Contextual Victim Effect
  est4 = bintL2v;
! est5: Level-3 Between-Class Contextual Victim Effect
  est5 = bintL3v;