Moderated mediation two-level model PreviousNext
Mplus Discussion > Multilevel Data/Complex Sample >
Message/Author
 Antje Schmitt posted on Monday, October 27, 2008 - 8:00 am
We did an Experience Sampling study and collected data (events, emotions, work engagement) from 55 people twice a day for nine working days (repeated measures design: daily measures are nested in individuals). We like to test a moderated mediation model with:
Daily events --> triggering emotional experiences (mediator) --> influencing work engagement (DV) (Lower Level Mediation). The moderators are on Level 2 (they were measured once).
Is it possible to test such a multilevel moderated mediation model with Mplus and how could I perform the analyis? Thanks a lot in advance!
 Kristopher J. Preacher posted on Monday, October 27, 2008 - 10:21 am
Yes, it is possible. Bauer, Preacher, & Gil (2006, pp. 153-158) address this model. We have code in SAS, SPSS, and HLM for lower-level mediation models with the potential for moderation by level-2 predictors (see quantpsy.org), but it is also easy to do in Mplus. Here is Mplus code that yields the same output:

TITLE: 1-1-1 model from BPG article
DATA: FILE IS bpg_example_data.dat;
VARIABLE: NAMES ARE id x m y;
CLUSTER IS id;
ANALYSIS: TYPE = TWOLEVEL RANDOM;
MODEL:
%WITHIN%
sa | m ON x;
sb | y ON m;
sc | y ON x;
m y;
%BETWEEN%
sa sb sc m y;
sa WITH sb(cab);
sa WITH sc m y;
sb WITH sc m y;
sc WITH m y;
m WITH y;
[sa](sa); [sb](sb); [sc](sc);
MODEL CONSTRAINT:
NEW(ind);
ind=sa*sb+cab; ! indirect effect
OUTPUT: TECH1 TECH8;

Bauer et al. use a parametric bootstrap to obtain a CI for the indirect effect. A modification of the R code here can be used to achieve the same goal using Mplus output. Ex.11.11 in the Mplus Users Guide will also be helpful.

Bauer, D. J., Preacher, K. J., & Gil, K. M. (2006). Conceptualizing and testing random indirect effects and moderated mediation in multilevel models: New procedures and recommendations. Psychological Methods, 11, 142-163.
 Antje Schmitt posted on Wednesday, October 29, 2008 - 5:02 am
Thanks a lot! Especially the Mplus code was very helpful.
 Jeffrey Kahn posted on Wednesday, November 16, 2011 - 8:52 am
I have a 2-1-1 mediation model based on a diary study. Event rumination mediates the relation between attachment anxiety and event disclosure. Attachment avoidance is a level 2 covariate predicting event disclosure. Event intensity is a moderator of the b path between event rumination and event disclosure.

My Mplus code is based on Preacher, Zypher, and Zang (2010):

TITLE: Moderated mediation model
DATA: FILE IS data.dat;
VARIABLE: NAMES ARE code ev_int ev_disc
ev_rumin attavoid attanx;
USEVARIABLES ARE code ev_int
ev_disc ev_rumin attavoid attanx;
BETWEEN IS attanx attavoid;
CLUSTER IS code;
ANALYSIS: TYPE IS TWOLEVEL RANDOM;
MODEL: %WITHIN%
ev_rumin ev_disc;
sb | ev_disc ON ev_rumin;
%BETWEEN%
attanx ev_rumin ev_disc attavoid;
ev_rumin ON attanx(a);
ev_disc ON ev_rumin(bb);
ev_disc ON attanx attavoid;
sb WITH attanx ev_rumin ev_disc
attavoid;
[sb](bw);
MODEL CONSTRAINT:
NEW(b indb);
b=bb+bw;
indb=a*b;
OUTPUT:
TECH1 TECH8 CINTERVAL;

Did I handle the attavoid covariate properly? Also, how do I integrate the moderating effect of ev_int? Thanks.
 Bengt O. Muthen posted on Wednesday, November 16, 2011 - 3:20 pm
aatavoid is an observed between-level covariate so I wouldn't mention its variance as you do. If it predicts sb I would add that ON statement instead of WITH.

As for the moderator, first see if the sb variance is significant or if a fixed slope can be used. Generally speaking, with a continuous moderator, use Define to create the interaction.
 Jeffrey Kahn posted on Friday, November 18, 2011 - 11:05 am
Thank you, Bengt.

