E. 2-1-1 model (MSEM)
TITLE: 2-1-1 mediation (MSEM)
DATA: FILE IS mydata.dat; ! text file containing raw data in long format
VARIABLE: NAMES ARE
group x m y;
USEVARIABLES ARE
group x m y;
BETWEEN IS x; ! identify variables with only Between variance;
! variables that are not claimed as "BETWEEN IS" or "WITHIN IS" can have
! both Within and Between variance
CLUSTER IS group; ! Level-2 grouping identifier
ANALYSIS: TYPE IS TWOLEVEL RANDOM;
MODEL: ! model specification follows
%WITHIN% ! Model for Within effects follows
m y; ! estimate Level-1 (residual) variances for m and y
y ON m; ! regress y on m
%BETWEEN% ! Model for Between effects follows
x m y; ! estimate Level-2 (residual) variances for x, m, and y
m ON x(a); ! regress m on x, call the slope "a"
y ON m(b); ! regress y on m, call the slope "b"
y ON x; ! regress y on x
MODEL CONSTRAINT: ! section for computing indirect effect
NEW(indb); ! name the indirect effect
indb=a*b; ! compute the Between indirect effect
OUTPUT: TECH1 TECH8 CINTERVAL; ! request parameter specifications, starting values,
! optimization history, and confidence intervals for all effects
F. 2-1-1 model with random slopes (MSEM)
TITLE: 2-1-1 mediation (MSEM)
DATA: FILE IS mydata.dat; ! text file containing raw data in long format
VARIABLE: NAMES ARE
group x m y;
USEVARIABLES ARE
group x m y;
BETWEEN IS x; ! identify variables with only Between variance;
! variables that are not claimed as "BETWEEN IS" or "WITHIN IS" can have
! both Within and Between variance
CLUSTER IS group; ! Level-2 grouping identifier
ANALYSIS: TYPE IS TWOLEVEL RANDOM;
MODEL: ! model specification follows
%WITHIN% ! Model for Within effects follows
m y; ! estimate Level-1 (residual) variances for m and y
sb | y ON m; ! regress y on m
%BETWEEN% ! Model for Between effects follows
x m y; ! estimate Level-2 (residual) variances for x, m, and y
m ON x(a); ! regress m on x, call the slope "a"
y ON m(bb); ! regress y on m, call the slope "bb"; bb = contextual effect, not the Between slope
y ON x; ! regress y on x
sb WITH x m y; ! estimate Level-2 covariances of sb with x, m, and y
[sb](bw); ! estimate the mean of sb, call it "bw"
MODEL CONSTRAINT: ! section for computing indirect effect
NEW(b indb); ! name the Between b path and the indirect effect
b=bb+bw; ! compute Between b path
indb=a*b; ! compute the Between indirect effect
OUTPUT: TECH1 TECH8 CINTERVAL; ! request parameter specifications, starting values,
! optimization history, and confidence intervals for all effects
|