Message/Author 

Sven Lohrey posted on Friday, February 20, 2015  5:24 am



Dear All, I am trying to calculate a multilevel moderated mediation model with x affecting y via m (all on level 1), and x > m being moderated by a level 2 variable w. I also have a level 2 control variable con. Here is how far I got with the syntax. Does this look correct? ANALYSIS: TYPE = TWOLEVEL RANDOM; MODEL: %WITHIN% x m y; sa  m ON x; sb  y ON m; sc  y ON x; %BETWEEN% sa sb sc x m y w con; y ON w con; m ON w con; sa ON w(a2) con; sb ON w con; sc ON w con; sa WITH w(saw); sa WITH sb sc m y; sb WITH sc m y w; sc WITH m y w; m WITH y w; y WITH w; [saw](a1); [sb](b1); MODEL CONSTRAINT: NEW(ind1 ind2 TCIlo TCIhi); TCIlo=0.45441; TCIhi=0.45441; ind1=(a1+a2*TCIlo)*b1; ind1=(a1+a2*TCIhi)*b1; OUTPUT: TECH1 TECH8 CINTERVAL; 

Sven Lohrey posted on Friday, February 20, 2015  5:26 am



Sorry, the last indirect effect should of course be called "ind2". Also, do I have to include the control variable in the WITH statements? 


What is the difference between this question and the previous ones on multilevel mediation that you have asked? 

Sven Lohrey posted on Saturday, February 21, 2015  3:10 am



The main difference is that none of my previous models included a higherlevel moderator of a lowerlevel relationship, as in this model. I have not worked with the TWOLEVEL RANDOM mode before, and while I tried my best to integrate the moderator and control into the available 111 multilevel syntax by Preacher, Zyphur & Zhang, I am not sure if what I did is correct. In particular, I am not sure if the WITH statements as well as the model constraint command are correct. Preacher et al. for example include the correlation of "sa" and "sb" (termed cab) in their equation for the indirect effect in the model constraint section, and I am unsure how to handle this for the above model to account for the moderation effect. I am not a statistician, and while I attended Mplus workshops, they do not deal with complex models like the above or the ones I have previously posted. Unfortunately, here in the UK we don't have a single workshop that focuses on multilevel moderated mediation with Mplus. Thus, I would very much appreciate your help on this. Thank you very much! 


The model you describe closely matches a model discussed in Bauer, Preacher, & Gil (2006, p. 153), in which w moderates the level1 random slopes in a model for a 111 design. Your model adds the level2 control variable con, but otherwise it is nearly the same. However, your syntax treats con not just as a control variable, but also as a moderator. If you really mean to treat it as a control variable only, I would not regress sa, sb, or sc on con. Also, you should not have both of these commands in the same model: sa ON w; sa WITH w; !I would remove this one Same here: y ON w; y WITH w; !I would remove this one [saw](a1); should be [sa](a1); Because both sa and sb are random slopes, you also need sa WITH sb(cab); Finally, your post indicated w was to be treated as a moderator of the x > m path, but your syntax treats it as a moderator of the other paths as well. If you remove the moderation of 'b' (and maybe of 'c'), then the correct ind1 and ind2 will be: ind1=(a1+a2*TCIlo)*b1+cab; ind2=(a1+a2*TCIhi)*b1+cab; 

Sven Lohrey posted on Monday, February 23, 2015  2:51 am



Thank you very much! This is very helpful! I will make sure to have a closer look at the Bauer, Preacher & Gil article. 


Mplus input for that is on slides 80  of the Topic 7 handout from our Mplus short courses on our website. 


