两层次中介检验MPLUS代码

更新时间:2023-05-05 11:45:26 阅读: 评论:0

Mplus syntax files for single- and multilevel mediation models, to accompany: Preacher, K. J., Zyphur, M. J., & Zhang, Z. (2010). A general multilevel SEM framework for asssing multilevel mediation. Psychological Methods, 15, 209-233.
Preacher, K. J., Zhang, Z., & Zyphur, M. J. (2011). Alternative methods for asssing mediation in multilevel data: The advantages of multilevel SEM. Structural Equation Modeling, 18, 161-182.
Note: In models in which the Between and Within components of a 1→1 path are estimated parately and the Within component is random, the Between component is estimated as the contextual effect rather than as the Between slope in Mplus (e Mplus Ur's Guide, Ex.9.2). In Examples F and J this has been addresd by adding the Within slope to the contextual effect to yield the correct Between slope component before computing the indirect effect.
A. simple mediation
TITLE: simple mediation
DATA: FILE IS mydata.dat; ! text file containing raw data in long format
VARIABLE: NAMES ARE
x m y;
USEVARIABLES ARE
x m y;
ANALYSIS: BOOTSTRAP IS 5000; ! bootstrap is recommended for simple mediation MODEL: ! model specification follows
m ON x; ! regress mediator on independent variable
y ON x m; ! regress outcome on both mediator and independent variable
MODEL INDIRECT: ! request significance test for indirect effect of x on y via m
y IND m x; ! indirect effect of interest (ending in y and starting with x)
OUTPUT: CINTERVAL(BCBOOTSTRAP); ! request bias-corrected bootstrap ! confidence intervals
B. 2-2-1 model with latent variables (MSEM)
TITLE: 2-2-1 mediation (similar code ud in example 2)
DATA: FILE IS mydata.dat; ! text file containing raw data in long format
VARIABLE: NAMES ARE
group x1 x2 x3 m1 m2 m3 m4 m5 y1 y2 y3 y4 y5;
MISSING ARE *; ! missing data denoted "*" in mydata.dat
USEVARIABLES ARE
group x1 x2 x3 m1 m2 m3 m4 m5 y1 y2 y3 y4 y5;
BETWEEN ARE x1 x2 x3 m1 m2 m3 m4 m5; ! identify variables with only Between variance;                ! variables that are not claimed as "BETWEEN ARE" or "WITHIN ARE" can have
! both Within and Between variance
CLUSTER IS group; ! Level-2 grouping identifier
ANALYSIS: TYPE IS TWOLEVEL RANDOM; ! tell Mplus to perform multilevel modeling
MODEL: ! model specification follows
%WITHIN% ! Model for Within effects follows
yw BY y1 y2 y3 y4 y5; ! yw is a factor defined by y1, y2, y3, y4, and y5
%BETWEEN% ! Model for Between effects follows
mb BY m1 m2 m3 m4 m5; ! mb is a factor defined by m1, m2, m3, m4, and m5
xb BY x1 x2 x3; ! xb is a factor defined by x1, x2, and x3
yb BY y1 y2 y3 y4 y5; ! yb is a factor defined by y1, y2, y3, y4, and y5
mb ON xb(a); ! regress mb on xb, call the slope "a"
yb ON mb(b); ! regress yb on mb, call the slope "b"
yb ON xb; ! regress yb on xb, too
MODEL CONSTRAINT: ! ction for computing indirect effect
NEW(ab); ! name the indirect effect
ab = a*b; ! compute the indirect effect
OUTPUT: TECH1 TECH8 CINTERVAL; ! request parameter specifications, starting values, ! optimization history, and confidence intervals for all effects
C. 2-1-1 model (traditional MLM)
TITLE: 2-1-1 mediation (traditional MLM)
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(b); ! regress y on m, call the slope "b"
%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, constrain the slope equal to "b"
y ON x; ! regress y on x
MODEL CONSTRAINT: ! ction 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
D. 2-1-1 model (unconflated MLM)
TITLE: 2-1-1 mediation (unconflated MLM)
DATA: FILE IS mydata.dat; ! text file containing raw data in long format
VARIABLE: NAMES ARE
group x m y mmean;
USEVARIABLES ARE
group x m y mmean;
BETWEEN ARE x mmean; ! identify variables with only Between variance;
! variables that are not claimed as "BETWEEN ARE" or "WITHIN ARE" can have                ! both Within and Between variance
WITHIN ARE m; ! identify variables with only Within variance
CENTERING IS GROUPMEAN(m); ! group-mean center m
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
[m@0]; ! m was group-mean centered, so fix its mean to zero
%BETWEEN% ! Model for Between effects follows
y mmean; ! estimate Level-2 (residual) variances for y and mmean
mmean ON x(a); ! regress mmean on x, call the slope "a"
y ON mmean(b); ! regress y on mmean, call the slope "b"
y ON x; ! regress y on x
MODEL CONSTRAINT: ! ction 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
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: ! ction 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: ! ction 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
G. 1-1-1 model (traditional MLM)
TITLE: 1-1-1 mediation (traditional MLM)
DATA: FILE IS mydata.dat; ! text file containing raw data in long format
VARIABLE: NAMES ARE
id x m y;
USEVARIABLES ARE
id x m y;
CLUSTER IS id; ! Level-2 grouping identifier
ANALYSIS: TYPE IS TWOLEVEL RANDOM;
MODEL: ! model specification follows
%WITHIN% ! Model for Within effects follows
sa | m ON x; ! regress m on x, call the random slope "sa"
sb | y ON m; ! regress y on m, call the random slope "sb"
sc | y ON x; ! regress y on x, call the random slope "sc"
%BETWEEN% ! Model for Between effects follows
sa sb sc m y; ! estimate Level-2 (residual) variances for sa, sb, sc, m, and y
[sa](a); ! estimate the mean of sa, call it "a"
[sb](b); ! estimate the mean of sb, call it "b"
sa WITH sc m y; ! estimate Level-2 covariances of sa with sc, m, and y
sb WITH sc m y; ! estimate Level-2 covariances of sb with sc, m, and y
sc WITH m y; ! estimate Level-2 covariances of sc with m and y
y WITH m; ! estimate Level-2 covariance of y and m
sa WITH sb(cab); ! estimate Level-2 covariance of sa and sb, call it "cab"
MODEL CONSTRAINT: ! ction for computing indirect effect
NEW(ind); ! name the indirect effect
ind=a*b+cab; ! compute the indirect effect
OUTPUT: TECH1 TECH8 CINTERVAL; ! request parameter specifications, starting values, ! optimization history, and confidence intervals for all effects
H. 1-1-1 model (unconflated MLM)
TITLE: 1-1-1 mediation (unconflated MLM)
DATA: FILE IS mydata.dat; ! text file containing raw data in long format
VARIABLE: NAMES ARE id x m y xmean mmean ymean;
USEVARIABLES ARE id x m y xmean mmean;
CENTERING IS GROUPMEAN(x m); ! group-mean center x and m
CLUSTER IS id; ! Level-2 grouping identifier
WITHIN ARE x m; ! identify variables with only Within variance;
! variables that are not claimed as "BETWEEN ARE" or "WITHIN ARE" can have                ! both Within and Between variance
BETWEEN ARE xmean mmean; ! identify variables with only Between variance ANALYSIS: TYPE IS TWOLEVEL RANDOM;
MODEL: ! model specification follows
%WITHIN% ! Model for Within effects follows
m ON x(aw); ! regress m on x, call the slope "aw"

本文发布于:2023-05-05 11:45:26,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/82/531709.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图