TITLE: this is an example of a two-level
regression analysis for a continuous
dependent variable with a random slope and an observed covariate
DATA: FILE = ex9.2a.dat;
VARIABLE: NAMES = y x w xm clus;
WITHIN = x;
BETWEEN = w xm;
CLUSTER = clus;
DEFINE: CENTER x (GRANDMEAN);
ANALYSIS: TYPE = TWOLEVEL RANDOM;
MODEL: %WITHIN%
s | y ON x;
%BETWEEN%
y ON w xm;
[s] (gam0);
s ON w (gam1)
xm;
y WITH s;
MODEL CONSTRAINT:
PLOT(ylow yhigh); ! moderation by w=-1 and +1 for xm=0
LOOP(level1,-3,3,0.01); ! level1 represents variation in x
ylow = (gam0+gam1*(-1))*level1;
yhigh = (gam0+gam1*1)*level1;
PLOT: TYPE = PLOT2;