萜妹之前遇见了一个神仙网站,觉得非常有用,所以就想推荐给小可爱们呀~


网页介绍

这个网站是萜妹在看文章的时候在参考文献部分偶然发现的,说明网站还是很靠谱的,小可爱们如果需要在文章中引用可采用以下格式:

Stride C.B., Gardner S., Catley. N. & Thomas, F.(2015) ‘Mplus code for mediation, moderation, and moderated mediation models’, http://www.offbeat.group.shef.ac.uk/FIO/mplusmedmod.htm

这些语句主要是针对PROCESS中的模型,当然研究者做了一定的修改,使得语句更加完善。

由于是针对PROCESS模型,所以PROCESS不能处理多层数据,这里的语句也不可,想要处理多层的可以看Kris Preacher的网站。(原网站中有此链接)

最后,网站里的PROCESS各个模型的对应语句都有,萜妹这里就只对常用模型语句进行了搬运,如果没有小可爱们需要的,小可爱们可以去原网站查。(选择阅读原文可跳转至原网站)

模型与语句

下文语句中红字部分为可替换部分,另外数据文件来源及变量命名部分已省略。

Model 3:三阶调节

img

USEVARIABLES = X W Y XW XZ WZ XWZ;

DEFINE: 
  XW = XW; 
  XZ = XZ; 
  WZ = WZ; 
  XWZ = XWZ;
  
ANALYSIS: 
  TYPE = GENERAL; 
  ESTIMATOR = ML; 
  BOOTSTRAP = 10000;
  
MODEL: 
  [Y] (b0); 
  Y ON X (b1); 
  Y ON W (b2); 
  Y ON Z (b3); 
  Y ON XW (b4); 
  Y ON XZ (b5); 
  Y ON WZ (b6); 
  Y ON XWZ (b7);
  
MODEL CONSTRAINT: 
 NEW(LOW_W MED_W HIGH_W LOW_Z MED_Z HIGH_Z LOW_LOZ MEW_LOZ HIW_LOZ LOW_MEZ MEW_MEZ HIW_MEZ LOW_HIZ MEW_HIZ HIW_HIZ);
 
  LOW_W = #LOWW;  ! 可将#LOWW替换为所选W的低值,下同
  MED_W =#MEDW;  
  HIGH_W = #HIGHW; 
  LOW_Z =#LOWZ; 
  MED_Z = #MEDZ; 
  HIGH_Z = #HIGHZ; 
  
  LOW_LOZ = b1 + b4LOW_W + b5LOW_Z + b7LOW_WLOW_Z; 
  MEW_LOZ = b1 + b4MED_W + b5LOW_Z + b7MED_WLOW_Z; 
  HIW_LOZ = b1 + b4HIGH_W + b5LOW_Z + b7HIGH_WLOW_Z;
  LOW_MEZ = b1 + b4LOW_W + b5MED_Z + b7LOW_WMED_Z; 
  MEW_MEZ = b1 + b4MED_W + b5MED_Z + b7MED_WMED_Z; 
  HIW_MEZ = b1 + b4HIGH_W + b5MED_Z + b7HIGH_WMED_Z;
  LOW_HIZ = b1 + b4LOW_W + b5HIGH_Z + b7LOW_WHIGH_Z; 
  MEW_HIZ = b1 + b4MED_W + b5HIGH_Z + b7MED_WHIGH_Z; 
  HIW_HIZ = b1 + b4HIGH_W + b5HIGH_Z + b7HIGH_WHIGH_Z;
  
  PLOT(PLOW_LOZ PMEW_LOZ PHIW_LOZ PLOW_MEZ PMEW_MEZ PHIW_MEZ PLOW_HIZ PMEW_HIZ PHIW_HIZ);
  
  LOOP(XVAL,1,5,0.1);
  
  PLOW_LOZ = (b0 + b2LOW_W + b3LOW_Z + b6LOW_WLOW_Z) + LOW_LOZXVAL; 
  PMEW_LOZ = (b0 + b2MED_W + b3LOW_Z + b6MED_WLOW_Z) + MEW_LOZXVAL; 
  PHIW_LOZ = (b0 + b2HIGH_W + b3LOW_Z + b6HIGH_WLOW_Z) + HIW_LOZXVAL;
  PLOW_MEZ = (b0 + b2LOW_W + b3MED_Z + b6LOW_WMED_Z) + LOW_MEZXVAL; 
  PMEW_MEZ = (b0 + b2MED_W + b3MED_Z + b6MED_WMED_Z) + MEW_MEZXVAL; 
  PHIW_MEZ = (b0 + b2HIGH_W + b3MED_Z + b6HIGH_WMED_Z) + HIW_MEZXVAL;
  PLOW_HIZ = (b0 + b2LOW_W + b3HIGH_Z + b6LOW_WHIGH_Z) + LOW_HIZXVAL; 
  PMEW_HIZ = (b0 + b2MED_W + b3HIGH_Z + b6MED_WHIGH_Z) + MEW_HIZXVAL; 
  PHIW_HIZ = (b0 + b2HIGH_W + b3HIGH_Z + b6HIGH_WHIGH_Z) + HIW_HIZXVAL;
  
PLOT: 
  TYPE = plot2;
  
OUTPUT: 
  STAND CINT(bcbootstrap);

Model 6:链式中介

img

USEVARIABLES =  X M1 M2 Y;

ANALYSIS: 
  TYPE = GENERAL; 
  ESTIMATOR = ML; 
  BOOTSTRAP = 10000;

MODEL: 
  Y ON M1 (b1); 
  Y ON M2 (b2);
  Y ON X (cdash);  
  M1 ON X (a1); 
  M2 ON X (a2); 
  M2 ON M1 (d1);

MODEL CONSTRAINT: 
  NEW(a1b1 a2b2 a1d1b2 TOTALIND TOTAL); 
  a1b1 = a1b1; 
  a2b2 = a2b2; 
  a1d1b2 = a1d1b2; 
  TOTALIND = a1b1 + a2b2 + a1d1b2; 
  TOTAL = a1b1 + a2b2 + a1d1b2 + cdash; 

OUTPUT: 
  STAND CINT(bcbootstrap); 

Model 7:有调节的中介(第一阶段)

img

USEVARIABLES = X M W Y XW;

DEFINE: 
  XW = XW; 
  
ANALYSIS: 
  TYPE = GENERAL; 
  ESTIMATOR = ML; 
  BOOTSTRAP = 10000;

MODEL: 
  [Y] (b0); 
  Y ON M (b1);
  Y ON X (cdash);

  [M] (a0); 
  M ON X (a1); 
  M ON W (a2); 
  M ON XW (a3);

MODEL CONSTRAINT: 
 NEW(LOW_W MED_W HIGH_W IND_LOWW IND_MEDW IND_HIW IMM  TOT_LOWW TOT_MEDW TOT_HIW);

  LOW_W = #LOWW;  ! 可将#LOWW替换为所选W的低值,下同
  MED_W =#MEDW;  
  HIGH_W = #HIGHW; 
  
  IND_LOWW = a1b1 + a3b1LOW_W;
  IND_MEDW = a1b1 + a3b1MED_W;
  IND_HIW = a1b1 + a3b1HIGH_W;

  IMM = a3b1;

  TOT_LOWW = IND_LOWW + cdash; 
  TOT_MEDW = IND_MEDW + cdash; 
  TOT_HIW = IND_HIW + cdash;

  PLOT(LOMOD MEDMOD HIMOD);

  LOOP(XVAL,1,5,0.1);
  
  LOMOD = IND_LOWWXVAL;
  MEDMOD = IND_MEDWXVAL;
  HIMOD = IND_HIWXVAL;

PLOT: 
  TYPE = plot2;

OUTPUT: 
  STAND CINT(bcbootstrap);

Model 14:有调节的中介(第二阶段)

img

USEVARIABLES = X M V Y MV;

DEFINE: 
  MV = MV; 
ANALYSIS: 

  TYPE = GENERAL; 
  ESTIMATOR = ML; 
  BOOTSTRAP = 10000;

MODEL: 
  [Y] (b0); 
  Y ON M (b1);
  Y ON V (b2); 
  Y ON MV (b3);
  Y ON X (cdash);

  [M] (a0); 
  M ON X (a1); 
MODEL CONSTRAINT: 

  NEW(LOW_V MED_V HIGH_V IND_LOWV IND_MEDV IND_HIV IMM TOT_LOWV TOT_MEDV TOT_HIV);

  LOW_ V = #LOWV;  ! 可将#LOWW替换为所选V的低值,下同
  MED_V =#MEDV;  
  HIGH_V = #HIGHV; 

  IND_LOWV = a1b1 + a1b3LOW_V;
  IND_MEDV = a1b1 + a1b3MED_V;
  IND_HIV = a1b1 + a1b3HIGH_V

  IMM = a1b3;

  TOT_LOWV = IND_LOWV + cdash; 
  TOT_MEDV = IND_MEDV + cdash; 
  TOT_HIV = IND_HIV + cdash;

  PLOT(LOMOD MEDMOD HIMOD);

  LOOP(XVAL,1,5,0.1);

  LOMOD = IND_LOWVXVAL;
  MEDMOD = IND_MEDVXVAL;
  HIMOD = IND_HIVXVAL;

PLOT: 
  TYPE = plot2;

OUTPUT: 
  STAND CINT(bcbootstrap);

Model 11:有三阶调节的中介(第一阶段)

img

USEVARIABLES = X M W Z Y XW XZ WZ XWZ;

DEFINE: 
  XW = XW; 
  XZ = XZ; 
  WZ = WZ; 
  XWZ = XWZ;

ANALYSIS: 
  TYPE = GENERAL; 
  ESTIMATOR = ML; 
  BOOTSTRAP = 10000;

MODEL: 
  [Y] (b0); 
  Y ON M (b1);
  Y ON X (cdash);

  [M] (a0); 
  M ON X (a1); 
  M ON W (a2); 
  M ON Z (a3); 
  M ON XW (a4); 
  M ON XZ (a5); 
  M ON WZ (a6); 
  M ON XWZ (a7);

MODEL CONSTRAINT: 
 NEW(LOW_W MED_W HIGH_W LOW_Z MED_Z HIGH_Z  ILOW_LOZ IMEW_LOZ IHIW_LOZ ILOW_MEZ IMEW_MEZ IHIW_MEZ ILOW_HIZ IMEW_HIZ IHIW_HIZ TLOW_LOZ TMEW_LOZ THIW_LOZ TLOW_MEZ TMEW_MEZ THIW_MEZ TLOW_HIZ TMEW_HIZ THIW_HIZ);

  LOW_W = #LOWW;  
  MED_W =#MEDW;  
  HIGH_W = #HIGHW; 

  LOW_Z = #LOWZ; 
  MED_Z = #MEDZ;  
  HIGH_Z = #HIGHZ; 

  ILOW_LOZ = a1b1 + a4b1LOW_W + a5b1LOW_Z + a7b1LOW_WLOW_Z; 
  IMEW_LOZ = a1b1 + a4b1MED_W + a5b1LOW_Z + a7b1MED_WLOW_Z; 
  IHIW_LOZ = a1b1 + a4b1HIGH_W + a5b1LOW_Z + a7b1HIGH_WLOW_Z;

  ILOW_MEZ = a1b1 + a4b1LOW_W + a5b1MED_Z + a7b1LOW_WMED_Z; 
  IMEW_MEZ = a1b1 + a4b1MED_W + a5b1MED_Z + a7b1MED_WMED_Z; 
  IHIW_MEZ = a1b1 + a4b1HIGH_W + a5b1MED_Z + a7b1HIGH_WMED_Z;

  ILOW_HIZ = a1b1 + a4b1LOW_W + a5b1HIGH_Z + a7b1LOW_WHIGH_Z; 
  IMEW_HIZ = a1b1 + a4b1MED_W + a5b1HIGH_Z + a7b1MED_WHIGH_Z; 
  IHIW_HIZ = a1b1 + a4b1HIGH_W + a5b1HIGH_Z + a7b1HIGH_WHIGH_Z;

