TITLE:
  Ch 11a: Add Level-2 and Level-3 Gender by Within-Student Victim Cross-Level Interactions
  Predicting Student Closeness

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

DEFINE:
  CMgCMe = CMg50*CMemo5;
  CMeCMv = CMemo5*CMvic3;
  girlWCv = girl*WCvic;

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 WSvic WCvic CMvic3 CMgCMe CMeCMv girlWCv;
  MISSING = ALL (-9999);
  CLUSTER = ClassID StudID;
  WITHIN = time1 WSvic;
  BETWEEN = (StudID) girl WCvic girlWCv (ClassID) CMg50 CMemo5 CMvic3 CMgCMe CMeCMv;

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

MODEL:

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

%BETWEEN StudID%
  close lin intL1v;
  close lin intL1v WITH close lin intL1v;
  close lin intL1v ON girl (bintL2g blinL2g biL1vL2g);
  intL2v | close ON WCvic;
  close ON girlWCv (biL2gL2v);
  intL1v ON WCvic  (biL1vL2v);

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