【Mplus語句】多水平中介模型

最近,工作上遇到需要進(jìn)行多水平中介模型(Multilevel Mediation Model)的分析需求,尤其是2(X)-2(M)-1(Y)這種跨水平中介模型。

由于最近進(jìn)行數(shù)據(jù)分析的工具主要轉(zhuǎn)到R上,所以,花費(fèi)了些時(shí)間去找R語句分析2-2-1這種多水平中介模型,但目前依然沒有找到比較趁手的包(mlma這個(gè)包的用法屬實(shí)還需要花些時(shí)間去理解)。

無奈,只能轉(zhuǎn)向n年沒有使用過的Mplus,好在Mplus方面的資源,尤其是關(guān)于復(fù)雜模型的語句還是不少,最后,用Mplus來解決問題了。

現(xiàn)在分析個(gè)數(shù)據(jù),真的是恨不得把SPSS,stata,R,Mplus都開開,心疼我可憐的小surface,有時(shí)候燙得感覺下一秒就要炸了……

話不多說,趁著干活中間,換換腦子,記錄下各種跨水平中介模型的Mplus語句吧,畢竟之前自己也Bing了不少時(shí)間。方便以后檢索吧。


本部分是:關(guān)于Y在level1的四種模型:1-1-11-2-1,2-1-12-2-1

① 1-1-1 model

1-1-1.png
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: ! section 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

還有1-1-1 model (unconflated MLM),1-1-1 model with fixed slopes (MSEM),1-1-1 model with random slopes (MSEM),詳見文末資料來源。

② 1-2-1 model

1-2-1.png
TITLE: 1-2-1 mediation (MSEM)
DATA: FILE IS mydata.dat; ! text file containing raw data in long format
VARIABLE: NAMES ARE id x m y;
USEVARIABLES ARE id x y m;
CLUSTER IS id; ! Level-2 grouping identifier
BETWEEN ARE m; ! identify variables with only Between variance;
! variables that are not claimed as "BETWEEN ARE" or "WITHIN ARE" can have
! both Within and Between variance
ANALYSIS: TYPE IS TWOLEVEL RANDOM;
MODEL: ! model specification follows
%WITHIN% ! Model for Within effects follows
y ON x; ! regress y on x
%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

③ 2-1-1 model

2-1-1.png
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: ! 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

還有2-1-1 mediation (unconflated MLM),2-1-1 mediation (MSEM)2-1-1 mediation (MSEM),詳見文末資料來源。

④ 2-2-1 model

2-2-1.png
TITLE: 2-2-1 mediation with latent variables (MSEM)
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: ! section 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

本部分是:關(guān)于Y在level2的四種模型:2-2-21-2-2,1-1-2,2-1-2

⑤ 2-2-2 model

2-2-2.png

這個(gè),其實(shí)就是最普通且最簡(jiǎn)單的中介分析了,我就不放了,各種軟件都可以做。

⑥ 1-2-2 model

1-2-2.png
TITLE: 1-2-2 mediation (MSEM)
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
BETWEEN ARE m y; ! identify variables with only Between variance;
! variables that are not claimed as "BETWEEN ARE" or "WITHIN ARE" can have
! both Within and Between variance
ANALYSIS: TYPE IS TWOLEVEL RANDOM;
MODEL: ! model specification follows
%WITHIN% ! Model for Within effects follows
x; ! estimate Level-1 (residual) variance for x
%BETWEEN% ! Model for Between effects follows
m y; ! estimate Level-2 (residual) variances for 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

⑦ 1-1-2 model

1-1-2.png
TITLE: 1-1-2 mediation (similar code used in example 3)
DATA: FILE IS mydata.dat; ! text file containing raw data in long format
VARIABLE: NAMES ARE
group x1 x2 x3 x4 m1 m2 m3 y1 y2 y3 y4 y5;
MISSING ARE *; ! missing data denoted "*" in mydata.dat
USEVARIABLES ARE
group x1 x2 x3 x4 m1 m2 m3 y1 y2 y3 y4 y5;
BETWEEN ARE y1 y2 y3 y4 y5; ! 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;
MODEL: ! model specification follows
%WITHIN% ! Model for Within effects follows
mw BY m1 m2 m3; ! mw is a factor defined by m1, m2, and m3
xw BY x1 x2 x3 x4; ! xw is a factor defined by x1, x2, x3, and x4
mw ON xw; ! regress mw on xw
%BETWEEN% ! Model for Between effects follows
mb BY m1 m2 m3; ! mb is a factor defined by m1, m2, and m3
xb BY x1 x2 x3 x4; ! xb is a factor defined by x1, x2, x3, and x4
yb BY y1 y2 y3 y4 y5; ! yb is a factor defined by y1, y2, y3, y4, and y5
yb ON mb(b); ! regress yb on mb, call the slope "b"
yb ON xb; ! regress yb on xb
mb ON xb(a); ! regress mb on xb, call the slope "a"
MODEL CONSTRAINT: ! section for computing indirect effect
NEW(ab); ! name the indirect effect
ab = a*b; ! compute the Between indirect effect
OUTPUT: TECH1 TECH8 CINTERVAL; ! request parameter specifications, starting values,
! optimization history, and confidence intervals for all effects

⑧ 2-1-2 model

2-1-2.png
TITLE: 2-1-2 mediation (MSEM)
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
BETWEEN ARE x y; ! identify variables with only Between variance;
! variables that are not claimed as "BETWEEN ARE" or "WITHIN ARE" can have
! both Within and Between variance
ANALYSIS: TYPE IS TWOLEVEL RANDOM;
MODEL: ! model specification follows
%WITHIN% ! Model for Within effects follows
m; ! estimate Level-1 (residual) variance for m
%BETWEEN% ! Model for Between effects follows
x y; ! estimate Level-2 (residual) variances for x 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

這些其實(shí)已有研究者總結(jié)了,關(guān)鍵詞檢索:Mplus syntax files for single- and multilevel mediation models,就能找到。

另外,在搜這個(gè)資料的過程中,我又找到了個(gè)各種復(fù)雜模型的Mplus語句大全:offbeat.group.shef.ac.uk/FIO/mplusmedmod.htm

網(wǎng)站內(nèi)容部分截圖:

Mplus1.png
Mplus2.png
Mplus3.png
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容