TITLE:
  Eq 11a.6: Add Time-Varying and Class Emotional Support
  Predicting Student Closeness

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

DEFINE:
  timTVemo = time1*emo5;

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 size23 girl CMg50 emo5 CMemo5 timTVemo;
  MISSING = ALL (-9999);
  CLUSTER = ClassID StudID;
  WITHIN = time1 emo5 timTVemo;
  BETWEEN = (StudID) girl (ClassID) size23 CMg50 CMemo5;

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

MODEL:

%WITHIN%
  close;
  lin | close ON time1;
  intL1e | close ON emo5;
  close ON timTVemo (blinL1e);

%BETWEEN StudID%
  close lin intL1e@0;
  close WITH lin;
  close lin ON girl (bintL2g blinL2g);

%BETWEEN ClassID%
  [close lin intL1e] (int btime1 bintL1e);
  close lin intL1e@0;
  close WITH lin;
  close lin ON size23 (bintsize blinsize);
  close lin ON CMg50  (bintL3g blinL3g);
  close lin ON CMemo5 (bintL3e blinL3e);