TLOW_LOZ = ILOW_LOZ + cdash; 
  TMEW_LOZ = IMEW_LOZ + cdash; 
  THIW_LOZ = IHIW_LOZ + cdash;

  TLOW_MEZ = ILOW_MEZ + cdash; 
  TMEW_MEZ = IMEW_MEZ + cdash; 
  THIW_MEZ = IHIW_MEZ + cdash;

  TLOW_HIZ = ILOW_HIZ + cdash; 
  TMEW_HIZ = IMEW_HIZ + cdash; 
  THIW_HIZ = IHIW_HIZ + cdash;

  PLOT(PLOW_LOZ PMEW_LOZ PHIW_LOZ PLOW_MEZ PMEW_MEZ PHIW_MEZ PLOW_HIZ PMEW_HIZ PHIW_HIZ);

  LOOP(XVAL,1,5,0.1);

  PLOW_LOZ = ILOW_LOZXVAL;
  PMEW_LOZ = IMEW_LOZXVAL;
  PHIW_LOZ = IHIW_LOZXVAL;

  PLOW_MEZ = ILOW_MEZXVAL;
  PMEW_MEZ = IMEW_MEZXVAL;
  PHIW_MEZ = IHIW_MEZXVAL;

  PLOW_HIZ = ILOW_HIZXVAL;
  PMEW_HIZ = IMEW_HIZXVAL;
  PHIW_HIZ = IHIW_HIZXVAL;

PLOT: 
  TYPE = plot2;

OUTPUT: 
  STAND CINT(bcbootstrap);

Model 18:有三阶调节的中介(第二阶段)

img

USEVARIABLES = X M V Q Y MV MQ VQ MVQ;

DEFINE: 
  MQ = MQ; 
  MV = MV; 
  VQ = VQ; 
  MVQ = MVQ;

ANALYSIS: 
  TYPE = GENERAL; 
  ESTIMATOR = ML; 
  BOOTSTRAP = 10000;

MODEL: 

  [Y] (b0); 
  Y ON M (b1); 
  Y ON V (b2); 
  Y ON Q (b3); 
  Y ON MV (b4); 
  Y ON MQ (b5); 
  Y ON VQ (b6); 
  Y ON MVQ (b7);
  Y ON X (cdash);

  [M] (a0); 
  M ON X (a1); 
  
MODEL CONSTRAINT: 

 NEW(LOW_V MED_V HIGH_V LOW_Q MED_Q HIGH_Q ILOV_LOQ IMEV_LOQ IHIV_LOQ ILOV_MEQ IMEV_MEQ IHIV_MEQ ILOV_HIQ IMEV_HIQ IHIV_HIQ TLOV_LOQ TMEV_LOQ THIV_LOQ TLOV_MEQ TMEV_MEQ THIV_MEQ TLOV_HIQ TMEV_HIQ THIV_HIQ)

  LOW_V = #LOWV;  
  MED_V =#MEDV; 
  HIGH_V = #HIGHV; 

  LOW_Q = #LOWQ; 
  MED_Q = #MEDQ;  
  HIGH_Q = #HIGHQ; 

  ILOV_LOQ = a1b1 + a1b4LOW_V + a1b5LOW_Q + a1b7LOW_VLOW_Q; 
  IMEV_LOQ = a1b1 + a1b4MED_V + a1b5LOW_Q + a1b7MED_VLOW_Q; 
  IHIV_LOQ = a1b1 + a1b4HIGH_V + a1b5LOW_Q + a1b7HIGH_VLOW_Q;

  ILOV_MEQ = a1b1 + a1b4LOW_V + a1b5MED_Q + a1b7LOW_VMED_Q; 
  IMEV_MEQ = a1b1 + a1b4MED_V + a1b5MED_Q + a1b7MED_VMED_Q; 
  IHIV_MEQ = a1b1 + a1b4HIGH_V + a1b5MED_Q + a1b7HIGH_VMED_Q;

  ILOV_HIQ = a1b1 + a1b4LOW_V + a1b5HIGH_Q + a1b7LOW_VHIGH_Q; 
  IMEV_HIQ = a1b1 + a1b4MED_V + a1b5HIGH_Q + a1b7MED_VHIGH_Q; 
  IHIV_HIQ = a1b1 + a1b4HIGH_V + a1b5HIGH_Q + a1b7HIGH_VHIGH_Q;

  TLOV_LOQ = ILOV_LOQ + cdash; 
  TMEV_LOQ = IMEV_LOQ + cdash; 
  THIV_LOQ = IHIV_LOQ + cdash;

  TLOV_MEQ = ILOV_MEQ + cdash; 
  TMEV_MEQ = IMEV_MEQ + cdash; 
  THIV_MEQ = IHIV_MEQ + cdash;

  TLOV_HIQ = ILOV_HIQ + cdash; 
  TMEV_HIQ = IMEV_HIQ + cdash; 
  THIV_HIQ = IHIV_HIQ + cdash;

 PLOT(PLOV_LOQ PMEV_LOQ PHIV_LOQ PLOV_MEQ PMEV_MEQ PHIV_MEQ PLOV_HIQ PMEV_HIQ PHIV_HIQ);

  LOOP(XVAL,1,5,0.1);

  PLOV_LOQ = ILOV_LOQXVAL;
  PMEV_LOQ = IMEV_LOQXVAL;
  PHIV_LOQ = IHIV_LOQXVAL;

  PLOV_MEQ = ILOV_MEQXVAL;
  PMEV_MEQ = IMEV_MEQXVAL;
  PHIV_MEQ = IHIV_MEQXVAL;

  PLOV_HIQ = ILOV_HIQXVAL;
  PMEV_HIQ = IMEV_HIQXVAL;
  PHIV_HIQ = IHIV_HIQXVAL;

PLOT: 
  TYPE = plot2;

OUTPUT: 
  STAND CINT(bcbootstrap);

Model 58:同时调节前后的中介

img

USEVARIABLES = X M W Y XW MW;

DEFINE: 
  MW = MW; 
  XW = XW;

ANALYSIS: 
  TYPE = GENERAL; 
  ESTIMATOR = ML; 
  BOOTSTRAP = 10000;

MODEL: 
  [Y] (b0); 
  Y ON M (b1); 
  Y ON W (b2); 
  Y ON MW (b3);
  Y ON X (cdash);

  [M] (a0); 
  M ON X (a1); 
  M ON W (a2); 
  M ON XW (a3); 

MODEL CONSTRAINT: 

  NEW(LOW_W MED_W HIGH_W IND_LOWW IND_MEDW IND_HIW IMM_LOW IMM_MEDW IMM_HIW TOT_LOWW TOT_MEDW TOT_HIW);

  LOW_W = #LOWW;  
  MED_W =#MEDW; 
  HIGH_W = #HIGHW; 

  IND_LOWW = a1b1 + a3b1LOW_W + a1b3LOW_W + a3b3LOW_WLOW_W;
  IND_MEDW = a1b1 + a3b1MED_W + a1b3MED_W + a3b3MED_WMED_W;
  IND_HIW = a1b1 + a3b1HIGH_W + a1b3HIGH_W + a3b3HIGH_WHIGH_W;

  IMM_LOW = a3b1 + a1b3 + a3b3LOW_W;
  IMM_MEDW = a3b1 + a1b3 + a3b3MED_W;
  IMM_HIW = a3b1 + a1b3 + a3b3HIGH_W;

  TOT_LOWW = IND_LOWW + cdash; 
  TOT_MEDW = IND_MEDW + cdash; 
  TOT_HIW = IND_HIW + cdash;

  PLOT(LOMOD MEDMOD HIMOD);

  LOOP(XVAL,1,5,0.1);

  LOMOD = IND_LOWWXVAL;
  MEDMOD = IND_MEDWXVAL;
  HIMOD = IND_HIWXVAL;

PLOT: 
  TYPE = plot2;

OUTPUT: 
  STAND CINT(bcbootstrap);

啦啦啦,语句就搬运到这里啦。之前有小可爱问萜妹模型的语句如何写,所以萜妹想着有了这么期推送。

不过这期现在最大的bug是,如果小可爱们本身没有mplus的语句基础,可能看着会觉得上述有些语句比较复杂,所以萜妹把需要替换的部分都标明出来啦。如果小可爱们想弄清楚这些原理的话,可以回顾萜妹之前关于mplus的语句说明,以及笔记系列关于中介、调节的原理介绍。

最后就是,其实现在我们研究经常使用跨层数据,这篇里也提到了跨层数据需要去另外的网站。所以萜妹如果顺利的话,下周就介绍跨层的语句说明啦。如果搞不定,那下周写什么再看,毕竟最近承受开题压力,萜妹也没什么灵感啦。

那小可爱们,我们下周见啦~

原文推送:

➪干货丨常用模型的Mplus例句