The sb variance is significant. I would like to see if ev_int (a level 1 variable) can predict the variance in sb. My intuition was to add the following statement in the %BETWEEN% section:

sb ON ev_int;

However, from your above comment it seems that I should use DEFINE to create an interaction term:

DEFINE: interact=ev_int*ev_rum;

Would I then include the following statement in the %BETWEEN% section?

ev_disc ON ev_rumin(bb) ev_int interact;

If it helps, my model can be viewed at:
http://my.ilstu.edu/~jhkahn/Multilevel%20moderated%20mediation.gif
 Bengt O. Muthen posted on Friday, November 18, 2011 - 6:13 pm
With a significant sb slope your model specification in your first message gives an interaction between the within-level part of ev_rumin and the between-level part of ev_disc. This, I think, is the moderation you talked about in your first message.

See also slide 45 of our Topic 7 short course handout.
 Yan Liu posted on Monday, April 30, 2012 - 11:46 am
Hi, Bengt

I am conducting some anlayses using the multilevel mediation models based on SEM framework introduced by Preacher, Zyphur, and Zhang (2010). I also read the paper "constructing covariates in multilevel regression" by Asparouhov and you (2007).I like this new approach a lot.

However, I found that the model doesn't run for ordinal categorical outcome variable. I wonder if there is a way for me to use this approach for categorical outcome.

The model I used has two outcomes (PAHome & PESch), one mediator (Enjoy) and one predictor (TT). The syntax is attached as follows.

USEVARIABLES = ideal-individ Enjoy PESch PAHome;
CATEGORICAL = PESch;
CLUSTER IS classid;
MISSING = ALL(999);

ANALYSIS:TYPE = TWOLEVEL;
MODEL:
%WITHIN%
TTw BY ideal-individ;
Enjoy ON TTw (aw);
PAHome ON Enjoy (b1w);
PAHome ON TTw;
PESch ON Enjoy (b2w);
PESch ON TTw;

%BETWEEN%
TTb BY ideal-individ;
Enjoy ON TTb (ab);
PAHome ON Enjoy (b1b);
PAHome ON TTb;
PESch ON Enjoy (b2b);
PESch ON TTb;
 Linda K. Muthen posted on Tuesday, May 01, 2012 - 10:28 am
Please send your output and license number to support@statmodel.com.
 Yan Liu posted on Thursday, May 03, 2012 - 4:44 pm
Hi, Linda

Thank you for your reply. I tried WLSMV estimator, then the model worked fine. Do you think if this is appropriate?

If it is, I have further questions. First, as far as I know full information ML can handle missing data. Here I used WLSMV, how are the missing data handled using this estimator?

Second, for my data set 20% missing on the mediator and two outcome variables. The missing values depend on gender and the predictor(a latent variable with four indictors). Is my understanding correct that I should include gender as a covariate to control for the gender differences on missingness (for both mediator and outcome variables)?

Can I use gender as a moderator? I tried to create an interaction between gender and the predictor (latent variable), but it didn't work. Is there a way to do it?

Thanks.
Yan
 Linda K. Muthen posted on Saturday, May 05, 2012 - 11:49 am
See the following technical appendix on the website:

Weighted Least Squares Estimation with Missing Data

Yes, you should include gender as a covariate. You can use the XWITH option to create an interaction between a latent an observed variable.
 Yan Liu posted on Wednesday, May 09, 2012 - 6:19 pm
Hi, Linda

Thank you so much!
So WLS estimator still uses FIML to treat missing values. What is the default for deleting missing values? I noticed the number of observations in the output is the same as the covariate, gender.

I tried the interaction between "gender" and the latent predictor "TTw", but it seems WLSMV doesn't run for this moderated mediational model. The error message is "WLSMV is not allowed with TYPE=RANDOM". So do we have to use MLR estimator?

Hence, I changed estimator to MLR, but it seems that the model didn't run if the outcome, "PESch", is defined as categorical. The error message is as follows.

Observed variable on the right-hand side of a between-level ON statement must be a BETWEEN variable. Problem with: ENJOY

I also tried to define the outcome "PESch" as a continuous variable, but it doesn't work well. If I have to treat outcome variables as continuous to run moderated mediational models, what strategies would you recommend? Thanks a lot!

Here is part of my Mplus syntax.
ANALYSIS:TYPE = TWOLEVEL RANDOM;
MODEL:
%WITHIN%
TTw BY ideal-individ;
sexTT| sex XWITH TTw;
Enjoy ON TTw (aw);
Enjoy ON sex sexTT;
PAHome ON Enjoy (b1w);
PAHome ON TTw sex sexTT;
PESch ON Enjoy (b2w);
PESch ON TTw sex sexTT;
 Linda K. Muthen posted on Thursday, May 10, 2012 - 11:24 am
Missing data handling is not done in the same way for weighted least squares and maximum likelihood. Weighted least squares is described in the technical appendix I referred you to. Maximum likelihood is described in the Little and Rubin book cited in the user's guide.

Missing data theory applies to dependent variables. Observations with missing data on one or more independent variables are not included in the analysis.

Put a factor behind joy, for example,

f BY enjoy@1; enjoy@0;

use f instead of enjoy as the covariate.
 Yan Liu posted on Wednesday, May 16, 2012 - 12:27 pm
Hi, Linda

Followed your suggestion, I put a factor behind enjoy, but it seems the model didn't work. Could you please take a look and see if my model is specified correctly. Thanks a lot!
Yan

ANALYSIS: TYPE = TWOLEVEL RANDOM;

MODEL:
%WITHIN%
TTw BY ideal-individ;
sexTT| sex XWITH TTw;
fw BY enjoy@1; enjoy@0;
fw ON TTw (aw);
fw ON sex sexTT;
PAHome ON fw (b1w);
PAHome ON TTw sexTT;
PESch ON fw (b2w);
PESch ON TTw sexTT;

%BETWEEN%
TTb BY ideal-individ;
fb BY enjoy@1; enjoy@0;
fb ON TTb (ab);
PAHome ON fb (b1b);
PAHome ON TTb;
PESch ON fb (b2b);
PESch ON TTb;
ideal-individ@0;


Here is the error message.
THE ESTIMATED WITHIN COVARIANCE MATRIX IS NOT POSITIVE DEFINITE AS IT SHOULD BE. COMPUTATION COULD NOT BE COMPLETED.
THE VARIANCE OF TTW APPROACHES 0. FIX THIS VARIANCE AND THE CORRESPONDING COVARIANCES TO 0, DECREASE THE MINIMUM VARIANCE, OR SPECIFY THE VARIABLE AS A BETWEEN VARIABLE.
 Bengt O. Muthen posted on Wednesday, May 16, 2012 - 6:55 pm
The message says that the variance of ttw approaches zero. To investigate why, you could simplify the model to only include the ttw and ttb factors, that is, using only the variables ideal-individ. If that does not show the same problem, then add variables into that model. Step-wise model building is always recommended.
 Ari Malka posted on Saturday, June 09, 2012 - 4:39 pm
Hello,

We are testing a model wherein we have military personnel nested within teams. Each team also has a group of leaders (and a group of subordinates). We have hypothesized a moderated-mediation model wherein Leadership Team Cohesion --> Subordinate Team Cohesion --> Team Performance. We also hypothesized two first stage moderators: (1) subordinate level of agreement on the extent to which their leadership team forms a cohesive unit and (2) racioethnic similarity between the leadership and subordinate teams (in the same larger team). We want to use moderated-mediation wherein all variables are at level 2 and wherein all variables are at level 1 (except the moderators) all in the same model. In other words, we want to have 6 latent variables (3 team level and 3 individual level). Is this possible?
 Linda K. Muthen posted on Sunday, June 10, 2012 - 3:41 pm
Yes, you can have a model with 3 team-level and 3 individual-level latent variables.
 ari malka posted on Saturday, June 30, 2012 - 12:00 pm
Hi Linda,

Thanks for the response above (regarding the model with leadership team cohesion). I am having trouble figuring out the code for mediation (both levels 1 and 2)and the code for the two moderators. Would it help to see my model? What is the best way for me to show it to you? Any help would be greatly appreciated!!

Ari
 ari malka posted on Saturday, June 30, 2012 - 12:01 pm
So far, this is my code:

VARIABLE:
NAMES ARE Cluster ClusSize Rank SubTeam Gender Race Age TeamEff1
TeamEff2 TeamEff3 TeamEff4 TeamCoh1 TeamCoh2 TeamCoh3 TeamCoh4
LeadCoh1 LeadCoh2 LeadCoh3 LeadCoh4 RaceSim rwgTCun rwgLCun;
USEVARIABLES ARE ClusSize Rank SubTeam Gender Race Age TeamEff1
TeamEff2 TeamEff3 TeamEff4 TeamCoh1 TeamCoh2 TeamCoh3 TeamCoh4
LeadCoh1 LeadCoh2 LeadCoh3 LeadCoh4 RaceSim rwgTCun rwgLCun Cluster;
MISSING ARE ALL (999);
CLUSTER IS Cluster;

