最近掏愁,工作上遇到需要進(jìn)行多水平中介模型(Multilevel Mediation Model)的分析需求,尤其是2(X)-2(M)-1(Y)這種跨水平中介模型亚情。
由于最近進(jìn)行數(shù)據(jù)分析的工具主要轉(zhuǎn)到R上命浴,所以装悲,花費(fèi)了些時(shí)間去找R語(yǔ)句分析2-2-1這種多水平中介模型厕倍,但目前依然沒(méi)有找到比較趁手的包(mlma
這個(gè)包的用法屬實(shí)還需要花些時(shí)間去理解)寡壮。
無(wú)奈,只能轉(zhuǎn)向n年沒(méi)有使用過(guò)的Mplus讹弯,好在Mplus方面的資源况既,尤其是關(guān)于復(fù)雜模型的語(yǔ)句還是不少,最后组民,用Mplus來(lái)解決問(wèn)題了坏挠。
現(xiàn)在分析個(gè)數(shù)據(jù),真的是恨不得把SPSS邪乍,stata,R对竣,Mplus都開(kāi)開(kāi)庇楞,心疼我可憐的小surface,有時(shí)候燙得感覺(jué)下一秒就要炸了……
話不多說(shuō)否纬,趁著干活中間吕晌,換換腦子,記錄下各種跨水平中介模型的Mplus語(yǔ)句吧临燃,畢竟之前自己也Bing了不少時(shí)間睛驳。方便以后檢索吧烙心。
本部分是:關(guān)于Y在level1的四種模型:
1-1-1
,1-2-1
乏沸,2-1-1
淫茵,2-2-1
① 1-1-1 model
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)
匙瘪,詳見(jiàn)文末資料來(lái)源。
② 1-2-1 model
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
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)
,詳見(jiàn)文末資料來(lái)源翁都。
④ 2-2-1 model
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-2
碍论,1-2-2
,1-1-2
柄慰,2-1-2
⑤ 2-2-2 model
這個(gè)鳍悠,其實(shí)就是最普通且最簡(jiǎn)單的中介分析了,我就不放了先煎,各種軟件都可以做贼涩。
⑥ 1-2-2 model
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
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
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è)資料的過(guò)程中占锯,我又找到了個(gè)各種復(fù)雜模型的Mplus語(yǔ)句大全:offbeat.group.shef.ac.uk/FIO/mplusmedmod.htm
網(wǎng)站內(nèi)容部分截圖: