【Mplus語(yǔ)句】多水平中介模型

最近掏愁,工作上遇到需要進(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-11-2-1乏沸,2-1-1淫茵,2-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)匙瘪,詳見(jiàn)文末資料來(lái)源。

② 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),詳見(jiàn)文末資料來(lái)源翁都。

④ 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-2碍论,1-2-21-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è)資料的過(guò)程中占锯,我又找到了個(gè)各種復(fù)雜模型的Mplus語(yǔ)句大全: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)系作者
  • 序言:七十年代末组去,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子导帝,更是在濱河造成了極大的恐慌章钾,老刑警劉巖,帶你破解...
    沈念sama閱讀 216,372評(píng)論 6 498
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件艺演,死亡現(xiàn)場(chǎng)離奇詭異却紧,居然都是意外死亡,警方通過(guò)查閱死者的電腦和手機(jī)胎撤,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,368評(píng)論 3 392
  • 文/潘曉璐 我一進(jìn)店門晓殊,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)伤提,“玉大人肿男,你說(shuō)我怎么就攤上這事。” “怎么了舌镶?”我有些...
    開(kāi)封第一講書(shū)人閱讀 162,415評(píng)論 0 353
  • 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)否灾。 經(jīng)常有香客問(wèn)我,道長(zhǎng)挎狸,這世上最難降的妖魔是什么崭别? 我笑而不...
    開(kāi)封第一講書(shū)人閱讀 58,157評(píng)論 1 292
  • 正文 為了忘掉前任,我火速辦了婚禮诀姚,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘瑞佩。我一直安慰自己,他們只是感情好稠炬,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,171評(píng)論 6 388
  • 文/花漫 我一把揭開(kāi)白布。 她就那樣靜靜地躺著毅桃,像睡著了一般钥飞。 火紅的嫁衣襯著肌膚如雪读宙。 梳的紋絲不亂的頭發(fā)上结闸,一...
    開(kāi)封第一講書(shū)人閱讀 51,125評(píng)論 1 297
  • 那天,我揣著相機(jī)與錄音结耀,去河邊找鬼饼记。 笑死具则,一個(gè)胖子當(dāng)著我的面吹牛博肋,可吹牛的內(nèi)容都是我干的匪凡。 我是一名探鬼主播病游,決...
    沈念sama閱讀 40,028評(píng)論 3 417
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼买猖,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼玉控!你這毒婦竟也來(lái)了?” 一聲冷哼從身側(cè)響起虱而,我...
    開(kāi)封第一講書(shū)人閱讀 38,887評(píng)論 0 274
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎罢杉,沒(méi)想到半個(gè)月后,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體贡歧,經(jīng)...
    沈念sama閱讀 45,310評(píng)論 1 310
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡滩租,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,533評(píng)論 2 332
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了利朵。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片律想。...
    茶點(diǎn)故事閱讀 39,690評(píng)論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖绍弟,靈堂內(nèi)的尸體忽然破棺而出技即,到底是詐尸還是另有隱情,我是刑警寧澤樟遣,帶...
    沈念sama閱讀 35,411評(píng)論 5 343
  • 正文 年R本政府宣布而叼,位于F島的核電站,受9級(jí)特大地震影響豹悬,放射性物質(zhì)發(fā)生泄漏葵陵。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,004評(píng)論 3 325
  • 文/蒙蒙 一瞻佛、第九天 我趴在偏房一處隱蔽的房頂上張望脱篙。 院中可真熱鬧,春花似錦、人聲如沸涡尘。這莊子的主人今日做“春日...
    開(kāi)封第一講書(shū)人閱讀 31,659評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)考抄。三九已至,卻和暖如春蔗彤,著一層夾襖步出監(jiān)牢的瞬間川梅,已是汗流浹背。 一陣腳步聲響...
    開(kāi)封第一講書(shū)人閱讀 32,812評(píng)論 1 268
  • 我被黑心中介騙來(lái)泰國(guó)打工然遏, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留贫途,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 47,693評(píng)論 2 368
  • 正文 我出身青樓待侵,卻偏偏與公主長(zhǎng)得像丢早,于是被迫代替她去往敵國(guó)和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子秧倾,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,577評(píng)論 2 353