ANALYSIS:
TYPE IS TWOLEVEL;
ESTIMATOR IS MLM;
ITERATIONS = 1000;
CONVERGENCE = 0.000001;

Model:
%Within%
LTCi by LeadCoh1@1 LeadCoh2 LeadCoh3 LeadCoh4;
TCi by TeamCoh1@1 TeamCoh2 TeamCoh3 TeamCoh4;
TPi by TeamEff1@1 TeamEff2 TeamEff3 TeamEff4;
TCi on LTCi;
TPi on TCi;

%Between%
LTCg by LeadCoh1@1 LeadCoh2 LeadCoh3 LeadCoh4;
TCg by TeamCoh1@1 TeamCoh2 TeamCoh3 TeamCoh4;
TPg by TeamEff1@1 TeamEff2 TeamEff3 TeamEff4;
TCg on LTCg;
TPg on TCg;

OUTPUT: SAMPSTAT RESIDUAL STANDARDIZED CINTERVAL TECH3 TECH4;
SAVEDATA:
FILE IS Diss Data for Mplus 6.22;
FORMAT IS FREE;
RECORDLENGTH = 1000;
 Linda K. Muthen posted on Sunday, July 01, 2012 - 10:49 am
This looks okay.

Please limit posts to one window.
 baozhenzhou posted on Friday, January 31, 2014 - 8:23 pm
Hello! We want to test a moderated mediation model just like the model 5 in the following paper (when the a and b paths are both moderated by w):
Preacher, K. J., Rucker, D. D., & Hayes, A. F. (2007). Addressing moderated mediation hypotheses: Theory, methods, and prescriptions. Multivariate Behavioral Research, 42, 185-227.
Our model is perceived school climate (x) --> deviant peers affiliation (m) --> delinquency(y). The moderator is effortful control (w). Given we were analyzing clustered data (students are nested within 10 schools). Is it possible to test such a multilevel moderated mediation model with Mplus and how could I perform the analyis? Thanks a lot in advance!
 Linda K. Muthen posted on Saturday, February 01, 2014 - 2:12 pm
Ten schools is too few for multilevel modeling. You need at least 20 and many would suggest 30-50. Instead create nine dummy variables and use those as covariates to control for non-independence of observations.
 baozhenzhou posted on Saturday, February 01, 2014 - 6:32 pm
Linda, thanks for your help! The Mplus User's Guide has a description of how to refer the levels of a nominal dependent variables in the MODEL command but no description of how to create dummy variables for independent in the DEFINE command. I have searched the Mplus Discussion for the answers and found the following example. But I still can't understand how to write the syntax for the dummy variables of 10 schools? Could you help me? Thanks a lot!

DEFINE;
white = 0;
if (raceth eq 1) then white = 1;
black = 0;
if (raceth eq 2) then black = 1;
etc.
 Linda K. Muthen posted on Sunday, February 02, 2014 - 10:22 am
The above DEFINE command is how you would create dummy variables. You should create k-1 dummy variables where k is the number of categories.
 baozhenzhou posted on Sunday, February 02, 2014 - 5:48 pm
Thanks, Linda. Followed your suggestion, this is my code to define nine dummy variables for ten schools(sc).
DEFINE:
sc1 = sc == 1;
sc2 = sc == 2;
sc3 = sc == 3;
sc4 = sc == 4;
sc5 = sc == 5;
sc6 = sc == 6;
sc7 = sc == 7;
sc8 = sc == 8;
sc9 = sc == 9;
Did I handle the dummy variables properly? Thank you very much!
 Linda K. Muthen posted on Monday, February 03, 2014 - 10:38 am
This does not look correct. You should have a cluster variable that takes on the values of 1 through 10.

DEFINE:
sc1=0;
if cluster == 1 then sc1 = 1;
sc2=0;
if cluster == 2 then sc2 = 1;
ETC.
 luk bruyneel posted on Friday, February 07, 2014 - 1:02 am
Hello,

After a succesful multilevel mediation model (2-2-1), I'm looking for moderated mediation, using the Mplus codes that come with Preacher, Rucker and Hayes (2007) 'Addressing moderated mediation hypotheses'. I used model 2, where the a path is moderated by w (first stage moderation):

MODEL:
%WITHIN%
y on l;