As a follow up to the initially posted question and answer of this thread: Following Preacher et al. we tested a multilevel moderated mediation model. Predictor (x), mediator (m) and outcome (y) variables are at level 1. The apath is moderated by a level 2 variable (W). Same setup as in the previous post. However, I am not sure when we can conclude that there is evidence for moderated mediation. Our results yielded: a significant crosslevel interaction (relation between x and m moderated by W) an indirect effect of x on y via m that the conditional indirect effect of x on y depends on level 2 moderator W; conditional indirect effect was significant when the value of the moderator equals the mean, 1SD and 2SDs below and 1SD above the mean; whereas the conditional indirect effect was not significant when the value of the moderator was 2SDs above the mean. Does the latter finding indicate moderated mediation? I mean can we conclude that there is moderated mediation as soon as we identify any value of the moderator for which the indirect effect is significant and for which it is not significant? Is there a way to test for the presence / absence of moderated mediation systematically? Preacher, K. J., Zyphur, M. J., & Zhang, Z. (2010). A general multilevel SEM framework for assessing multilevel mediation. Psychological Methods, 15, 209–33. doi:10.1037/a0020141 


Yes, you have found significant moderated mediation. To do this systematically, check our Mediation page at http://www.statmodel.com/Mediation.shtml where you find plotting of crosslevel effects. This gives you 95% confidence intervals so you can see for which moderator values you have significance (CIs don't cover zero). 


Hi, I have created the syntax below for a multilevel 111 mediation model with level 2 moderation of both the a and b paths. I also have a level 2 control variable called "con". The model runs and is estimated. However, is it correct? If correct, what estimates indicate that the moderation is significant? ANALYSIS: type = twolevel random; estimator = ml; MODEL: %WITHIN% x y m; sa  m on x; sb  y on m; sc  y on x; %BETWEEN% sa sb sc m y w con; y on w con; m on w con; sa on w(a2); sb on w(b2); sc on w; sa with sb(cab); sa with sb sc m y; sb with sc m y w; sc with m y w; m with y w; [sa](a1); [sb](b1); MODEL CONSTRAINT: NEW (inda0 inda1 inda2 indb0 indb1 indb2 wMean wLo wHi); wMean=valuemean; wlo=valuelo; whi=valuehi; inda0=a1*(b1+b2*wMean)+cab; inda1=a1*(b1+b2*wlo)+cab; inda2=a1*(b1+b2*whi)+cab; indb0=(a1+a2*wMean)*b1+cab; indb1=(a1+a2*wlo)*b1+cab; indb2=(a1+a2*whi)*b1+cab; Thank you so much for your help! 


Q1. It is a good start, but I have questions. When you have a moderator on level2 (your w), the mean of the random slope  such as sa  is not [sa] (a1) because [sa] is the intercept. Also the covariance between sa and sb is not (cab); (cab) is the residual covariance. So the means and the covariance would have to be expressed in Model Constraint (not too hard). Also, I don't know what "valuemean" represents. Q2. Moderation is significant if the s on w slope is significant. 


Thanks so much for your reply, Bengt. So generating the a1, b1 and cab variables in the model section is inappropriate given the level2 moderator? This is something that carries over from the nonmoderated 111 model from Preacher, Zyphur, & Zhang (2010), so I could understand that it could require modification in a moderated model. Yet, as I understand, Preacher confirms these lines of syntax in a level2 moderated, 111 mediation in his post above from 15 Feb(same discussion thread). If I express it instead in the model constraint section, would it look like this? inda0=saMean*(sbMean+b2*wMean)+cab; ... where sa/sbMean is replaced with the actual mean value of sa/sb and cab is replaced with the residual covariance? If yes, do I take the mean parameter that is estimated if I run the model above without the sa/sb/sc ON w statements? Where does cab come from? Also, to clarify, "valuemean", "valuelo" and "valuehi" in my syntax above are replaced with the actual numerical values when I run the model. Finally, I see in the output the estimates of sa/sb/sc ON w. So this is refering to moderation of the isolated paths, whereas the estimates generated by the model constraint section refer to the moderation of the indirect effect at specified levels of w. (Correct?) Thanks again for your help with this. 


Instead of the s intercepts you want the s means, so with the regression s on w (b); [s] (a); [w](wmean); Model constraint would compute the NEW parameter as smean = a + b* wmean; Similarly, the cab covariance would be computed from model parameters. 


Thank you again, Bengt. I think I understand. I found how to compute correlation in another discussion thread. Below is my revised syntax. Could you kindly confirm that I have got it correct? Both the computations and the overall model considering my intention is to evaluate the effect of a level2 moderator on both the 'a' and 'b' paths in a 111 mediation model (esssentially, Bauer et al., 2006, figure 4). %BETWEEN% sa(p1) sb(p2) sc m y w con; y on w con; m on w con; sa on w(a2); sb on w(b2); sc on w; sa with sb(p3); sa with sb sc m y; sb with sc m y w; sc with m y w; m with y w; [sa](a1); [sb](b1); [w](wmean); MODEL CONSTRAINT: NEW (cab saMean sbMean inda0 inda1 inda2 indb0 indb1 indb2 MGOMean MGOLo MGOHi); cab=p3/(sqrt(p1)*sqrt(p2)); saMean=a1+a2*wmean; sbMean=b1+b2*wmean; wMean=valuemean; wLo=valuelo; wHi=valuehi; inda0=saMean*(sbMean+b2*wMean)+cab; inda1=saMean*(sbMean+b2*wLo)+cab; inda2=saMean*(sbMean+b2*wHi)+cab; indb0=(saMean+a2*wMean)*sbMean+cab; indb1=(saMean+a2*wLo)*sbMean+cab; indb2=(saMean+a2*wHi)*sbMean+cab; 


Still some work needed for cab because sa and sb covary also because they are both a function of w so the slopes on w play a role. And you don't need to compute the corresponding correlation as I think you were after in your input. 

Gary Adams posted on Wednesday, November 04, 2015  12:19 pm



I am hoping to get your insights. I have daily diary data (observations nested within individuals, n=80) collected once each day over a 14 day period. On the within level 1, the variables are x1 =stress experience and m2=appraisal collected on days 1 through 14. On the between level 2 are social support (which will serve as a crosslevel moderator), control variables (e.g., age) and the dv Y1, which is burnout. I am generally familiar with using Mplus to model crosslevel interactions and the like when the outcome (dv) is at the within level. My first question is how to specify a lagged relationship such that stress experiences (x1 measured at day t) are modeled as a predictor of future appraisals (m2 t +1). A second question is, are there any unique issues in terms of programming owing to Y1 being a level 2 variable? Any insights, examples, comments would be greatly appreciated. 


One approach is to analyze this in wide, singlelevel form so that the variables are x and m at the 14 time points. The level2 variables (which don't vary across time) are then added to the wide layout. That makes it easy to specify lagged relationships. And crosslevel interactions turn into products of variables. 

Eunice Kim posted on Thursday, November 05, 2015  7:59 am



Hello! I have a 111 mediation with a level 2 moderator (w) and a level 2 control (exd). I'd like to a crosslevel moderated mediation in which the slopes are not randomly varying but the intercepts are randomly varying. Please see the below and then let me know whether the syntax looks correct or not. Thanks! ANALYSIS: TYPE = TWOLEVEL RANDOM; MODEL: %WITHIN% x m y; beta1  m ON x; beta2  y ON m; beta3  y ON x; %BETWEEN% beta1 beta2 beta3 x m y w exd; y ON w exd; m ON w exd; beta1 ON w(a2); beta2 ON w; beta3 ON w; [beta1](a1); [beta2](b1); beta1 @0; beta2 @0; beta3 @0; MODEL CONSTRAINT: NEW(ind1 ind2 wlo whi); wlo=0.05441; whi=0.45441; ind1=(a1+a2*wlo)*b1; ind2=(a1+a2*whi)*b1; OUTPUT: TECH1 TECH8 CINTERVAL; 


Some observations: You are fixing the residual variances of the random slopes beta1beta3 at zero. This means that they are still varying, so you have crosslevel interaction (which happens only with varying slopes). It also means that you can drop the  statements and instead create the crosslevel interactions by multiplying w and x, w and m. If you have problems or further question, send output to Support along with your license number. 

Gary Adams posted on Friday, November 06, 2015  7:59 am



Thank you so much for your reply to my earlier post. I had been stuck thinking in terms of a 'long format' approach rather than a wide one. I will have to shift my thinking and learn something new. Thanks again Dr Muthen. Gary 

Eunice Kim posted on Sunday, November 08, 2015  12:44 pm



Thank you so much for your answer, Dr. Muthen. You are correct in that I meant fixing the residual variances of the random slopes. According to your suggestion, I've revised it. Does it look correct? ANALYSIS: TYPE = TWOLEVEL RANDOM; MODEL: %WITHIN% x m y; m ON x (a1); y ON m (b1); y ON x; %BETWEEN% x m y w xw exd; y ON w xw exd; m ON xw (a2); m ON w exd; MODEL CONSTRAINT: NEW(ind1 ind2 wlo whi); wlo=0.05441; whi=0.45441; ind1=(a1+a2*wlo)*b1; ind2=(a1+a2*whi)*b1; OUTPUT: TECH1 TECH8 CINTERVAL; 


Isn't x a variable that varies not only across between units? Which would mean that x*w is not a betweenlevel variable as you have it. So xw needs to appear on within. 

Jenna Kim posted on Friday, June 03, 2016  6:32 pm



Dear Dr. Muthen and Muthen, I have a multilevel modmed model with x1,x2>m>y(level1), and x1,x2> m being moderated by w(level2). Level1 controls are(d1d4, c1c2). I keep getting a message, "ERROR Undefined variable used in transformation: BETA1". My syntax follows: variable: names are tid d1d4 c1c2 x1x2 w m y; usevariables are tid d1d4 c1c2 x1x2 w m y; cluster is tid; analysis: type=twolevel random; model: within= d1d4 c1c2 x1x2 m; between= w; missing= blank; centering= grandmean (w); %WITHIN%; [y] (beta0); y on d1d4; y on c1c2; beta1  m ON x1; beta2  m ON x2; sb  y ON m; sc1  y ON x1; sc2  y ON x2; [beta1](a1); [beta2](a2); [sb](b1); beta1 beta2 with b1; %BETWEEN%; y ON w; beta1 ON w; ! estimates gamma11 beta2 ON w; ! estimates gamma21 m with beta1 beta2; define: c1beta1b1= c1*beta1*b1; c2beta2b1= c2*beta2*b1; model constraint: new(ind1 ind2 TCIlo TCIhi); TCIlo= 2.17867; TCIhi= 3.96473; ind1= (a1+w*TCIlo)*b1+c1beta1b1;ind2= (a1+w*TCIhi)*b1+c1beta1b1;ind3= (a2+w*TCIlo)*b1+c2beta2b1;ind4= (a2+w*TCIhi)*b1+c2beta2b1; tot1= ind1+sc1; tot2= ind2+sc1; tot3= ind3+sc2; tot4= ind4+sc2; OUTPUT: TECH1 TECH8 CINTERVAL; 


This type of question should be sent to Support along with your license number. 


Hi, I would like some help with the interpretation of my findings for a 111 mediation model with level 2 moderator. I initially find no significant indirect effect in my unmoderated 111 model (random slopes). When I add the level 2 moderator, the indirect effect of x on y via m becomes significant. Further, the indirect effect appears to depend on moderator w  the indirect is significant at low and mean levels of w, but not at high levels of w. Yet my crosslevel interaction term (random slope of y and m on w) is not significant. Of note, when I run a crosslevel interaction model isolating the my relationship with cross level interaction, the interaction term is significant. It becomes insignificant when I add the xm relationship to the model. Thank you in advance for your advice. 


This is not an unusual finding. Generally there isn't high power to detect interaction terms. Moderated effects can still be significant in certain intervals. 


I need a multilevel moderated mediation model to include two mediators as well as withinlevel demographic covariates (sex, ethnicity, age, and income). I based the following syntax off Sven's original post and Dr. Preacher's feedback to the best of my ability, but given the complexity of this analysis, I'm not confident this is correct. Could someone please advise? WITHIN = sex eth age income; BETWEEN = w; CLUSTER = cluster; ANALYSIS: TYPE = TWOLEVEL RANDOM; MODEL: %WITHIN% x m1 m2 y; sa1  m1 ON x; sa2  m2 ON x; sb1  y ON m1; sb2  y ON m2; sc  y ON x; y ON sex age eth income; %BETWEEN% sa1 sa2 sb1 sb2 sc x m1 m2 y w; y ON w; m1 ON w; m2 ON w; sa1 ON w(wa1); sa2 ON w(wa2); sb1 sb2 ON w; sc ON w(wc); sa1 WITH sa2 sb2 sc m y; sa2 WITH sb1 sc m y; sb1 WITH sb2 sc m y; sb2 WITH sc m y; sa1 WITH sb1(cab1); sa2 WITH sb2(cab2); [wa1](a1); [wa2](a2); [wb1](b1); [wb2](b2); MODEL CONSTRAINT: NEW(ind1l ind1h ind2l ind2h wLO wHI); wLO=0.629; wHI=0.629; ind11=(a1+wa1*0.629)*b1+cab1; ind1h=(a1+wa1*0.629)*b1+cab1; ind21=(a2+wa2*0.629)*b2+cab2; ind2h=(a2+wa2*0.629)*b2+cab2; OUTPUT: TECH1 TECH8 CINTERVAL; 


Before you get into the complexities of this, I recommend checking if sa1, sa2, sb1, sb2 actually have significant variances. That's often not the case in my experience. If not, things simplify. These statements don't make sense because the bracket statements don't refer to variables in the model as far as I can see: [wa1](a1); [wa2](a2); [wb1](b1); [wb2](b2); 


Hi, I have a similar model like Sven above. That is 111 mediation and only the the X > Me link is moderated by a level2 variable. X is groupmean centered and Mo (betweenlevel moderator) is grandmean centered. Me and Y are not centered. I run the analyses (with Type is twolevel random and ALGORITHM=INTEGRATION) but I run into the following problems: 1. "ERROR OCCURRED WHILE COMPUTING THE STANDARD ERRORS FOR THE STANDARDIZED COEFFICIENT." Any ideas why? 2. I want to conduct simple slopes (slope estimate for low and high moderator). Can I do that in Mplus or do I need to use Preacher's utility? 3. When I look at the values of the Y axis in my plot, the Y looks centered (around 0). But the variable has not been centered. How is this possible? Thank you! Paris 


2. You can do this in Mplus. See out mediation page at http://www.statmodel.com/Mediation.shtml For 1 and 3, please send your output to Support along with your license number. 


Thank you, Bengt! It turns out that the only way to get standardized coefficients with type is twolevel random is to combine ESTIMATOR=BAYES with ALGORITHM=GIBBS(RW). However, in this analysis the PSR increases, even when I increase the FBITERATIONS. So I always get the following message in the output: USE THE FBITERATIONS OPTION TO INCREASE THE NUMBER OF ITERATIONS BY A FACTOR OF AT LEAST TWO TO CHECK CONVERGENCE AND THAT THE PSR VALUE DOES NOT INCREASE. The support team told me that this happens probably because the random slope variance is not adequate, although it is significant. Is there a way to get standardized coefficients without performing BAYES? I'm puzzled because when I don't use BAYES everything looks fine in my output; the only problem is that there are no standardized estimates. Thank you! Paris 


With random slopes, Bayes is the only way to get standardized values  and they are special ones that need to be understood by reading the literature on them such as Hamaker, E.L., Asparouhov, T., Brose, A., Schmiedek, F. & Muthén, B. (2018). At the frontiers of modeling intensive longitudinal data: Dynamic structural equation models for the affective measurements from the COGITO study. Multivariate Behavioral Research, DOI: 10.1080/00273171.2018.1446819 (Online supporting material). 

Back to top 