%BETWEEN%
y on m (b1)
x
w
xw;
m on x (a1)
w
xw (a3);
MODEL CONSTRAINT:
new (ind wmodval);
wmodval = -1;
ind=(a1+a3*wmodval)*b1;

Your help would be appreciated in the complete and correct interpretation of the findings:
- m is significant to y, x/w/xw are not
- x and w are significant to m, xw is not
- significant indirect effect
 Bengt O. Muthen posted on Friday, February 07, 2014 - 1:53 pm
There is no significant moderation, but the indirect effect is significant.
 luk bruyneel posted on Friday, February 07, 2014 - 2:01 pm
Thanks for your reply!
-So if xw were significant to m, there would be significant moderation?
-Since x is not significant to y, there is full mediation?
 Bengt O. Muthen posted on Friday, February 07, 2014 - 2:02 pm
Right.
 luk bruyneel posted on Sunday, February 16, 2014 - 1:48 am
In the above multilevel moderated mediation model with a categorical outcome, Mplus automatically uses Bayesian estimation. In a previous post in the 'CFA with Bayesian estimation' forum you mentioned that PPC for multilevel models has not been implemented yet.
Is there a way to assess model fit here then?
 Linda K. Muthen posted on Sunday, February 16, 2014 - 11:14 am
This has not yet been developed. So there is no way to assess fit.
 luk bruyneel posted on Sunday, February 23, 2014 - 2:02 am
Thanks for your reply! In my 2-2-1 model, I want to combine moderated mediation and simple mediation for another variable in the same model. Is the following model correct? Are there any problems known with such model, except that model fit cannot be assessed?

%BETWEEN%
!moderated mediation
y on m (b1)
x1
w
x1w;
m on x1 (a1)
w
x1w (a3);

!mediation
y on x2;
m on x2(a);


MODEL CONSTRAINT:
new (ind1 ind2 wmodval);
wmodval = 0.125;
ind1=(a1+a3*wmodval)*b1;
ind2=a*b1;
 Bengt O. Muthen posted on Tuesday, February 25, 2014 - 1:45 pm
I don't see a problem. Note that you can use the LOOP option (see UG ex 3.18).
 annebell yang posted on Monday, May 12, 2014 - 4:24 pm
Hi Dr. Muthen,
I am wondering if mplus can test two moderators at different stages at the sometime, like model 21 in Hayes' new book "PROCESS". Basically, I want to test a model like this:
x-->m-->y(y1, y2, y3),
the relation between x and m is moderated by moderator 1, and m-->Y relation is moderated by moderator2. In addition, I also have multiple dependent variables.

Moreover, these y1, y2, y3 are measured by team leaders (all other variables are individual level), so I want to control for team level variance, so I specify a two-level model,just no independent variables in level 2.

So my questions are
1 can mplus test such a model? because I could use PROCESS macro in spss to test this moderated mediation, but PROCESS does not have multilevel functions. and it can only test one dv at a time.

2 if mplus can, can I use indirect to test the moderated mediation? Do I need to test each dv at a time? But can I use indirect to test two moderators at the same time?

Thank you very much in advance for your reply!


annebell
 annebell yang posted on Monday, May 12, 2014 - 4:42 pm
Dear Dr. Muthen,
I also have another model I am not quite sure.
The model is a moderated mediation,
x-->m(m1, m2, m3)-->Y(Y1, Y2, Y3), and the relation between x and m is moderated by a Moderator. All These variables are individual level, except for Y is measured by team leader, so i want to control for team level variance, but no IVs in team level. I have three mediators, and three dependent variables.


I have used Bayes iterations, and the moderation is significant. However, if I just use regular iterations, the results are not significant. My question is what is the difference between the two? Which results should I use?



Thank you a lot!

annebell
 Bengt O. Muthen posted on Tuesday, May 13, 2014 - 5:38 am
This is possible in Mplus, but you have to study up on what it means. It is straightforward to do two-level moderated mediation in Mplus. In your case you just add a between part for the y variables by mentioning their variances. If Bayes gives significance and ML doesn't it can mean that the distribution of the estimate is not symmetric/normal. In this case Bayes is preferrable (bootstrap is an alternative for ML, but doesn't exist yet for two-level).
Back to top
Add Your Message Here
Post:
Username: Posting Information:
This is a private posting area. Only registered users and moderators may post messages here.
Password:
Options: Enable HTML code in message
Automatically activate URLs in message
Action: