Message/Author 


I am attempting to test a moderated mediation model where X>M>Y (all observed variables) is moderated by w, a binary variable (gender). I know how to examine this with a multiple group approach but am attempting the approach described in Preacher, Rucker & Hayes (2007) in Figure 2 model 5 where W influences paths a and b of the mediation chain. With some help from Preacher & Hayes, I have modeled this as pasted below. However, all of the estimates SEs, ps, CIs are exactly the same for all of the paths with the exception of X>M and M>Y. This seems very odd to me. Can you point me to what I might be doing wrong? Thank you. ANALYSIS: BOOTSTRAP = 1000; MODEL: M WITH MW; M ON X (a1) W XW (a3); Y ON M (b1) X W XW MW (b2); MODEL CONSTRAINT: NEW(eff1 eff2); eff1=(a1+a3*1)*(b1+b2*1); eff2=(a1+a3*2)*(b1+b2*2); OUTPUT: CINTERVAL(bcbootstrap); 


Can you send your input, data, output, and license number to support@statmodel.com. 


I should have seen this earlier. The label b2 after x, w, ex, and mw holds all of those regression coefficients equal. It should be stated as: Y ON M (b1) X W XW MW (b2); 


Thank you. The results make much more sense now. Now it is only the M on W and M on MW results that are identical. Does it make sense that this would be the case? Might this be because the MW crossproduct involves a binary variable (coded 1 & 2)? 


I think you mean M on w and Xw. It is the same issue. The label needs to be on the next line. M ON X (a1) W XW (a3); 


Ah, yes. All looks well now. Thank you again for the help. 


Drs. Muthen, I am attempting to fit a Moderated Mediation model with simple (single level) survey data. Specifically, I wish to examine the moderating influence of a dichotomous variable (Mod) effect coded (1, +1) on the 'A', 'B', and 'Cprime' paths as seen in Edwards and Lambert (2007; Model H). I realize that the multigroup function of Mplus may be used in this specific instance(e.g. a categorical moderator), however I would like to retain the more traditional 'cross product' approach for two reasons: 1) To replicate OLS estimates for all paths, 2) I am often interested in similar models with continuous moderators where multigroup analysis is not appropriate. IV and Mod were centered prior to importing into Mplus, and product terms were created using a DEFINE statement. I use the following code: MODEL: Med on Mod IV IVxMod; ! 'A' Path Y on Mod IV IVxMod Med ModxMed; ! 'B' and 'Cprime' Paths MODEL INDIRECT: Y IND Med IV; The resulting model has df = 1 and a significant ChiSq. Examination of RESIDUAL matrix suggests a notable covariance between Med and ModxMed. Adding a covariance parameter results in a notpositive firstorder derivative matrix. I have run into this problem before in the past, and I have a hunch that it stems from the fact that Med is an endog variable. Any advice? Thanks 


If you obtain standard errors, the message most likely comes from the fact that the mean and the variance of your binary variable are not orthogonal. You can ignore the message if this is the case. 

Hong Deng posted on Thursday, May 10, 2012  8:10 pm



Dear Drs. Muthen, I’m trying to test a moderated mediation model with nested data. Data for all my variables were collected from individual and the level of interest is individual too. Basically it is a 111 mediation model (xmy)with a level 1 moderator (w). It should be an easy one if my data isn’t nested in several clusters. Is it possible to test such a model in Mplus? How should I write my Syntax. Thanks very much. 


Moderation can be handled by a multiple group analysis if the moderator is categorical or by creating an interaction term between the moderator and the variable being moderated. You can use TYPE=COMPLEX to take the nonindependence of observations into account. Modify Example 3.11 and add CLUSTER to the VARIABLE command and TYPE=COMPLEX to the ANALYSIS command. 


I am attempting to conduct a moderated mediation analysis where all variables are latent variables formed with continuous indicators. In my model, the independent variable (X) functions as a moderator of the b1 path (the path from the mediating variable to outcome). This model is illustrated in Preacher, Rucker & Hayes (2007)  Figure 2, Model 1. I get an error message that says: MODEL INDIRECT is not available for TYPE=RANDOM. 1. Is it possible to do moderated mediation with a latent interaction variable? 2. Any guidance as to how to generate syntax for this model would be greatly appreciated. Best, Elizabeth 


This type of model is discussed in Section 3 and Section 5 of Muthén, B. (2011). Applications of causally defined direct and indirect effects in mediation analysis using SEM in Mplus. which is on our web site under Papers, Mediational Modeling. As stated in Section 3, Model Indirect cannot be used for this type of model. Section 5 shows how to define the direct and indirect effects instead using Model Constraint. 


Dear Drs. Muthen, I am currently running a moderated mediation model (X > A > Y with the pathway from A to Y being moderated by gender) using the following syntax: Y on X; A on X(Med1); Y on A(Med2); Y on Gender A*Gender; MODEL CONSTRAINT: NEW(Indir1); Indir1=Med1*Med2; This model revealed significant moderated mediation; however, correlations suggested that moderation could also be expected on the pathway between X and A. When I checked for moderation of this pathway it also revealed significant moderated mediation. I've been told that presenting a model with both moderated pathways is inappropriate and that I need to check to see which model is best; however I am unsure of how to do this. Do you have any advice or syntax for such a problem? Many thanks in advance, Paula 


I would suggest a 2group analysis with gender as the grouping variable. You can then easily test if the two paths are the same or different across gender. I can't see why a model with both paths differing across gender would be inappropriate. 

Luisa Rossi posted on Thursday, October 25, 2012  4:32 am



Dear Drs Muthen, I have been running some mediation analyses and found that the x>y relationship was mediated by m. I would now like to see if the a and b paths of the indirect models are different depending on whether respondents score high or low on a number of personality measures. So far, I have used multiple group comparisons with difftest to assess this. I am now thinking there may be a better way to do it but I am not sure. Can you help? Thanks, Luisa 


Why are you dissatisfied with your approach? Is it because your moderator is continuous and you are categorizing it? See Example 3.18 in the Version 7 Mplus User's Guide on the website for another approach to moderated mediation. 

Luisa Rossi posted on Thursday, October 25, 2012  10:08 am



Hi Linda, Thanks for the tip! I will look at the example. I am unsure whether multiple group comparison is the most effective way to look at moderated mediation or whether reviewers may criticize it. Thanks again! 


There are two ways to look at moderation. One is multiple group and the other to create an interaction variable. 

Luisa Rossi posted on Tuesday, October 30, 2012  7:03 am



Hi Linda, I work with survey data so I had to impute my dataset to account of missing data. I noticed that difftest cannot be used with imputed data so I am thinking about using the interaction variable approach. The example you recommended above seems to be based on path analysis (?) as it is able to use the define option after the usevariable one. I am working with latent variables so I first need to define them  however, mplus is not happy for me to use 'define' within the 'model' option. What can I do? 


With latent variables, you should use the XWITH option for interactions. DEFINE is for observed variables. You don't include it in the MODEL command but above or below it. 

Luisa Rossi posted on Wednesday, October 31, 2012  5:15 am



Thanks Linda! AS I am interested in the potential moderating role of w on path a and b, I adapted the model 5 example in Preacher, Rucker, and Hayes (2007) but I used the XWITH command to obtain the two interaction terms mw  m XWITH w; xw  x XWITH w; and included these interaction terms in the model as they suggest: MODEL: y on m (b1) x w mw (b2) xw; m on x (a1) w xw (a3); I find that there is no evidence for a moderating role of either mw or xw (Ps>.05). However, when I had run the multiple group comparisons using w as the grouping variable I had found that it moderated path a (not b)... I am slightly confused on why this might be... can you help? are the 2 approaches not 100% comparable? 


These two approaches should yield identical results. Please send the two outputs and your license number to support@statmodel.com. 

C. Lechner posted on Monday, January 14, 2013  7:58 am



Dear Drs. Muthén, I am testing a moderated mediation model where the moderator is a latent variable; i.e., there is a latent interaction using the XWITH command involved. Because this requires TYPE=RANDOM, the STANDARDIZED output is not available in these analyses. However, I would like to report Rsquare values for my outcomes. > Is there any way to obtain Rsquare values for these analyses? Many thanks in advance! Clemens 


See the FAQ Latent Variable Interactions on the website. 

C. Lechner posted on Thursday, January 17, 2013  7:38 am



Thanks, Linda. I have a followup question: Using the formulas provided in the FAQ, I programmed myself an Excel spreadsheet that calculates Rsquare, change in Rsquare, and standardized path coefficients. It reproduces the numbers from your example on p. 6 in the FAQ sheet perfectly well. However, I wonder how one would generalize the equations from the FAQ sheet to include covariates. In my model (otherwise identical to Fig.2 on p.7), all three latent variables are regressed on a set of covariates. > How do I get the total variances of the latent variables in this case? My approach was to sum all the product terms of the squared regression weights and the variance of the respective predictor, plus the residual variance of the latent variable (which I get in the output). E.g., for a latent variable eta2, regressed on eta1 and covariates x1 and x2, where b1 to b3 denote regression coefficients and zeta2 the residual variance of eta2, the total variance would be obtained by computing: Var(eta2) = b1^2 * Var(x1) + b2^2 * Var(x2)+ b3^2 * Var(eta1) + Var(zeta2). However, this seems to systematically underestimate rsquare. > Have I overlooked anything? > Is there any way to directly get the total variance of a latent variable that is regressed on a set of covariates in the Mplus output? 


You need the variances of the two factors in the interaction. I think you are using the residual variances. If the variances are not available in TECH4, you will need to compute them. 

C. Lechner posted on Thursday, January 17, 2013  9:42 am



TECH4 is unavailable for TYPE = RANDOM. I tried to compute the variances of all latent variables in the way described above. Referring to the notation in Figure 2 in the FAQ sheet, extended by two covariates x1 and x2 for each latent variable, I compute Var(eta1) = b11^2 * Var(x1) + b12^2 * Var(x2)+ ß^2 * Var(eta2) + Var(zeta1) Var(eta2) = b21^2 * Var(x1) + b22^2 * Var(x2)+ Var(zeta2) Var(eta3) = b31^2 * Var(x1) + b32^2 * Var(x2)+ ß1^2 * Var(eta1) + ß2^2 * Var(eta2) + 2*ß1*ß2*Cov(eta1,eta2)+ß3^2*Var(eta1*eta2) + Var(zeta3) where eta1 is regressed on eta2 (coefficient ß), eta3 is regressed on eta1 (coefficient ß1), eta2 (coefficient ß2), and their interaction (coefficient ß3), all three latent are regressed on the covariates x1 and x2 (coefficients bij), zeta_i denote residual variances for the latent variables; and where Var(eta1*eta2) = Var(eta1)*Var(eta2)+[Cov(eta1,eta2)]^2 and Cov(eta1,eta2) = ß*Var(eta2). > Is this correct? There must be something missing. Rsquares are substantially smaller than the ones Mplus computes for a model without interaction. 


In your eta1 equation you have to express eta2 in terms of the x's so that eta1 is written as a function of these x's. You also have to take into account that the x's are correlated and add a term like for the et1 equation: 2*Cov(x1, x2)*b11*b12. 

C. Lechner posted on Friday, January 18, 2013  1:04 am



Thanks you, Bengt – I think the covariance term is what I had overlooked. I'll add it and see whether the numbers add up to something that makes sense then. As this involves a lot of manual computation when more covariates are involved, I wonder whether there is any easy workaround? E.g., could one simply estimate the factor variances in a measurementpart only model (without the covariates and structural paths) and use those as input for the calculations of standardized parameters and rsquare in the final model? I'm afraid that would bias the variance estimates, wouldn't it? 


It might be too approximate. 

ywang posted on Friday, March 29, 2013  12:49 pm



Dear Drs. Muthen: I have a question about how to decide the signficance of the moderated medaition. M is a mediator and W is a moderator (gender, 0 and 1). For the following input: ANALYSIS: BOOTSTRAP = 1000; MODEL: M ON X (a1) W XW (a2); Y ON M (b1) X W XW MW (b2); MODEL CONSTRAINT: NEW(eff1 eff2); eff1=a1*b1; eff2=(a1+a2)*(b1+b2); Should we test the indirect effect of a2*b1 and a1*b2 in order to conclude the signficant moderated mediation? Thank you very much in advance! 


Seems like you have set it up right. One thing you want to test is the difference between eff1 and eff2. To test significance of the moderation in the mediation, don't you want to test that a2*(b1+b2) is significant? Both the difference and this last term can be given NEW names so you get ztests. 


Hello! I wanted to ask a question about a post from the first author on this post regarding a model he created from your 2007 Conditional Indirect Effects Paper, working from "Model 5". In line with the model, I am confused about the role of eff1 and eff2. Having performed previous mediations with the eff1 = a*b, this makes sense to me based on the M ON (X & XW) and Y on (M & MW) paths. I am confused about the eff2 role of multiplying each by 2  what would this be representing? Thank you! Leslie MODEL CONSTRAINT: NEW(eff1 eff2); eff1=(a1+a3*1)*(b1+b2*1); eff2=(a1+a3*2)*(b1+b2*2); OUTPUT: CINTERVAL(bcbootstrap); 


One and two standard deviations above the mean of zero for the moderator. 


Hello, I am attempting to complete a moderated mediation in which my predictor and mediator variables are latent and I have a categorical and latent outcome. The format follows Preacher’s Model 5 in which the moderator impacts both paths a and b. The moderator variable has 4 categories (Black, White, Hispanic, Other). Would it be best to utilize the multiple group function, comparing all 4 racial groups together? Though, I am unsure of how to complete group comparisons from there. Or would it be better to run models with several dummy codes representing the moderator? 


I would suggest doing multiplegroup analysis, letting the a and b paths vary. 


I found most other researchers would calculate the critical ratios of differences(CRD) by dividing the difference between two estimates by an estimate of the standard error of the difference (Arbuckle, 2003). A CRD greater than 1.96 indicates that there was a significant difference between the two parameter estimates at p < 0.05.However, they usually do this in the Amos software. However, in the Mplus result part, I cannot find the standard error of the difference. I am wondering how can you do this through the results provided by Mplus? 


My question is, I want to do multigroup analysis to identify whether the path coefficients differ significantly between east and west. We compared the first model, which allows the structural paths to vary across cultures, with the second model, which constrains the structural paths across cultures to be equal to examine the cultural differences. All the other paths (i.e., factor loadings, error variances and structure covariances) were constrained to be equal. However, I found the factor loading are still different in the Mplus result part. Are there other things that need to be constrained equally? By the way, do you have any sample code for me to do such a multiple group comparison of the mediation model? Thanks. 


You can use MODEL TEST to do the CRD test. See the user's guide. See the Topic 1 course handout on the website under multiple group analysis to see the inputs for testing for measurement invarinace. 

JOEL WONG posted on Tuesday, October 08, 2013  5:28 pm



I am attempting to test a first and second stage moderated mediation model. I have one predictor, one outcome, one mediator, and one moderator (W). W is hypothesized to moderate the relationship between the predictor and the mediator and the relationship between the mediator and the outcome. This model is described as model 58 in Hayes' PROCESS manual  see http://mres.gmu.edu/pmwiki/uploads/Main/process.pdf Does anyone know the Mplus syntax for this model? Preacher et al. (2007) provides the Mplus syntax for several moderated mediation models, but it doesn't include this model. Thank you. 


UG ex 3.18 describes the case of a moderator Z that moderates the influence of the predictor X on M and X on Y. That involves creating X*Z in Define. A plot of the effects and their confidence bands are obtained by LOOP. So that's the first part of your question. The second part is the moderation of the M>Y relationship. This calls for creating M*Z and regressing Y on it. LOOP could be used here as well. 


Hello, Thank you for your previous suggestion in running my moderated mediation with 2 latent predictors, continuous mediator, and binary outcome. I have 4 groups, and have tested the model using the indirect command and bootstrapping (with BC confidence intervals). To compare the effect size of the indirect effects across groups. Would it be acceptable to examine whether the confidence intervals between groups overlaps as a means of testing for significant differences? Or is there a better way to test whether the effect sizes are significantly different (e.g. running a difftest where I constrain paths a and b and compare them to a nonconstrained model)? Also, when I run the mediation for the whole sample, the mediation is significant. However, when I run the mediation using multigroup, the indirect effect is no longer significant in any of my four groups. Would it be safe to say that this could be due to sample size issues (as, I have already established measurement invariance in my predictors) 


You should use DIFFTEST. Yes, lower power could be the reason for this. 

Laura Baams posted on Tuesday, October 29, 2013  9:02 am



Hi, I am running a bootstrap multigroup mediation model with observed variables. Two predictors (x1, x2), two mediators (m1, m2) and one outcome (y). There are 5 groups for the multigroup part. I have compared model fit of a model in which I constrain all paths to be equal across groups, and a model in which they are not equal, and variations of this. The model with the best fit, is the one where groups 1 and 2 are constrained to be equal, and group 3 and 4 are constrained to be equal. I need to report the standardized estimates, but these are not equal for groups 1 and 2, or 3 and 4, while the unstandardized estimates are. From other posts I understand that Mplus does not constrain standardized estimates, does this mean I cannot report standardized estimates in this case? Is there a way I can still obtain standardized estimates (that are equal across groups 1 and 2; and 3 and 4)? Thanks so much! 


The standardized coefficients are standardized using different standard deviations for each group. This is why the coefficients are different. It is not because they are not constrained to be equal in the analysis. 


Dear Drs Muthén, I am running a moderated mediation model based on Preacher, Rucker & Hayes (2007) model 3: the path from mediator m to y is moderated by w. The output shows that all paths are significant at p =.000. However, the fit indexes are as follows: AIC 195.379 BIC 221.996 SampleSize Adjusted BIC 171.948 ChiSquare Test of Model Fit Value 12.001 Degrees of Freedom 2 PValue 0.0025 RMSEA Estimate 0.358 90 Percent C.I. 0.182 0.565 Probability RMSEA <= .05 0.004 CFI 0.958 TLI 0.852 ChiSquare Test of Model Fit for the Baseline Model Value 243.003 Degrees of Freedom 7 PValue 0.0000 SRMR 0.311 Can I consider that my model is significant, relying on the significance of the paths? Thank you for your input, Patricia 


Model fit is not assessed using the significance of the model parameters. The fit statistics indicate that leaving out the two paths represented by the two degrees of freedom create a lack of fit. 

Hannah Lee posted on Sunday, March 30, 2014  2:17 pm



Hello, I am trying to run a moderated mediation model (Similar to Model 2 as Hayes and Preacher 2007 shows). The IV, Moderater are latent constructs and I am unable to use the MODEL INDIRECT with the latent interactions. So I referred to Muthen (2011) sections 3 and 5 using BOOTSTRAP=1000; and OUTPUT: cinterval(bootstrap); But I keep getting the error message that bootstrap cannot be used with TYPE=RANDOM. How can I get the indirect/total effects? ==================================== ANALYSIS: TYPE = RANDOM; bootstrap = 1000; MODEL: x1 BY CPI1CPI3; x2 BY CPC1CPC3; w BY CCC1CCC3; m BY NPA1NPA5; d BY Perf1 Perf6; x1xw  x1 XWITH w; x2xw  x2 XWITH w; d ON m (b1) x1 x2 w x1xw x2xw c1 c2; m ON x1 (a1) x2 (a2) w x1xw (a3) x2xw (a4) c1 c2; MODEL CONSTRAINT: new (ind wmodval); wmodval = 1; ind=(a1+a3*wmodval)*b1; ind=(a2+a4*wmodval)*b1; OUTPUT: SAMPSTAT STAND; cinterval(bootstrap); *** ERROR in ANALYSIS command BOOTSTRAP is not allowed with TYPE=RANDOM. 


Drop the bootstrap request. If your sample size is not small it is unlikely that bootstrap SEs would be very different from regular ML SEs. 

Hannah Lee posted on Sunday, March 30, 2014  7:07 pm



Thank you, Dr. Muthen. Would N=201 sample size be sufficient? Some of the tvalues for the indirect effects come out to be borderline significant. I was wondering if this may be improved if I were able to bootstrap. 


I would not worry unless the sample size is less than 100. I would be conservative as far as significance goes given that you are not doing a single test but several tests. 

CW posted on Tuesday, April 22, 2014  10:53 am



I have used the following syntax to test a moderated mediation model: y ON m (b); m ON x (gamma1) z xz (gamma2); However, I am now realizing that this did not include a test of y on x, which seems like the typical c path in a mediation model. Can you explain to me why did is not present in this syntax, and is it necessary? Thank you! 


Whether you include a direct effect in your model is up to you. Your research hypothesis should determine this. 

Alvin posted on Thursday, May 01, 2014  10:31 pm



Hi there, I estimated a moderated mediation model (similar to that of Hayes and Preacher). All looks good except I did not get fit statistics in my output, even though I did it without bootstrap. Can you advise? many thanks Here's the relevant bit of the syntax: Analysis: Type = random; ALGORITHM=INTEGRATION; Model: pte by conflict family witness access child; adapt by safety bonds justice roles exist; stress by basic health dispa safe; ptexad  pte xwith adapt; whodas12 on pte (b1) adapt stress ptexad; stress on pte (a1) adapt ptexad (a3); Model constraint: new (ind wmodval); wmodval = 1; ind=(a1+a3*wmodval)*b1; Information Criteria Akaike (AIC) 9305.490 Bayesian (BIC) 9484.270 SampleSize Adjusted BIC 9319.462 (n* = (n + 2) / 24) 


Chisquare and related fit statistics are not available when means, variances, and covariances ore not sufficient statistics for model estimation. This is the case for numerical integration. 

Alvin posted on Friday, May 02, 2014  7:48 pm



Thanks very much Dr Muthen for the quick reply. I could not do it without numerical integration however. Is there a way to get fit statistics without using numerical integration. If not, how do I know if my model fits? In terms of interpreting the outcome, is it correct to say that the putative moderator did not moderate the mediating relationship between the IVs and DV, as the interaction product (ptexad) was not significant? 


When there are no absolute fit statistics, nested models can be tested using 2 times the loglikelihood difference which is distributed as chisquare. Nonnested models with the same set of dependent variables can be compared using BIC. If the interaction is not significant, there is no moderation. 

Alvin posted on Wednesday, May 07, 2014  1:27 am



Thanks. Another question is the output does not give standardized coefficients as this was not allowed under Type=random analysis .. Is there a way to obtain standardized estimates as I'm interested in the effect sizes 


Because the variance of y varies as a function of x with TYPE=RANDOM, we do not give standardized estimates. 

Alvin posted on Wednesday, May 07, 2014  5:44 pm



Thanks Dr Muthen  it probably doesn't make sense then to standardize the estimates of the effect size, does it? Also, I notice boostrap can not be used to construct CIs in this case with a randominterceptrandomslope model. Why is that? 

Alvin posted on Wednesday, May 07, 2014  6:06 pm



A further question Dr Muthen is, I notice in model 5 by Preacher et al, the value of w at which the conditional indirect effect of x is estimated is set to 1. Is this an accepted practice? The authors refer to the JohnsonNeyman (Jn) technique where a region of significance or a range of values of w is used in lieu of using arbitrary conditional values of w. Is this method used in analysis of moderated mediation models? 


The variance of y varies as a function of x for any random effect. In this case, standardization is not done. If you add ALGORITHM=INTEGRATION; to the ANALYSIS command, I think you can use BOOTSTRAP. 1 is probably one standard deviation below the mean. This is a common choice. See Example 3.18 where you can get a plot that shows a region of significance. 

Alvin posted on Thursday, May 15, 2014  11:41 pm



Thanks Dr Muthen. I wanted to look at the significance level of a particular set of indirect paths (beta1 x beta2) in the mediation part of the moderated mediation model, as this path (beta2) dropped out (not significant) after building the moderators into the model. Of interest is whether this could be due to power issues (as I have a small sample size). In randomeffect analysis however Mplus does not allow modelindirect command. Is there an alternative way to request estimates of indirect/direct effects in this case? 


See Slides 8085 of the Topic 7 course handout on the website. 


I have an environmental observed variable of maltreatment, one observed impulsivity mediator, and a latent antisocial variable as my outcome. I'm interested in using genotype as a moderator. The problem is my moderator (genotype) is categorical and my maltreatment variable is categorical (no maltreatment, emotional abuse, physical abuse). I understand that the common practice in SEM is to use multiple group comparisons. This is my problem and confusion. Recent recommendations by GxE experts call for all covariates to be included as interaction terms in your model. For example, I will have race and age as covariates in my SEM (full partial). However, it's now recommended that you should also add "race x environment" and "age x environment" as covariate terms in addition to having them be "main effect" terms. The Age x environment term is easy to add as a covariate because age is continuous. Race is not so easy, because it's categorical. Thus I'm not sure how to "control" for these other moderation effects that include categorical variables. Do I just do a massive multiple group comparison? I've considered dummy coding the categorical moderator variables, so that I can create interaction variables and add everything in one SEM rather than do many group comparisons. That way I can appropriately add covariates where I want (full partial). Is that bad practice? Any advice? 


Seems like (1) dummy coding categorical variables and creating interactions is a relatively simple way to go. (2) Multiplegroup modeling is also fine, but you would either have to combine that with interaction terms or do groups as maltreatment x genotype (so 6 groups). Approach (1) allows only different regression effects while approach (2) also allows different (residual) variances for DVs. You may want to ask this type of general modeling question on SEMNET. 

Alvin posted on Monday, July 28, 2014  4:54 pm



Dear Dr Muthen, following a mediated moderation model, I ended up with unstandardized estimates. I was wondering since standardization isn't available in randomeffect models, are there alternative ways for standardizing the estimated coefficients manually? I've previously obtained unstandardized estimates from a similar model but without interaction terms, and they look similar to the one with interaction effects. Does it make sense to obtain standardized effects in this case? this is a fair question that I anticipate reviewers may ask. Many thanks 


What are your Model command statements that give rise to a random effect model? 

Alvin posted on Monday, July 28, 2014  5:34 pm



Here's the relevant bit of the syntax. The model was estimated using algorithmintegration. Many thanks Model: pte by conflict family witness access child; adapt by safety bonds justice roles exist; stress by basic health dispa safe; ptexad  pte xwith adapt; stxad  stress xwith adapt; whodas on pte (b1) adapt stress (c1) ptexad stxad (b2); stress on pte (a1) adapt ptexad (a3) stxad with stress; whodas on dsmany; Model constraint: !plot(indirect); !loop(mod,1,2,0.1); new (ind wmodval); wmodval = 1; ind=(a1+a3*wmodval)*(b1+b2*wmodval); new(ac); ac = a1*c1; 


Hi! I have problems when computing moderated mediation with 2 moderators (no problems if I run the analysis separately for each moderator): MAXIMUM LOGLIKELIHOOD VALUE FOR THE UNRESTRICTED (H1) MODEL IS 10455.691 THE ESTIMATED COVARIANCE MATRIX IS NOT POSITIVE DEFINITE AS IT SHOULD BE. COMPUTATION COULD NOT BE COMPLETED. PROBLEM INVOLVING VARIABLE VBFS_1. THE CORRELATION BETWEEN VBFS_1 AND ZETA_2 IS 1.000 THE PROBLEM MAY BE RESOLVED BY SETTING ALGORITHM=EM AND MCONVERGENCE TO A LARGE VALUE. Syntax for the analysis with 2 moderators. analysis: type=random; model: wo_1 by … ; gro_1 by … ; vbf_1 by … ; int1  plum_1 XWITH vbf_1; plum_1 on la_1 ze_1 wo_1 (a1) gro_1 (a2) vbf_1 (a3); ze_2 on plum_1 (b1) la_1 ze_1 int1; int2  plda_1 XWITH vbf_1; plda_1 on la_1 ze_1 wo_1 (a4) gro_1 (a5) vbf_1 (a6); leng_2 on plda_1 (b2) la_1 ze_1 int2; MODEL CONSTRAINT: NEW (ind1 ind2 ind3 ind4 ind5 ind6); ind1 = a1*b1; ind2 = a2*b1; ind3 = a3*b1; ind4 = a4*b2; ind5 = a5*b2; ind6 = a6*b2; Can you help me? Thanks a lot. 


You should ask yourself why THE CORRELATION BETWEEN VBFS_1 AND ZETA_2 IS 1.000 Two variables that correlate one cannot both be used in an analysis. They are not statistically distinguishable. 


Alvin  you are using XWITH. For standardization with XWITH, see our FAQ: Latent variable interactions. 

Alvin posted on Tuesday, July 29, 2014  6:55 pm



Many thanks Dr Muthen. Can I just clarify, following the equations set out in your FAQ, in order to calculate the standardized coefficient of say beta1(direct effect)  beta1 by square root of V (n1) where V is the variance of latent factor 1 and n1 is ? 

Pieter Baay posted on Wednesday, July 30, 2014  12:10 am



Dear Linda, I'm performing two moderated mediation analyses (one with observed categorical moderator, one with latent continuous mod) and I wonder which moderator value(s) to specify in the MODEL CONSTRAINT. For the categorical moderator, I wrote: X BY x1x4; M BY M1M5; Y BY Y1Y8; XM  X XWITH MOD; Y ON M (a) X; M ON X (gamma1) mod XM (gamma2); MODEL CONSTRAINT: new(pinde pindeN test); pinde = a*(gamma1+gamma2*1); pindeN = a*(gamma1+gamma2*0); test = pinde  pindeN; Is this correct? And what would this look like for a continuous, latent moderator? In previous posts (e.g. by Hannah Lee and Alvin), a moderator value of 1 was specified. Could you please explain what the 1 represents (especially given their construction of latent variables)? Thanks so much! 

annared posted on Wednesday, July 30, 2014  5:18 am



Dear Linda, Thanks for your quick answer. If I use wo_1 instead of vbf_1 to build the interactions (int1 and int2) I get the same error message (i.e. that the correlation between wo_1 and ze_2 is 1.0). However, in both cases the correlation is not 1.0 when I run the analysis without int2. So I guess I have something wrong with my syntax? Thank you! 


Alvin  are you referring to the bottom of page 7? Two lines from the bottom has Sqrt{V(eta_1)}, where eta_1 refers to Figure 2. 


Pieter  that input looks correct. For a latent moderator you have to use the estimated factor variance and look at two values such as 1 SD below vs 1 SD above the factor mean of zero. 


Annared  send your two outputs to support. 

Zaijia posted on Friday, August 01, 2014  8:17 pm



Should the result of indirect effects from Mplus be the same as PROCESS? 


PROCESS(ORS) specified the hardware you the analysis uses and has nothing to do with estimated effects, only how long it will take to compute them. 

Zaijia posted on Saturday, August 02, 2014  7:31 pm



Hi, Dr. Muthen, thank you for your response. But I didn't mean the processor. I mean the Macro developed by Hayes for mediation analysis. Should the results from that macro be the same as Mplus? 


I am not familiar with Hayes' macro. If M and Y are continuous and you use ML I would assume you get the same results. 

Zaijia posted on Sunday, August 03, 2014  1:08 pm



Yes, I found that when Y is dichotomous the results are different. Why does that happen? Another question is how to add interaction term into Mplus?For example, I have 2 dichotomous IV, one mediator, one DV and I want to test the moderated mediation effect, what will the syntax be like? 


Question 1: Take a look at the paper on our website: Muthén, B. & Asparouhov T. (2014). Causal effects in mediation modeling: An introduction with applications to latent variables. Forthcoming in Structural Equation Modeling. Question 2: See the second bullet of our Mediation page http://www.statmodel.com/Mediation.shtml 

Zaijia posted on Sunday, August 03, 2014  2:13 pm



That's really helpful!Thank you so much! 

Zaijia posted on Sunday, August 03, 2014  2:19 pm



What does this following syntax in your mediation page mean? MODEL INDIRECT: y MOD m z (2 2 0.1) xz x; 


See the Version 7.2 Mplus Language Addendum on the website with the user's guide. 

Pieter Baay posted on Tuesday, August 05, 2014  12:14 am



Thank you for the suggestion to use + 1SD and 1SD above the factor mean of zero, based on the factor variance. I've got two followup questions: 1) I think I should use the factor variance of the latent interaction effect rather than the factor variance of the moderator. Is this correct and if so, how can I obtain its value? 2) Is the mean of factors (such as XM) automatically set to zero or should I add a statement to do so? Or, alternatively, should I use the mean /+ 1 SD as moderator values? Thanks again for your help! 


1) No. And, this value is not a parameter, so not available. 2) The mean of a latent variable interaction is not a parameter and should not be referred to. For moderator values, see the Latent Variable Interaction FAQ. 

Alvin posted on Wednesday, August 06, 2014  10:41 pm



Many thanks Dr Muthen. Can I ask  my model is a probit model (with a categorical outcome variable, the others are continous) would it be possible to specific a logit model to derive ORs? Thanks v much for your help! 


You can obtain a logistic model by using maximum likelihood estimation. WLSMV gives a probit model. 


I am working on a multilevel mediated moderation model. Technically that should be the same as a moderated mediation (like Model 2 in Preacher, Rucker & Hayes, 2007). The indpendent (Intr) and dependent variable (Irri) in the model have been measured every day over five days (Level 1). Both the moderator (Age) and the mediator (WM) are traits (Level 2). I know that a crosslevel interaction usually is modelled by regressing the moderator on the random slope. But I need to treat the crosslevelinteraction as a variable. Can I use the DEFINEcommand for a crosslevelinteraction, and what should I do with the random slope? Or maybe there is another solution? USEVARIABLES ARE Intr Age WM Irri iact; MISSING = All(99); CLUSTER IS id; BETWEEN ARE Age WM; DEFINE: iact = Intr *Age; ANALYSIS: TYPE IS TWOLEVEL RANDOM; MODEL: %WITHIN% s  Irri ON Intr; %BETWEEN% Intr Age WM Irri; Irri ON WM(b1) Intr Age iact; WM ON Intr(a1) Age iact(a3); MODEL CONSTRAINT: NEW (ind wmodval); wmodval=10; ind=(a1+a3*wmodval)*b1; OUTPUT: TECH1 TECH8 CINTERVAL; Your help is appreciated! 


If you have %within% s  y on x; %between% y s on w; s@0; Fixing the residual variance s@0 is the same as working with an observed variable xw = x*w. You see this is you write out the formulas (or look at slide 45 of our Topic 7 handout). In practice you have to fix at a small value such as 0.01. 


Thanks for your quick answer. I checked the handout, and the examples in the users guide, but still I am puzzled how to model the indirect effect between a crosslevelinteraction (IV = Level 1, Mod = Level 2, DV = Level 1), and a Level 2 Mediator? What I want to test is a mediated moderation. 

Shiny posted on Saturday, August 16, 2014  2:39 pm



I am testing a moderated Mediation model, with categorical DV. Moderator=mod. Mediators=m. I want to see how mod interacts with the IV (x) and influences the path a (similar to Preacher et al 2007 model 2) The input in mplus is as follow: USEVARIABLES ARE x1 x2 x3 mod m1 m2 m3 y1 y2 y3 y4 y5; CATEGORICAL =y4 y5; ANALYSIS: TYPE = RANDOM; MODEL: xw BY x1 x2 x3;!IV mw BY m1 m2 m3;! Mediator y1w BY y1 y2;!DV1 y4 ON y3 (E); DV3 on DV2 y5 ON y1w(D); y3 ON mw (C); y1w ON mw(B); mw ON xw (A); Here starts with the moderator: y3 y1w ON mod xwmod;! Regress dv1 2 on interaction and moderator mw ON mod;! Regress mediator on moderator xwmod  xw XWITH mod; mw ON xwmod (A2);! Regress mediator on interaction MODEL CONSTRAINT: NEW(AB BD ABD wmodval AC CE ACE); AB = (A+A2*wmodval)*B; BD = B*D; ABD = (A+A2*wmodval)*B*D; wmodval =1; AC = (A+A2*wmodval)*C; CE = C*E; ACE = (A+A2*wmodval)*C*E; OUTPUT: TECH1 CINTERVAL; This Syntax is based on Preachers script. Is it correct? do i need to Regress the distal DVs (y4 y5)on moderator and interaction? Since bootstrap is not possible with Random, can I rely on the CI without Boot?! Thx! 


This looks correct. You may also want to use LOOP plotting (see our Mediation topic in the left column of the home page). I would regress y4 and y5 on moderator and interaction. Bootstrap is available with Random in Version 7.2. 

Shiny posted on Monday, August 18, 2014  3:30 pm



Thank you Dr. Muthen. I looked at the Output. before moderator was added, all Regression and indirect effects were significant. Adding interaction and moderator, neither interaction nor moderator and indirect effect significant. Does it mean there is no moderated Mediation effect? The Mediation model: Xw (latent variables) mw( latent mediator)  y1w (latent)  y5 (categorical) Xw mw y3  y4 (binary) Interaction is xw * mod, named as xwmod Y4 ON Y3: estimate =0.594 p= 0.054 Y5 ON Y1w: 0.316 p=0.046 Y3 ON Mod(moderator):0.075 p= 0.310 y3 on Mw(mediator):3.260 p=0.000 y3 on Xwmod(interaction):0.027 p=0.503 Y1w ON mw (mediator) : 2.891 p=0.000 y1w on Xwmod(interaction) 0.022 p= 0.417 y1w on Mod(moderator): 0.105 p= 0.026 mw ON xw: 0.181 p= 0.004 mw on Xwmod: 0.006 p= 0.783 mw on mod:0.037 p= 0.110 New/Additional Parameters estimate p AB 0.506 0.032 BD 0.913 0.072 ABD 0.160 0.133 WMODVAL 1.000 1.000 AC 0.571 0.047 CE 1.937 0.088 ACE 0.339 0.167 Because I have categorical DV, by Default estimator is MLR, but bootstrap does not Support MLR. When I used WLSMV, then I cannot use Random. What can I do to get bootstrap function? Thx! 


It's a tricky situation. You have y4 binary and y5 categorical, which means that you need to carefully consider how indirect and direct effects are computed; see Muthén, B. & Asparouhov T. (2014). Causal effects in mediation modeling: An introduction with applications to latent variables. Forthcoming in Structural Equation Modeling. Your model is more complex because of the multiple indirect effects. You may get away with considering the latent response variables y4* and y5* as the relevant DVs which is ok with MLR. I would not worry about bootstrapping unless your sample size is low. If your mod variable can be categorized you can use multiplegroup modeling instead of XWITH and then do this using Bayes where no bootstrapping is ever needed. 

Shiny posted on Monday, August 25, 2014  2:08 pm



In your paper (page 8) it said: a*b effect is only valid for the underlying continuous latent response variable y*, not for the observed categorical outcome y itself. Does it mean I can not use MODEL CONSTRAINT and specify NEW (ab) and ab=axb, if I use original categorical y? Must binary y be converted into y*? 2. If so, how shall i modify in d original syntax? Shall I write something like: CATEGORICAL =y4 y5; DEFINE y4 = y4* y5=y5*??? Then change the original path y4 (binary) on y3 into y4* on y3? 3. Can I use ANYLSIS: ESTIMATOR IS WLSMV AND BOOTSTRAP instead of bayes in multiple groups? 4. I did a multiple Group Analysis to test if the mediation effect differs across two Groups(Group H, Group L). Input: MODEL CONSTRAINT: NEW(AHBHDH ALBLDL) AHBHDH=AH*BH*DH;! Indirect effect in group H ALBLDL = AL*BL*DL; !indirect effect in group L DIFF = AHBHDH  ALBLDL; Output (Bootstrap 5000) AHBHDH 0.531 0.425 0.376 0.166 0.030 0.006 0.042 ALBLDL 0.320 0.241 0.199 0.047 0.032 0.054 0.093 DIFF 11.874 6.308 4.536 0.884 0.311 0.520 1.160 I can see in group H, there is an indirect effect at 95% CI, yet this indirect effect does not exist in group L. However the difference test includes 0. does the indirect effect differs across groups? 


2. You can still use a*b when the continuous latent response variable is considered the distal outcome. 3. Yes. 4. No. Think of it this way. You have 2 estimates and you have zero that you can line up as: 0.166 0.047 0 The value 0.166 is significantly smaller than zero but not significantly smaller than 0.047 because 0.047 is closer to 0.166 than zero is. 

Shiny posted on Monday, August 25, 2014  3:03 pm



Thank you very much for your prompt and helpful answer, Dr. Muthen. I Need a bit more Explanation of the 1st Point from your side. To simplify, let me just use a simple Mediation model(xmy). If I use a categorical y, what can I do in mplus to test Mediation? Use IND function but not the a*b? If I want to use a*b, according to your answer, it shall be y*? Would you be so Kind to give me a clue how to create y* in mplus? Thank you indeed! 

Shiny posted on Wednesday, August 27, 2014  12:37 pm



Dear Dr. Muthen, could you pls tell me how to code y* (continuous latent Response variable) in mplus? I have an observable binary y (not latent). Shall i simply replace y with y*? I have not found related script. Thank you for your help! 


You don't have to create y*. If you use WLSMV then a*b refers to the effect on y*. So all you have to do is use WLSMV. 

Shiny posted on Wednesday, August 27, 2014  3:18 pm



That is great to know, since I did use WLSMV already. Is the coefficient a probit Regression weight or a normal Regression weight (if this is a y*)? In multiple Group Analysis, can I do the same wald test or chi difference test, working with constrained or free Parameters of y*, like treating it as a continous variable, once WLSMV is specified? Thank you very much for your helpful comment! 


Q1. a*b is a probit regression coefficient when you consider y to be the DV and it is a linear regression coefficient when you consider y* to be the DV; so the same coefficient plays two roles. Q2. Yes 

Shiny posted on Wednesday, August 27, 2014  4:43 pm



Thank you for your answers, I really appreciate them! 

Winnie Yang posted on Tuesday, November 11, 2014  4:59 am



Dear Drs Muthen, I am running a mediated moderation model. HP(X)>EP(M)>JS(Y). age as the moderator (W), HP, EP and JS are all latent variables, age is collected by asking participants to fill in their age ,so I believe that would be an observed variable.I have 4 questions below: 1. When creating a interaction variable, do I use XWITH command? I know that XWITH is suitable for latent variables only, while HP is a latent variable, Age is not. would XWITH still be right? 2. Assuming that I should use XWITH, I have the following syntax, do they look correct? ANALYSIS: estimator = ml; type = random; ALGORITHM=INTEGRATION; MODEL: HP BY HP101HP106; EP BY EP101 EP102 EP103 EP104R EP105 EP106R; JS BY JS101JS103; HCPxAGE  HCP XWITH AGE; JS ON EXP(B1) HCP AGE HCPxAGE; EXP ON HCP(A1) AGE HCPxAGE (A3); MODEL CONSTRAINT: new(IND W); W=1; IND=(A1+A3*W)*B1; 3. In terms of interpretation, if IND shows to be significant (p <.05), does that suggest then that W is a significant moderator? Or I would need to look at other areas for determination? 4. My model is actually more complicated than this. As a whole, I have 4 outcome variables and 2 independent variables and 2 mediators for each IV. Can I run it altogether then?Thanks! 


1. XWITH can be used for 2 latents or 1 latent and 1 observed. 2. Looks ok, but don't say AGE HCPxAGE (A3); because you can have only one parameter labeled per line. 3. Look at our website under Mediation (left margin of the home page)and you find the document Loop plot for ex 3.18 Make sure you understand this before going on with your analyses. If needed, read the Preacher, Rucker Hayes article we refer to in the UG. 4. Only after you got the simpler models under your belt. 


Hello, I am running a sem model and want to test both moderation and mediation effects as follow m = x w xw; y = x m w xw mw; Y: continuous; M: dichotomous; X and W both categorical (4 modalities each); Using multi group I have an estimate (of X and M) for each category of W, although it s not clear to me how to proceed to test XW and MW (i guest i should compare estimates of X (and estimates of M) among the W'subgroups)? Could you please give me some insights? Thank you 


With W as the grouping variable you want to test that the slopes of Y on M and M on X are the same across groups; that's testing the moderation. Make sure that the Y intercept is different across groups and that the M intercept is different across groups. Note also that a dichotomous M calls for special considerations. See the paper on our website Muthén, B. & Asparouhov T. (2014). Causal effects in mediation modeling: An introduction with applications to latent variables. Structural Equation Modeling: A Multidisciplinary Journal, 22(1), 1223. DOI:10.1080/10705511.2014.935843 You may also/instead consider WLSMV estimation where M* instead of M is the relevant mediator (see my 2011 paper referred to in the paper above to explain this). 


thank you very much. Yes I want to test moderation effect. But I had a mistake in my previous post. Y is actually categorical (5 categories). As suggested I used the WLSMV estimator. To test Y intercept I defined a restricted model in which the paths are constrained to be equal across the groups for X, M and W. M on x w; Y on m (1) x (2) w (3); ! As y is categorical I fixed each threshold as follow [Y$1@2 Y$2@3 Y$3@4 Y$4@5]; 1 I am not sure if the syntax is right? 2 should I only fix the Y intercept? Or both? Then I used DIFFTEST to compare the unconstrained model and the restricted one. Thank you 


Sorry to post it twice it seems like it didnt work the first time. thank you very much. Yes I want to test moderation effect. But I had a mistake in my previous post. Y is actually categorical (5 categories). As suggested I used the WLSMV estimator. To test Y intercept I defined a restricted model in which the paths are constrained to be equal across the groups for X, M and W. M on x w; Y on m (1) x (2) w (3); ! As y is categorical I fixed each threshold as follow [Y$1@2 Y$2@3 Y$3@4 Y$4@5]; 1 I am not sure if the syntax is right? 2 should I only fix the Y intercept? Or both? Then I used DIFFTEST to compare the unconstrained model and the restricted one. Thank you 


I don't understand your setup. We talked about a multigroup analysis, grouping on W. But your input doesn't show that, nor any interactions with W. And I don't know why you fix the Y thresholds. I think the thresholds change across groups as the default so no need to mention them. 


thank you as i defined w as a grouping variable, i remove the interaction XW and MW in the equations. Obviously it was not the good thing to do. I am not sure how to proceed to test "Y intercept and M intercept" across groups as suggested. could you please give me some more details thanks again 


hi, here is my syntax : usevariables are y x m w; grouping is w (0=never 1=one 2=two 3=always) ; categorical are m y; Analysis: type=mgroup; difftest=deriv.dat; !from the unconstrained model ; estimator=WLSMV; model: M on x w; Y on m (1) x (2) w (3); how could i improve it to thank you 


When you have Grouping = w... you should not include w in the Model statements. See Topic 1 of our course on our website to get the basics. Ignore the intercepts for now. 

Riza Casidy posted on Wednesday, March 04, 2015  7:10 am



Hi I am attempting to use the multiple group analysis in Mplus to test for moderated mediation with a categorical moderator, I would like to test whether an indirect effect differs between two subsamples (group a & group b). The IDV, DV, and MV are all latent, continuous variables For each group, I requested the indirect effect by using the model constraint command. GROUPING IS UNI (0=group a 1=group b); MODEL: PS by Q6_1 Q6_2 Q6_3; SAT by Q8_1 Q8_2 Q8_3; AO by Q18_1 Q18_2 Q18_3; SAT ON PS; PS ON AO; MODEL DEAKIN: PS by Q6_1 Q6_2 Q6_3; SAT by Q8_1 Q8_2 Q8_3; AO by Q18_1 Q18_2 Q18_3; SAT ON PS (p1a); PS ON AO (p2a); MODEL CONSTRAINT: NEW (ind_1); Ind_1 = p1a*p2a; MODEL UNIMELB: PS by Q6_1 Q6_2 Q6_3; SAT by Q8_1 Q8_2 Q8_3; AO by Q18_1 Q18_2 Q18_3; SAT ON PS (p1b); PS ON AO (p2b); MODEL CONSTRAINT: NEW (ind_2); Ind_2 = p1b*p2b; MODEL CONSTRAINT: NEW (diff); diff = ind_1ind_2; Is my method above correct? Did I miss anything? Do I have to constrain the latent variable as well? How do I do that? I would like to be sure. Thank you. 


You also need to make sure you have a sufficient degree of measurement invariance across groups for your latent variable indicators. 


Hi there, I'm trying to run the following model: A > B > C Where A>B and B>C are both moderated by D and A = Categorical (3 different conditions) B = Continuous (mediator) C= Continuous (outcome) D = Continuous (moderator) Could you advise on what the input should be? Thank you! 


Create products of variables (interactions) using DEFINE. Assuming 3 categories of A and therefore 2 dummy variables A1, A2: A1D = A1*D; A2D = A2*D; BD = B*D; and add B ON AD1, AD2 in the B regression and add C ON BD in the C regression. 

Jordan posted on Tuesday, April 21, 2015  8:28 pm



Hello, I am attempting to run a moderated mediation model using SEM. I have been using the XWITH command to create the interaction term, and asking for indirect effect estimates using the MODEL CONSTRAINTS, as below. However, I do not know what to input for the question marks. I would like to see the indirect effect conditional upon the moderator at 1SD, mean, and +1SD; but since my moderator is latent, I'm not sure what to input. I tried coding like this: [moderator] (zmean); moderator (zvar); ...and then simply inputting "zmean+sqrt(zvar)", for example to get +1SD. ...but the model wouldn't estimate the mean...so this doesn't appear to work. Can you tell me what I should input in place of the question marks below if my moderator is latent and I"m using the XWITH command? MODEL CONSTRAINT: new (ind1ind3); ind1=(a1+a3*(?)) * b1; ind2=(a1+a3*(?)) * b1; ind3=(a1+a3*(?)) * b1; 


Unless you have multiple groups or time points, latent variables have mean zero. The SD is the square root of the modelestimated latent variable variance. Taken together, that gives you the ? 

Jordan posted on Wednesday, April 22, 2015  4:33 pm



Got it. Makes sense. Thanks for the help! 


Hi I am testing a ML mediated moderation, first link moderated by a group (aggregated) var. I might be mislabeling the coefficients. Assuming a1 is the relationship IV(x) to med(m); a2 mod(w) to med; a3 is the interaction on med; b1 is the my effect; cdash1 is the direct effect xy; I run the model below but model constraint results suggest this is not right. Also, is it ok to use the coefficients obtained in the between part of the model? I assumed so given that an L2 moderator can only influence the between level variance of an L1 variable... Usevariables = x m w y; Cluster = team ; between = w ; within = ; Analysis: Type = Twolevel random; Estimator = ML; MODEL: %Within% Sm ON x; y ON m! SHOULD THIS BE (b1) instead? %Between% S ON w (a3);! CORRECT? CTF ON w (a2); [S] (a1);! CORRECT? [y] (b0); y ON m (b1) ; y ON x (cdash1); S WITH x; MODEL CONSTRAINT: NEW(LOW_w HIGH_w CIND_LO CIND_HI TOT_LO TOT_HI dif1 dif2); LOW_W = 2.77; HIGH_W = 3.74; ! cond ind CIND_LO = a1*b1 + a3*b1*LOW_W; CIND_HI = a1*b1 + a3*b1*HIGH_W; dif1 = CIND_HI  CIND_LO; ! cond tot TOT_LO = CIND_LO + cdash1; TOT_HI = CIND_HI + cdash1; dif2 = TOT_HI  TOT_LO; 


SORRY, in the post above, by CTF is meant 'm', so %Between% ... CTF ON w (a2); should read %Between% ... m ON w (a2); 


One question is at which level you want the mediation  what does your research question say? If level2 is the focus, why not say %Within% y on m x; m on x; %Between% y on m (b1); m on x (a1) w(a2); inter  x XWITH w; m on inter (a3); etc. 


Thank you for your very swift reply, x is a level 1 var, w is level 2 var, so I was trying to examine the crosslevel interaction, but in essence I would like to understand the underlying logic to model both between and within variance when testing for cross level interactions so i can best decide when one or the other is most suited * In any case, I have tried to test the proposed syntax, but obtained the following error; *** ERROR in MODEL command Interactions declared on the between level require numerical integration. Add ALGORITHM=INTEGRATION to the ANALYSIS command. I have added this ALGORITHM=INTEGRATION, and obtained then the following error *** ERROR in MODEL command The XWITH option is not available for observed variable interactions. Use the DEFINE command to create an interaction variable. Problem with: INTER  X XWITH W  what would you suggest? * finally, in the syntax proposed, should the second line in the between read 'w on m (a2)'? Otherwise I am missing something. Many thanks, 


w (a2) is a continuation of the m on line above  look at the the semi colon. For your question, send output to support. See also slides 8085 of our Topic 7 short course handout. 


apologies, had missed that absent ; in the previous line.. I have already gone through the slides and associated recorded video, as well as chapter 9 in the manual but am afraid i was still unable to figure this out  I have sent the material and license. Thank you very much, claudia 


Dr. Muthen, I would like to test moderated mediation in which sex moderates the B path (asdom3>fsdom3) in the mediation: group>asdom3>fsdom3. I also want the model to estimate the mediation hifreq2>asdom3>fsdom3. hifreq2, sex and group are binary. Indicators of latent variables are continuous. Is my desired model possible? If so, is adding MODEL CONSTRAINT commands for indirect effects to the existing model below (which only includes the interaction) the recommended syntax? Thank you. CLASSES = c(2); KNOWNCLASS IS c (group=0 group=1); Model: %overall% asdom3 by as23_r as24_r as25_r as26_r as27_r as28_r; fsdom3 by fs23_r fs24_r fs25_r fs26_r fs27_r fs28_r; as23_r as24_r as25_r PWITH fs23_r fs24_r fs25_r; as26_r as27_r as28_r PWITH fs26_r fs27_r fs28_r; int  sex XWITH asdom3; fsdom3 ON hifreq2 sex asdom3 int; asdom3 ON hifreq2 sex; sex with hifreq2; [asdom3@0]; [fsdom3@0]; %c#2% fsdom3 ON hifreq2 sex asdom3 int; asdom3 ON hifreq2 sex; sex with hifreq2; [asdom3]; [fsdom3]; [as24_r fs27_r]; as23_r as24_r as25_r PWITH fs23_r fs24_r fs25_r; as26_r as27_r as28_r PWITH fs26_r fs27_r fs28_r; Analysis: Type=Mixture Random; Algorithm=integration; 


I think it could be more easily done by creating a 4class Knownclass c variable using the combination of group and sex. Then you have full control over how the slopes and intercepts should vary across those 4 categories. 


I am unsure how the indirect effect of group or sex should be tested in this recommended approach because once considered as a KNOWNCLASS variable, group and sex will not appear in the %overall% model syntax which seems necessary for MODEL CONSTRAINT to request the indirect effects. I am a beginner and do really appreciate the extra clarification. Thank you again. 


If you are a beginner, perhaps it is easier to not get into mixture Knownclass at all. Use XWITH to get "int" as you have done for the m>y moderation by sex, use sex as a binary x variable and use "group" as a binary x variable. Then you get your moderated indirect effect as usual: a*b+g*a*z, where a and b are the usual ones, g is the slope of fsdom3 regressed on int and z is the sex moderator (I hope I got that right; this is essentially Model 3 of Preacher et al, 2007). 


Thank you. Is this still viable if I am also interested in testing the sex X asdom3 interaction across groups (3 way interaction)? I don't know why my model below receives the new error "One or more variables have a variance greater than the maximum allowed of 1000000." Model: asdom3 by as23_r as24_r as25_r as26_r as27_r as28_r; fsdom3 by fs23_r fs24_r fs25_r fs26_r fs27_r fs28_r; as23_r as24_r as25_r PWITH fs23_r fs24_r fs25_r; as26_r as27_r as28_r PWITH fs26_r fs27_r fs28_r; sXas  sex XWITH asdom3; sXasXg  group XWITH sXas; fsdom3 ON hifreq2(Beta4); fsdom3 ON sex (Beta2); fsdom3 ON group (Beta5); fsdom3 ON asdom3(Beta1); fsdom3 ON sXas (beta3); fsdom3 ON sXasXg(Beta6); asdom3 ON hifreq2(gamma2); asdom3 ON sex(gamma1); asdom3 ON group(gamma3); sex with hifreq2 group; hifreq2 with group; !Model constraint: ! NEW (INDhif INDg); ! INDhif=(gamma2*Beta1)+(gamma2*Beta3)...; ! INDg=.... 


Please send output with this question to support. 


Hello, I am doing a moderated mediation (code below) with categorical moderator (ethnicity) split into 5 dummy variables. CISRHigh is a binary mediator, anyserv is a binary outcome. WLMSV estimation is used. yw1 to yw5 (mediator*ethnic group) created under the DEFINE command. Can you tell me how to test the difference between indirect effects using the model constraint command? Thanks, Dharmi Analysis: Type = RANDOM; Model: CISRhigh on positive; CISRhigh on lacksupp; CISRhigh on White; CISRhigh on Irish; CISRhigh on BlackCaribbean; CISRhigh on Bangladeshi; CISRhigh on Indian; xw1  lacksupp XWITH White; xw2  lacksupp XWITH Irish; xw3  lacksupp XWITH BlackCaribbean; xw4  lacksupp XWITH Bangladeshi; xw5  lacksupp XWITH Indian; xw6  positive XWITH White; xw7  positive XWITH Irish; xw8  positive XWITH BlackCaribbean; xw9  positive XWITH Bangladeshi; xw10  positive XWITH Indian; CISRhigh on xw1; CISRhigh on xw2; CISRhigh on xw3; CISRhigh on xw4; CISRhigh on xw5; CISRhigh on xw6; CISRhigh on xw7; CISRhigh on xw8; CISRhigh on xw9; CISRhigh on xw10; anyserv on CISRhigh White Irish BlackCaribbean Bangladeshi Indian; anyserv on yw1; anyserv on yw2; anyserv on yw3; anyserv on yw4; anyserv on yw5; 


You label the parameters in the MODEL command, forexample: Model: CISRhigh on positive; CISRhigh on lacksupp; CISRhigh on White (p1); CISRhigh on Irish (p2); CISRhigh on BlackCaribbean; CISRhigh on Bangladeshi; CISRhigh on Indian; and create a difference parameter in MODEL constraint: MODEL CONSTRAINT: NEW (diff); diff = p1  p2; 


In your case, you would need to label the parameters involved in the indirect effects and create the two indirect effects in MODEL CONSTRAINT along with the difference parameter. 


Thanks Linda  I have done that now. However, I have just realised that I am using MLR estimation because WLSMV is not available when using XWITH for latent variable interactions. Does this mean that I need to change my model setup because my mediator is binary? I have read the forum regarding binary mediator being treated differently when used as independent/ dependent variable when using MLR. Thanks, Dharmi 


The combination of XWITH and a binary mediator is tricky:  XWITH is only available for ML  ML with a binary mediator needs to use the new counterfactuallydefined direct and indirect effects  the counterfactuallydefined effect option is not available with XWITH (although it is available for latent variables) I'm not sure what to suggest until we've generalized this. 


Dear Dr. Muthen, I want to investigate if a mediation is moderated by a dichotomous variable (coded 0 and 1). I opted for the multiple comparisons option and both the a and bpath are significant for each group, with a moderation on the bpath. As I am interested in indirect effects as well, I ran model 5 from Hayes (2007, Figure 2) with the syntax below. My results indicate no apath moderation and a bpath moderation which is in line with the multiple group comparison. However, both a1 and b1 are not significant anymore. This seems odd to me, as both analyses should yield in the same findings? Many thanks for your help! Model: M ON X (a1); W XW (a3); Y ON M (b1) X W XW MW(b2); MODEL CONSTRAINT: NEW(eff1 eff2 modval1 modval2); modval1 = 0.00; eff1=(a1+a3*modval1)*(b1+b2*modval1); modval2 = 1.00; eff2=(a1+a3*modval2)*(b1+b2*modval2); output: stand; cinterval (bcbootstrap); 


Hello, Thanks for the information. Do you think it is worth doing a multigroup mediation analysis instead? I haven't done multigroup analysis before, so I am unsure as to whether it would allow a CFA + mediation analysis (binary mediator) with WLSMV estimation. Thanks, Dharmi 


I ran into the same problem as posted above, in such that my mediated moderation using the syntax by Preacher and Hayes (binary moderator) seemingly yields different results than a multigroup approach. Could you point me in a direction where to search for the problem? I add the syntax underneath. Thank you and kind regards, Joyce I S  mECBIis1@0 mECBIis2@1 mECBIis3@2; I WITH S; S ON Con; MECBIIS1 ON I; MECBIIS3@0; Im Sm  M_NEGC1@0 M_NEGC2@1 M_NEGC3@2; Im WITH Sm; Sm ON Con (a1); S ON Sm (b1); M with Sm; ConxM with Sm; MxSm  Sm XWITH M; S ON MxSm (b2); MODEL CONSTRAINT: new (ind wmodval); wmodval = 1; ind=a1*(b1+b2*wmodval); 


Lisa, I don't know what you mean by "multiple comparisons". I thought you meant multiple group, but it doesn't seem like it. Regarding a1, b1 significance, note that these are main effects and behave differently when you have the interaction. 


Dharmi, WLSMV can do this, but the mediator will be the continuous latent response variable behind the binary observed variable. Not sure how you think multiplegroup replaces XWITH. 


Joyce, Send the 2 outputs that you compare to support along with license number. 


Thanks Bengt. At the moment, I am using XWITH for an interaction between latent variable and ethnic group for a moderated mediation. By using multigroup, I could get rid of this interaction in the moderated mediation and estimate a multigroup model instead. Dharmi 


It was not clear that one variable was categorical in the interaction. You can approach this as a multiple group analysis using ethnicity as the grouping variable. 


In the new MODEL INDIRECT language for moderated mediation you provide an example (3.18) for moderation of the X > M path: MODEL: y ON m xz z; m ON z xz x; If the M > Y path is moderated, would this be the correct model: MODEL: y ON m mz z; m ON x; or would it be: MODEL: y ON m mz z x; m ON x; Thanks! 


In the new, October 2015, Version 7 User's Guide which is on our website, ex 3.18 has for your first model the more common approach y ON m x z; m ON x z xz; and if you want to moderate the M>Y path I would say: y ON m mz z x; m ON x; (in the last line you may want to add z in case it also influences m). 


Many thanks! A follow up question: Release 7.4 handles ordinal mediators using the IND command but the moderated mediation approach in my previous question seems to not accept an ordinal M. Is there a workaround for moderated mediation with a categorical/ordinal mediator? 


Yes, the counterfactual MOD is not yet available for ordinal mediator. You would have to use WLSMV or Bayes viewing the mediator as a continuous latent response variable, not using MOD, but using Model Constraint in line with UG ex 3.18. 


Someone asked me for help recently with an example where they have a pure moderator of the relation between a predictor and a mediator. Let Y be the outcome, X be the predictor, M be the mediator, and Z the moderator. In my mind, if Z is a pure moderator of the relation between X and M, then the specification should be: Y on X M; M on X XZ; However, in all the examples they found, like 3.18 in Mplus, as well as in Hayes (2015), Preacher et al. (2007), and Bengt's example above, the syntax is Y on X M Z; M on X Z XZ; It seems like in this case, Z is not purely a moderator but also has direct effects on M and Y, although in some articles it is illustrated as simply being a pure moderator, so maybe I'm missing something. Of course I don't want to steer this person wrong and I'm not really familiar with this literature, but am I correct to say that in the first example, Z is a pure moderator (between X and M) whereas in the second example it is a moderator with additional direct effects on M and Y? 


I don't think there are any firm rules here. The statement M on X Z XZ; uses the idea that if the interaction XZ is needed then the main effects X and Z should also be included. Perhaps that is often needed in practice in the sense that the effect of Z is significant. Including Z in the statement Y on X M Z; is perhaps less convincing, but again Z may often be significant. 

Sam R posted on Tuesday, December 01, 2015  8:37 am



Hi there, I'm trying to test moderated mediation using the approach described in Preacher, Rucker & Hayes (2007) in Figure 2 model 2 so that I can test moderation in path A. My model is a manifest and the moderator is a binary 0/1 variable. I'm a graduate student and still learning so bear with me, but I've done some searching on the forum before drafting syntax. My input is as follows: usevariables = W_AG X_SCI M_S1 Y_Rat; missing = all(999); Grouping = W_AG (0=Low 1=High); analysis: type = general; model: Y_Rat on M_S1(b1_Low); Y_Rat on X_SCI; M_S1 on X_SCI (b2_Low); model constraint: New (ind_Low); ind_Low = b1_Low*b2_Low; model: Y_Rat on M_S1(b1_High); Y_Rat on X_SCI; M_S1 on X_SCI (b2_High); model constraint: New (ind_High); ind_High = b1_High*b2_High; model test: ind_Low = ind_High; Output: sampstat stdyx; This input produces an error in model constraint command (label is ambiguous) for the label B1_Low I know this is likely an issue with where I've placed the parameter label but any input would be greatly appreciated  Thank you for all of our work updating with these posts! 


I think the issue may be that you say Model: twice, whereas you should say Model low: Model high: or follow UG ex 5.15. Also, with a binary moderator you can do this more easily as a singlegroup analysis with a dummy covariate and using Define to create a product. 

Chan Chen posted on Tuesday, January 19, 2016  10:31 pm



Hi, here is my moderated mediation model categorical dependent variable: USEVARIABLES = x y m w mw; CATEGORICAL = y; DEFINE: xw = x*w; Analysis: estimator = WLSMV; BOOTSTRAP = 10000; MODEL: Y on M (b1); Y on X (cdash); M on X(a1); M on W (a2); M on XW (a3); MODEL CONSTRAINT: IND_LOWw = a1*b1 + a3*b1*LOW_W; IND_MEDw = a1*b1 + a3*b1*MED_W; IND_HIw = a1*b1 + a3*b1*HIGH_W; TOT_LOWw = IND_LOWw + cdash; TOT_MEDw = IND_MEDw + cdash; TOT_HIw = IND_HIw + cdash; PLOT(LOMOD MEDMOD HIMOD); LOOP (XVAL, 0,8,0.1); LODMOD = IND_LOWw*XVAL; MEDMOD = IND_MEDw*XVAL; HIMOD = IND_HIw*XVAL; PLOT: TYPE = PLOT2; OUTPUT: Cinterval (bcbootstrap); But the output showed an error as "Variances for categorical outcomes can only be specified using PARAMETERIZATION=THETA with estimators WLS, WLSM, or WLSMV.” As you could see in the model that I have identified the estimator as WLSMV; why could the model not coverage? Thank you! 


Please send the output and your license number to support@statmodel.com. 


Note also that these effects are not the optimal ones for a binary Y. See instead the paper on our website: Muthén, B. & Asparouhov, T. (2015). Causal effects in mediation modeling: An introduction with applications to latent variables. Structural Equation Modeling: A Multidisciplinary Journal, 22(1), 1223. DOI:10.1080/10705511.2014.935843 

Chan Chen posted on Friday, January 22, 2016  7:26 am



thank you so much! is it possible to model a moderated mediation model with categorical dependent variable. If so, is there any topic note or paper I could reference? Thank you! 


Moderated mediation is described in that paper. 


To clarify your earlier response (Bengt O. Muthen posted on Friday, November 13, 2015  10:22 am): When you say use WLSMV or Bayes viewing the mediator as a continuous latent response variable, you mean not specifying the binary M as a categorical variable, correct? Somehow, when M is included in the list of categorical variables using WLSMV (using TYPE=COMPLEX for clustered data) the mod med LOOP PLOT makes sense, but when treated as a continuous variable the resulting plot looks very strange. 

chan chen posted on Friday, February 05, 2016  8:41 am



Thanks Shiko BenMenahem, I only specified Y as categorical variable, others are all continuous, and then I used WLSMV as the estimator since Y is categorical. My mediator is a continuous variable with 7 anchor point. 


Thanks, but the question was addressed to Dr. Muthén. 


You should specify M as categorical. 


Dear Dr. Muthen, I wanted to investigate a moderated mediation by model 14 of hayes. The total index of moderated mediation and the interaction(int1) appear to be nonsignificant. However, when I take a closer look to the conditional indirect effect, there are some significant specific conditional indirect effects. More specifically, the mediation effect is significant for a certain moderator value, but not for the other. Hence, I am wondering if I could still argue that some effects do present moderated mediation and discuss them? Thanks in advance, Emma 


You can easily do that model in Mplus and get a moderation plot with confidence intervals that show you for which moderator values you have a significant effect. 

Margarita posted on Thursday, February 25, 2016  6:36 am



Dear Prof. Muthén, I am new to moderated mediation, and although I managed to run the analysis in Mplus I am not quite sure if I am interpreting the results correctly. Are you aware of any references about how to interpret the Mplus output? Thank you 


The Mplus output for moderated mediation gives the usual results that are discussed in articles such as by Preacher and in books such as by Hayes. See also our Mediation page: http://www.statmodel.com/Mediation.shtml FYI  the Mplus team is wrapping up a book on mediation so later this year you'll have more guidance. If you have a specific question about the output, please ask. 

Margarita posted on Thursday, February 25, 2016  3:22 pm



Prof. Muthén thank you for your reply. I look forward to the book. I have a question, if you have the time. My understanding is that when the interaction terms are not statistically significant then we can conclude that there is not a moderation. Is that correct? I get nonsignificant interactions but some of the conditional indirect effects are significant. Is such a discrepancy expected? Thank you for your time 

Margarita posted on Thursday, February 25, 2016  3:38 pm



Apologies for reposting, I thought it would save you some time. Following my previous question, to be more precise, the bc confidence intervals showed that for some moderator values there is a significant effect. My question is, even though the interaction term was nonsignificant can I still conclude that for some moderator values there is actually an effect? Thank you again 


Yes, I think you can still conclude that for some moderator values there is an effect based on the CIs. The interaction term is often not significant due to low power unless the sample size is very big, so I think it can be dangerous to throw it out. 

Margarita posted on Saturday, February 27, 2016  10:45 am



That's great, thank you. May I ask one last question: If the model fit is poor, in my case x2 (9) = 2133.29, p < .001 CFI = .00 TLI = 1.73 RMSEA = .81 (.78.84), p <.001 would you suggest still reporting the statistically significant effects? I really appreciate your help. 


If you have moderation involving the mediator the usual tests of fit do not apply. If you are not in that moderation case, the bad fit precludes interpreting the results. 


Dear Prof. Muthen, maybe you can help me further with a question regarding model 14, as well? My data indicates a nonsignificant effect b2 between the moderating variable V and the outcome variable Y. Indirect effects and interaction effects are all significant. Is that mentioned nonsignificant effect a problem for my model? Thanks for your help, best regards from Germany. Michael 


Not a problem. The main effect of V on Y cannot be interpreted separately from the effect on Y by the M*V interaction. 


Hello I have some general questions regarding the indirect effects you obtain with the model indirect command: 1) To obtain reliable information on the significance of the indirect effects, do I have to specify a bootstrap analysis (under the analysis command) or can I interpret the pvalues directly from the output without performing bootstrap analysis? 2) If bootstrapping is preferred and I use the MLR estimator in my analyses, should I rerun my model with ML so that I can examine the indirect effects under bootstrapping? 3) what exactly is the significance test for indirect effect based on? All the best Johan 


You should use bootstrapping, for instance Bootstrap = 1000; and in the Output command you should say Cinterval(bootstrap); and then judge significance of the indirect effect by whether or not the bootstrap confidence interval covers zero or not. Often, the symmetric confidence intervals from MLR are similar to the bootstrap intervals but it is better to go by the bootstrap intervals. 


Thanks for your quick reply! Johan 


Hello, I am trying to test for differences in indirect effects following the procedures described by Hayes in his 2015 MRB paper. The moderator is a categorical variable with only two levels. One of the covariates only varies within one of the two levels that makes up the moderator variable, but it is critical to control for that covariate in the group in which it does vary. How can you set up the model to avoid errors related to no variance but still get a statistical comparison of indirect effects across levels of the moderator. (specifically, if I include the main effect term AND the interaction term in the model, there is zero variance, but including only one or the other isn't a problem, but obviously not completely controlling for that covariate). Thank you! 


Hello (reposting), I am trying to test for differences in indirect effects following the procedures described by Hayes in his 2015 MRB paper. The moderator is a categorical variable with only two levels. One of the covariates only varies within one of the two levels that makes up the moderator variable, but it is critical to control for that covariate in the group in which it does vary. How can you set up the model to avoid errors related to no variance but still get a statistical comparison of indirect effects across levels of the moderator. (specifically, if I include the main effect term AND the interaction term in the model, there is zero variance, but including only one or the other isn't a problem, but obviously not completely controlling for that covariate). Thank you! 


I think this is a good question for SEMNET. 

Eric Deemer posted on Thursday, May 12, 2016  12:07 pm



Hello, I'm also trying to determine which values of a latent moderator I should use to test the significance of an indirect effect. Dr. Muthen, in an April 2015 post you said, "Unless you have multiple groups or time points, latent variables have mean zero. The SD is the square root of the modelestimated latent variable variance. Taken together, that gives you the ?" Does this mean I could, say, do a 1factor CFA of the latent moderator, estimate the residual variance, and subtract the residual variance from 1 to get the explained variance? Then take the square root of the latter to get the SD? Thank you. Eric 


No. Your 1factor CFA gives an estimated factor variance. Take the sqrt of that to get the SD. 


Great, thanks so much. Eric 


Dear Dr. Muthen I am testing a longitudinal panelmodel (multigroup). First I arrived a parsimonious unigroup model and than tested whether paths were similar between subgroups (males/females). All testing of constraining went okay. However, if I constrain an indirect effect to be equal for subgroups, the results (xsquare and df)are similar to the model in which the indirect effect is freely estimated. Does Mplus allow for testing of constraints for indirect effects? I hope you have the time to answer this Gabriël 


How do you constrain the indirect effect to be equal across groups? 


Dear Dr. Muthen In my multigroup analyses, I first pasted the script of the unigroupmodel (containing constraints). Second i specified the grouping variable and than the models for both males and females. Than i started comparing paths between the male and female models by placing constraints. I gave the indirect effect in the model for males the same value (01) as in the model for females. model indirect: C_INT IND B_PV A_GNC (01); C_EXT IND B_PV A_GNC; C_INT IND B_GNC A_PV; C_EXT IND B_GNC A_PV; C_GNC IND B_PV A_INT; C_GNC IND B_PV A_EXT; C_PV IND B_GNC A_INT; C_PV IND B_GNC A_EXT; 


In your statements model indirect: C_INT IND B_PV A_GNC (01); the label (01) that you give is ignored. You can't test that way. You can use Model Constraint to express the indirect effect in each group and express the difference in indirect effects  that then gets a SE and thereby a ztest of the difference. 

Rick Borst posted on Wednesday, July 27, 2016  4:58 am



Dear Linda, Is there a way to make a moderator under the DEFINE command that exists of two variables which still have to be made by a factoranalysis under the MODEL command? Example: I want to make the variable under DEFINE: IndOrg = Org_rec*Ind_rec; But I make Org_rec and Ind_rec under the MODEL command. Now I receive the obvious error: Undefined variable used in transformation: ORG_REC 


The DEFINE command is for observed variables. Use the XWITH option for a latent variable interaction. 


Dear Linda & Bengt, Just got the book Regression and Mediation Analysis Using Mplus but could not find the model I am working on. I want to test a mediated moderation model using *latent variables* where the moderation effect is assessed via multigroup analysis as such variable is dichotomous. How do I test the conditional indirect effects when I use multigroup analysis having latent variables assuming I have metric invariance? 


You can piece that together from different parts of the book. The fact that the X, M, Y variables are latent does not complicate the setup. A latent mediator case is discussed in Section 8.6. Several types of moderated mediation is treated in Section 2.6 and multiplegroup mediation analysis is treated in Section 3.6. The Section 3.6 analysis uses a binary X variable as the grouping variable but this is can be changed to the moderator being the binary grouping variable. Section 3.6 shows how interaction effects (which is what conditional indirect effects come from) are expressed in terms of slope nonequalities across the groups. 

Tor Neilands posted on Thursday, September 08, 2016  10:36 pm



VanderWeele in "A Unification of Mediation and Interaction: A 4Way Decomposition", Epidemiology, 25(5), 749761, 2014, describes a counterfactualsbased approach to decompose the total effect of exposure X on outcome Y via mediator M through four effects: CDE, reference interaction (Int_ref), mediated interaction (Int_med), and pure indirect effect PIE. A colleague is seeking my help to obtain these four effects from analysis we've run in Mplus for a continuous exposure, continuous mediator, and continuous outcome with the model specification containing an interaction of X with M in line with Case 3, Figure 4.1 in Muthen, Muthen, and Asparouhov, 2016, p. 204. Can you tell me how to obtain the four quantities described above using Mplus? (Could it be as simple as Mplus already producing these same effects under different names?) Thanks so much, Tor Neilands 


The 2015 VanderWeele book Explanation in Causal Inference discusses this in the context of a model with XM interaction on pages 377 and 378. Top of page 378 shows how to express the 4 effects in terms of model parameters and values of a continuous exposure (X) variable. This can be done in Model Constraint which also gives you SEs by the Delta method. 

Tor Neilands posted on Tuesday, September 13, 2016  6:43 pm



Thanks, Bengt! Using the book chapter you referenced plus the article I cited (both cover pretty much the same ground it seems), I was able to reverseengineer Dr. VanderWeele's PROC NLMIXED SAS code from his article and book appendices into Mplus Model Constraint syntax as you suggested to compute the 4 decomposition effects based on the model parameters. I am grand mean centering all covariates C to compute effects at the means of the covariates. I am less clear on the advisability of grand mean centering X and M in performing an analysis of this type. For a standard linear regression with interaction, centering both X and M yields more interpretable main effects and it appears to make the counterfactual effects easier to interpret in this analysis, too. However, are there any reasons why one should one not center either X or M in this analysis? Thanks again and thanks, too, for setting up and being so attentive to Mplus Discussion  this is a tremendous resource for the research community. Tor Neilands 


I am glad it worked out. If this is a common request perhaps we should add it automatically to the printing of our counterfactual effects. In the meantime, if you like, please send me your Mplus input so that we can create a FAQ on it. I don't see a reason why one couldn't grandmean center X and M. 

Tor Neilands posted on Wednesday, September 14, 2016  8:54 am



I just sent along the Mplus input and output where the results match results generated in SAS using Dr. VanderWeele's sample SAS code. I very much like the idea of printing out these counterfactual effects in a future release of Mplus. I believe they add value and should not be too hard to obtain since most are a linear combination or, in the case of proportion mediated, ratios of effects or linear combinations of effects Mplus is already showing. I'm glad there is no reason not to center X and M. Centering X is working well in my application. I am rethinking centering M, though, because when I grand mean center M in my analysis, the interaction reference effect IntRef becomes zero and its coefficient is added to that of the CDE to alter the value of the CDE. Any further comments on this issue would be much appreciated. 


Thanks. I typically don't center M. 


Dear Drs. Muthen, I have a few questions about moderated mediation. I'm testing a model P>B>D, where P and B, and B and D paths are moderated by W; and B> D path is moderated by Q; All variables are latent with ordinal indicators. The questions are: 1) I am trying to estimate the indirect effects at specific values of moderators (e.g.at 2 s.d and 2 s.d.). I am somewhat new to Mplus, so I was wondering if the code looks right?! Model: P BY Pcal1 Pcal2 Pcal3 Pcal4; B BY Bwpb1 Bwpb2 Bwpb3 Bwpb4; D BY D1 D2 D3 D4; W BY Rss1 Rss2 Rss3 Rss4; Q BY Rpca1 Rpca2 Rpca3r Rpca4r; BW  B XWITH W; PW  P XWITH W; PQ  P XWITH Q; P@1; B@1; D@1; W@1; Q@1; D on B (b1); B on P (a1); B on PW (gamma1); B on PQ (gamma2); D on BW (gamma3); MODEL CONSTRAINT: NEW(LowModM1M2 HighModM1M2); LowModM1M2 = ((a1+gamma1*(2)+gamma2*(2))*((b1+gamma3*(2)); HighModM1M2 = ((a1+gamma1*(2)+gamma2*(2))*((b1+gamma3*(2)); Thank you Alex 


looks correct. 


Hi Bengt, Thank you SO MUCH. I have just a few follow up questions please. 1) With TYPE = RANDOM; ALGORITHM = INTEGRATION; standardised coefficients are not available. Would that be correct to simply constrain variance of all latent variables to 1 (hence s.d.=1) to obtain standardised direct and indirect effect coefficients? If this is the case, should I also constrain latent means to be 0 as well? 2) Since the indicators are ordinal (measured on a 5 pointlikert scale) but their respective latent variables are assumed to be continuous, if there a way to see how many data points are there associated with 2/2s.d. of each latent moderator variable in order to make a valid inference?! If e.g. it’s possible in Mplus to see distribution of a latent variable using percentiles? The reason I am asking this, is because ideally I want to avoid a situation that if I use e.g. 2/2s.d. mod values, but don't have enough data points to make valid inferences. 3) Is there actually a way to test if latent variables are indeed normally distributed or is it just an assumption? 4) I read in your new book on regression and mediation analysis in Mplus, that it is recommended to grandmean center moderator variables, would you recommend to grandmean center only moderators or all variables? Thank you Kind regards Alex 


1) We have a FAQ Latent variable interactions that shows the formulas Mplus uses for standardization with XWITH. If you fix factor variances at 1, this will refer to the residual variance for factors that are DVs, so this doesn't give standardized coefficients. 2) You can request Save = FS which means that you can look at factor scores. 3) No, there is not a good way to do this. You should view it as an assumption. 4) I am not sure I recommended that in the book  I wouldn't bother unless the interpretation needs it. 


Thank you very much for the clarification 


Dear Bengt, May I ask you a followup question regarding an earlier comment please. My post: September 27, 2016  4:54 am 2) Since the indicators are ordinal (measured on a 5 pointlikert scale) but their respective latent variable is assumed to be continuous, is there a way to see how many data points are there associated with 2/2s.d. of that latent moderator variable in order to make a valid inference?! If e.g. it’s possible in Mplus to see distribution of a latent variable using percentiles? The reason I am asking this, is because ideally I want to avoid a situation that if I use e.g. 2/2s.d. mod values, but don't have enough data points to make valid inferences. Your reply: 2) You can request Save = FS which means that you can look at factor scores. Per your suggestion, I have obtained factor scores. There are 4 columns corresponding to factor scores of each (ordinal) indicator. I am not exactly sure what to do now with the 4 factorscore columns in order to see how many data points are there associated with 2/2s.d. of a latent moderator variable? Do I need to combine the scores in some way or do something with each factor score column separately? I am sorry, if this is a very basic question. Thanking you in advance 


We need to see your output  please send to Support along with your license number. 

Anika Schulz posted on Thursday, November 10, 2016  12:15 am



I ran a moderated mediation analysis with latent variables formed with continuous indicators (X > M > Y with the pathway from X to M being moderated by W). The conditional indirect effects for low and high levels of the moderator both turned out to be significant. However, their confidence intervals overlap. I was wondering which test I should use to find out if the slopes differ significantly from each other. I used the following syntax (similar to Hayes’ model 7): 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 HIGH_W IND_LOWW IND_HIW); LOW_W = .72; HIGH_W = .72; IND_LOWW = a1*b1 + a3*b1*LOW_W; IND_HIW = a1*b1 + a3*b1*HIGH_W; OUTPUT: CINTERVAL (BCBOOTSTRAP); Thank you for your help. 


The two effects are not independent so looking at the overlap in confidence intervals is not correct. Instead, express as a New parameter their difference. 


Hello all, I am trying to conduct a power analysis (via monte carlo simulation on Mplus) to see how large a sample I would need to collect for a study. The hypothesized model is a moderated mediation model where the "b" path is moderated by a continuous variable I was wondering if there was any guidance I could receive in the best way to do so via Mplus (either through resources or syntax  I have read previous preacher papers but still find myself having difficulty conducting such an analysis). I have seen some code above but some of the numbers that were included in the code confused me Thank you all so much! 


To add to my question above, I have read over and tried to understand the Thoemmes, MacKinnon, & Reiser (2010) paper on power analysis for complex mediational designs using monte carlo methods, and the Mplus syntax makes sense for a mediation model. Upon introducing the moderator on the b path, I no longer understand how to complete the code to run on Mplus Thanks 


I think this book would be very helpful to you: http://www.statmodel.com/Mplus_Book.shtml See especially chapters 2 and 3. 

Daniel Lee posted on Wednesday, January 18, 2017  5:22 pm



Hi Dr. Muthen, I had a question regarding the Mplus code as seen in user manual (Example 3.18 ModeratedMediation). In your syntax, you did not include y on m x (the IV), but rather just y on m. When I ran with just y on m (and not: y on m x), the program did not yield any direct effects. I'm wondering if the direct effects are there in the output and I'm just missing it, or if it is acceptable to estimate thee models without direct effects. I only ask this as the "y on m" vs. a "y on m x model" reaps different results (e.g., effect sizes pr significance of predictors). 


I would use y on m x. 

sarah posted on Friday, February 03, 2017  9:39 am



My License number (STBML70008216) Hy , in my PhD i collected data from 74 people for ten working days ( daily measures design : daily measures are nested in individuals) . i like to test a moderated mediation model with my multilevel data CM=> independant variable=> mediator 1=>mediator 2=>performance ( DV) ( on the lower level( level1) The moderator is on level ( it was measured once and moderate all the relationship between variables on the level 1) Please i want to test such a multilevel moderated mediation model with Mplus ? can i have Mplus code ? please advice .thanks a lot for advance 


I believe you can do a suitable analysis in Mplus. But the question about which analysis is suitable is better asked on SEMNET. 

Saleh Moradi posted on Saturday, February 25, 2017  5:07 pm



Dear Drs Muthen, I want to run a mediated moderation model with a Count Data as an outcome. i.e., X>M>Y and W as the moderator, moderating the path between X and M. X, M, W and Y are all latent variables. X, M, and W are continuous and Y is count. I have been advised to use Poisson regression with count data instead of OLS, or zeroinflated negative binomial regression for my specific case with lots of zeros. I have been searching for the most convenient platform to run this model. Is it possible to run this model in Mplus? If yes, can you possibly walk me through this, considering that I am a novice user of Mplus? 


Mediation with a count Y is described in Chapter 8 of our new book. Mplus provides the correct, counterfactuallydefined direct and indirect effects for this case. You say that Y is a count variable but you also say that it is a latent variable. Latent variables for X, W, and M is not an issue. 

AllisonG. posted on Tuesday, February 28, 2017  3:26 pm



I am doing moderated mediation model with a dichotomous IV  Race, latent mediator  Cognitive Health (composed of 3 cont variables), latent moderator  Social Health (composed of 3 cont variables), and a latent DV  Distress (composed of 2 cont variables). First, I don't think my syntax accounts correctly for this model. Suggestions would be greatly appreciated. DEFINE: RaceSocH = Race*Social Health; MODEL: ! Latent mediator Optimism ON Cognitive Health; Engagement ON Cognitive Health; Pain Catastophizing ON Cognitive Health; ! Latent moderator Social Support ON Social Health; Resource Loss ON Social Health; Social Undermining ON Social Health; ! Latent DV Depression ON Distress; PTSD ON Distress; Cognitive Health ON Race; Distress ON Cognitive Health Race; Compared to other IVs, it seems odd to control for effects of Age, Education, Marital Status, or Health on Race. How do you recommend adding those as control variables? Thank you. 


I think you should pose this question on SEMNET. 


Hello Dr. Muthen I want to test a moderated mediation model with an observed IV (actual motor competence), 1 latent moderator (autonomous motivation), 2 latent mediators (perceived motor competence and competence satisfaction), and an observed DV (weekly time spent in organized sports). As I'm using a combination of latent and observed variables, I'm not sure which commando for the analysis I should use. I want to use bootstrapping so I thought the analysis below might be correct but I'm not sure: ANALYSIS: TYPE = GENERAL RANDOM; ESTIMATOR = ML; ALGORITHM = INTEGRATION; BOOTSTRAP = 10000 Furthemore, as I have a latent moderator but an observed IV, I have doubts whether I need to use the XW  X XWITH W command or rather the XW = X*W for the interaction. And finally, for the first mediator, I would use the following code: Y ON M (b1); M ON X (a1); M ON W (a2); M ON XW (a3); Which code should I use for the second moderator? Y ON M (b2); M ON X (a4); M ON W (a5); M ON XW (a6);? Thank you for any help you might be able to provide. Kind regards 


Yes, use XWITH. You have 2 mediators so use M1 and M2 (not the same M). 


Thank you! 

Nini Wu posted on Thursday, April 20, 2017  3:23 am



Hello£¬I am testing a path model ABCD and there is direct effect from A to C and A to D . And I expected E £¨parent gender£©moderated the path from A to B, while F moderated the path from A to D £¨child gender£©. below is my detailed syntax£¬could you point me to what I am wrong? Define: AE=A*E; AF=A*F; Analysis:bootstrap=1000; model: B on A(a1) E(a3) AE(a2); C on B (b1) A; D on C(c1) A(d1) F(d2) AF(d3)£» Model Constraint: New(ind1 ind2 Zmodval); Zmodval=1; ind1=a1*b1*c1+a3*Zmodval*C1 ind2=d1+d3*Zmodval; output:Cinterval(BCbootstrap); For the output file, it displayed below: *** WARNING in MODEL command Variable is uncorrelated with all other variables: F *** WARNING in MODEL command Variable is uncorrelated with all other variables: AF *** WARNING in MODEL command At least one variable is uncorrelated with all other variables in the model. Check that this is what is intended. *** ERROR in MODEL CONSTRAINT command Only one sign (=, > or <) is allowed for each statement. Problem with the following statement starting with: IND1. 


Please send your full output to Support along with your license number. 

Anne Kuhn posted on Thursday, June 01, 2017  6:19 am



Hello, for days im trying to figure out how to do the analysis for my model on SPSS model 7. I have the following model: X (two conditions that have been manipulated; one group had to read one story about specific informations of sustainable products; second group received only general information) M (attitude  measured on a 7 point scale) Y (buying intention  measured on a 7 point scale) W (personal values a person has  2 groups= high values and low values) How can i do the test in Spss. Right now the problem is how to see the difference of both conditions in the output. I want to test the difference and i want to see that condition 1 which is the specific information is stronger than condition 2, but i have not been able to do this with model 7. Best regards, Anne 


This is a forum for only Mplus questions. 

George Pro posted on Monday, July 24, 2017  12:16 pm



Hello world, Looking for thoughts and critique. Main outcome ('multi') has 3 levels. Focal predictor ('ethra') has 3 levels. The model is mediated by 'insur' and 'pover'. I'm also looking at ethra*femal. How do I define a reference group for a categorical IV with KnownClass? My code below generates this error: Unknown class label: %ETHRA#1% %ETHRA#2% %ETHRA#5% FEMAL; Usevariables are femal ethra insur pover multi weigh xz; Categorical are insur pover; Nominal is multi; Classes is ethgp (3); Knownclass is ethgp (ethra=1 ethra=2 ethra=5); !Stratification = strat; Weight = weigh; Define: xz = ethra*femal; Analysis: type = mixture; Model: %OVERALL% multi#1 multi#2 on insur pover xz (b) %ethra#1% %ethra#2% %ethra#5% femal; insur on %ethra#1% (reg1) insur on %ethra#2% (reg2) insur on %ethra#5% (reg3); femal xz (int1); pover on %ethra#1% (reg4) pover on %ethra#2% (reg5) pover on %ethra#5% (reg6); femal xz (int2); Model Constraint: plot(indirect); loop(mod,0,1,1); indirect = b*(reg1 + reg2 + reg3 + reg4 + reg5 + reg 6 + int1mod + int2*mod); 


Please send the output and your license number to support@statmodel.com. 

steve posted on Thursday, July 27, 2017  3:00 am



Dear Professors, I am trying to estimate a moderated mediation analysis following the example of case 3 as described in your book "Regression And Mediation Analysis Using Mplus". I have two short questions: 1) On page 115, Table 2.28: Does the estimate of .950 (Tot natural IE) refers to the conditional indirect effect when X = 7 (versus the mean 5)? 2) Accordingly, is it safe to substitute the values for x in the model indirect statement (Table 2.26, p.113) with any given values of interest, e.g., high values of x vs. low values of x; or is it mandatory that the two values in the statement need to reflect one standard deviation above the mean (x1) vs. the mean (x0)? Thank you very much! With kind regards Steve 

ASIA RAFIQ posted on Monday, October 16, 2017  9:14 am



Hi! I am a PhD scholar. currently working on Expatriates. i am having three IVS( X1, X2, X3) on Mediator (M) Two Dvs (Y1, Y2) and Two Moderators (W, V). W moderates at first levels X1W, X2W, X3W with M at first level and MV on both Y1 and Y2. i dont know how to write Mplus code with multiple Dvs and Ivs. i only know with single IV ans Dv. please help me in this regard. thank you in advance 

ASIA RAFIQ posted on Monday, October 16, 2017  9:31 am



Respected Professor! I am a PhD scholar. currently working on Expatriates. i am having three IVS( X1, X2, X3) on Mediator (M) Two Dvs (Y1, Y2) and Two Moderators (W, V). W moderates at first levels X1W, X2W, X3W with M at first level and MV on both Y1 and Y2. i dont know how to write Mplus code with multiple Dvs and Ivs. i only know with single IV ans Dv. please help me in this regard. thank you in advance 


For examples, look at the outputs at http://www.statmodel.com/Mplus_Book_Tables.shtml 

Yuhan Zuo posted on Sunday, October 29, 2017  11:55 pm



Dear Muthen, I am working on a monolevel moderated mediation model with nonindependence problem. I use TYPE=COMPLEX to deal with the nonindependence issue.However, BOOTSTRAPPING can not be used together with TYPE=COMPLEX, yet I need to get the BOOTSTRAPPING results of indirect effect (a*b) to test the moderated mediation model. Is there anyway I can get the BOOTSTRAPPING results when using TYPE=COMPLEX? 


If Type=Complex is due to clustering, you can do Type=Twolevel with Bayes to allow nonsymmetric a*b CIs. Mplus does not have Bootstrapping for complex samples. 

Yuhan Zuo posted on Wednesday, November 01, 2017  1:54 am



Dear Muthen, Thanks for your reply! Although Mplus does not have Bootstrapping for complex samples, I want to know that if I can use Monte Carlo Method proposed by "Selig, J. P., & Preacher, K. J. (2008, June). Monte Carlo method for assessing mediation: An interactive tool for creating confidence intervals for indirect effects" to get the CI of the indirect effects when I use TYPE=COMPLEX to deal with my single level moderated mediation model with nonindependence problem? Thanks a lot again! 


I doubt that the article's approach covers Type=Complex data; you can ask the authors. 


Hi there, I am interested in testing whether a moderator moderates the relationship between an IV and a DV and whether a mediator mediates the relationship between the moderator and the DV (see specific variables below). I looked at example 3.18 in the users manual, but I can’t seem to figure out what my syntax should look like. Can you please help? Mediator = dtotext2 IV = ZneighprobMR1 Moderator = zmfr1 DV = DSA1A3 covariates: icsex icethnic groupid IDVARIABLE IS famid; MISSING ARE ALL (999); USEVARIABLES ARE icex icethnic groupid ZneighprobMR1 ZMFR1 mom1xflex1 dtotext2 DSA1A3; ANALYSIS: Type = general; ESTIMATOR ML; bootstrap = 5000; MODEL: DSA1A3 on dtotext2 (b) icex icethnic groupid ZneighprobMR1 ZMFR1; !model with just covariates DSA1A3 on dtotext2 (b) icex icethnic groupid ZneighprobMR1 ZMFR1 mom1xflex1; !model with covariates and interaction term dtotext2 on ZneighprobMR1 (gamma1); ! mediator regressed on moderator ???? (gamma2); MODEL CONSTRAInT: PLOT(indirect); Loop(mod,2, 2, .1); indirect = b*(gamma1+gamma2*ZMFR1); PLOT: TYPE = PLOT2; OUTPUT: stdyx; CINT(bcbootstrap); 


Have a look at the chapter 1 and chapter 2 scripts for the examples in our book Regression and Mediation Analysis using Mplus shown at http://www.statmodel.com/Mplus_Book_Tables.shtml 


Hi, I am running a model with moderated mediation with two mediators (the moderator is only moderating the relationship between the predictor and the first mediator). I currently am regressing the first mediator on the predictor, the first mediator on the interaction, and the first mediator on the moderator. My question is whether I should allow covariance between the predictor, the interaction term, and the moderator (where there is covariance between each of them) or should I constrain the covariances to 0? Thank you, Alison 


No, don't mention parameters related to those 3 covariates  they are automatically correlated just like in regular regression. 


I think there maybe a mistake on the mplus website. For model 3.18 the example download is: MODEL: y ON m (b); m ON x (gamma1) z xz (gamma2); I believe this is not consistent with the mplus version 8 manual which has: MODEL: y ON m (b) x z; m ON x (gamma1) z xz (gamma2); The line x z; is missing from the example download. 


Either model is fine but the Version 8 User's Guide setup is what I would recommend and is also what we are using in our mediation book. 

jb posted on Tuesday, February 20, 2018  2:11 am



Hello, I am extremely new to both SEM and MPlus so I was wondering if you could help me interpreting my output. All my variables are observed and all models fit very well. I have ran the following models with these findings: Model 1 (basic mediation with only one mediator): M1 mediates the relationship between X and Y Model 2: I added moderator W (dichotomous  high vs low value) on the "a" pathway of the mediation  significant moderation effect at the high value of the moderator Model 3: I added to Model 2 another mediator in series (M2), so that now I have M1 and M2 in series, and W still moderating the IVM1 ("a") path I am finding a significant XW interaction. However all new/additional parameters are not significant except for the total effect of W at its high value. I am struggling to interpret the results... 1 how do I understand if the serial mediation is significant, ie what do I need to look at? 2 is there a significant moderated mediation effect? 


This general analysis question is suitable for SEMNET. 


Dear Professor, I am a PhD scholar,currently working on a research paper.I want to run a model with one IV(X1), on Mediatior M ,one DV(Y1)and one modetator (W).Moderation is at first satge.But its a two level first stage moderation mediation model.I want to test such a multilevel moderated mediation model with Mplus ? can i have Mplus code ? thanks a lot for advance IV(Firm level)>M(Individual level)>DV(individual level) Moderator(Firm level) 


See 211 examples in http://www.statmodel.com/download/Preacher.pdf You say that moderation is at first stage  perhaps you mean that the regression of M on IV is moderated. If so, you simply create an interaction term IV*W using Define and put that on the Between list. Indirect and direct effects with this kind of moderation is in line with singleleevl mediation models such as shown in Section 2.6.1 of our book Regression and Mediation Analysis using Mplus. See also Mplus input and output for examples in this book on our website at http://www.statmodel.com/Mplus_Book_Tables.shtml For singlelevel moderation, see also our Mediation page at http://www.statmodel.com/Mediation.shtml including UG ex 3.18. 


Dear Professor, thanks for your reply.sir moderation is at first stage but my independent and moderator are at level 2 while mediator and dependent are level 1.so its a two level First stage moderation mediation.you said that direct and indirect effects with such kind of moderation are similar to single level mediation?please help me understand.thanks in advance 


I still don't know if by "moderation is at first stage" you mean that the regression of M on IV is moderated. Regarding singlelevel moderation, see our RMA book and also Topic 11 of our Short Course videos and handouts which is also available as YouTube videos. 

jb posted on Monday, March 26, 2018  8:29 am



I have two questions: 1) I am testing six consecutive moderated mediation models When I ask for descriptive statistics for each model, the means are slightly different depending on the model Since I am planning to report all models, what Descriptive statistics values should I report? I.e. from what model, since they are all slightly different depending on the specific model tested? 2) How do I obtain SDs for descriptive statistics? Do I need to square root manually the variance or is there a quicker way? 


1) Good question for SEMNET. I would report the univariate statistics for the maximum N for each variable. 2) Use Analysis: Type=Basic. 

jb posted on Monday, March 26, 2018  10:39 am



thank you for responding I am using Analysis: Type=Basic, but I obtain the variance, rather than the SD values? 


Square root variances. 


Dear Sir Muthen, Thank you for your response.By first stage moderation mediation i mean that the first path between iv and mediator is moderated by W. because i have four variables in my model i.e., IV,M,DV AND W. I am having a cross level model.My independent and moderating variable is at organizational level and mediator and dependent are at individual level.As i am new to Mplus so i am confused that how to handle two levels of data in Mplus while running first stage moderation mediation. 


Use Define: ivw = iv*w; and Between = IV W IVW; Then model it as %Within% DV on M; M; %Between% DV on M IV W IVW; 

Pengfei Li posted on Monday, April 23, 2018  8:28 am



Hi£¡Is it able to output confidence intervals for every value of mod in loop option at example 3.18? 


Yes  the plot shows the CIs and all plot values can also be saved. 

Pengfei Li posted on Monday, April 23, 2018  5:42 pm



Thanks a lot. Is there some way to caculate the critical value of confidence bands by JohnsonNeyman tech. directly? If we fix a smaller increment in LOOP option in example 3.18 whether it will be better? It needs the coefficients' covariance and variance, accroding to the formula of confidence bands in (Bauer & Curran,2005). Should I find it from TECH3 option? So would you please give me some advice? Bauer D J, Curran P J. Probing Interactions in Fixed and Multilevel Regression: Inferential and Graphical Techniques.[J]. Multivariate Behavioral Research, 2005, 40(3):373400. 


Q1: Why go through the trouble of doing this when it is given by Mplus? Q2: Yes. Q3: Yes, but again, not needed because Mplus gives the values when you use the option to save the Loop plot values. 

Pengfei Li posted on Tuesday, April 24, 2018  5:41 pm



It makes sense. Thanks. 

Pengfei Li posted on Wednesday, May 09, 2018  12:39 am



Dear Dr. Muthen, Can it output plot values' SD value¡¢t value and p value ? Is it possible plot a three dimensions graph such as response surface in Mplus? 


All values of a plot can be saved. 

Pengfei Li posted on Thursday, May 10, 2018  5:12 pm



When I ues "save plot data", it output four columns of data, loop(x).plot(y),lower CI and upper CI of plot(y). How to save SDvalue, tvalue and pvalue of plot(y)? 


If they are not in the plot they won't be saved. You only need the lower and upper CI values. They are much better than the SD, tvalue and pvalue because they don't rely on a symmetric confidence interval. 

Pengfei Li posted on Thursday, May 10, 2018  5:58 pm



Thanks. Got it. 


I am having trouble with a moderated mediation model where W moderates the path X > M. All variables are continuous. I am getting the error message: The following parameter label is ambiguous. Check that the corresponding parameter has not been changed. Parameter label: MED1. Could you suggest an improvement to the following syntax? Y ON X; M ON X (MED1); Y ON M (MED2); M ON W W*X; MODEL CONSTRAINT: NEW(INDIR1); INDIR1 = MED1*MED2; 


It looks fine so we need to see the full output  send to Support along with your license number. 


Hi, I'm testing a complex path analysis model with two IVs, each related to a first set of several mediators, themselves in turn related to another set of mediators, themselves related to one DV. The model includes covariates impacting the DV too. All variables are continuous. I want to test the moderation effect of an additional continuous variable on the pathways between IVs and the first set of mediators. I was able to define the interaction terms, add them to the model (in addition to the moderator), and some of the interaction terms are significant. How can I probe these interaction effects (i.e. sample slopes) for such a complex model? Thank you 


You should use the PLOT and LOOP options in line with UG ex 3.18, extended to your case. Just multiply not only with the "b" coefficient from the first set of mediators but also with the coefficients relating the final outcome to the second set of mediators. 


Hi, I want to see the effect of X(which is time invariant) on Y(measured in 10 time waves) through mediating effect of M. This relationship of M to Y is moderated by V. All these variables are latent and measured by proxies. I want to test this with a cross lagged model. But don't know How would I incorporate the mediating effect in this model? Any help would be greatly appreciated. 


ANALYSIS: TYPE = RANDOM; ALGORITHM = INTEGRATION; INTEGRATION = MONTE; MODEL: !Residual covariances M_INT2 PWITH M_INT3; M_INT2 PWITH M_INT4; M_INT3 PWITH M_INT4; V2_INT1V4_INT1 PWITH V2_INT2V4_INT2; V2_INT1V4_INT1 PWITH V2_INT3V4_INT3; V2_INT1V4_INT1 PWITH V2_INT4V4_INT4; V2_INT2V4_INT2 PWITH V2_INT3V4_INT3; V2_INT2V4_INT2 PWITH V2_INT4V4_INT4; V2_INT3V4_INT3 PWITH V2_INT4V4_INT4; Y_INT2 PWITH Y_INT3; Y_INT2 PWITH Y_INT4; Y_INT2 PWITH Y_INT5; Y_INT3 PWITH Y_INT4; Y_INT3 PWITH Y_INT5; Y_INT4 PWITH Y_INT5; !AUTOREGRESSIVE KSAC4 ON KSAC3; KSAC3 ON KSAC2; KSAC2 ON KSAC1; OCUL4 ON OCUL3; OCUL3 ON OCUL2; OCUL2 ON OCUL1; IJVP5 ON IJVP4; IJVP4 ON IJVP3; IJVP3 ON IJVP2; IJVP2 ON IJVP1; ! CROSSLAGGED IJVP5 ON KSAC4; IJVP4 ON KSAC3; IJVP3 ON KSAC2; IJVP2 ON KSAC1; KSAC4 ON BREL; KSAC3 ON BREL; KSAC2 ON BREL; !IJVP10 ON BREL; !IJVP9 ON BREL; !IJVP8 ON BREL; !IJVP7 ON BREL; !IJVP6 ON BREL; IJVP5 ON BREL; IJVP4 ON BREL; IJVP3 ON BREL; !STRUCTURAL MODEL INTCN1  KSAC2 XWITH OCUL2; IJVP3 ON INTCN1; INTCN2  KSAC3 XWITH OCUL3; IJVP4 ON INTCN2; INTCN3  KSAC4 XWITH OCUL4; IJVP5 ON INTCN3; MODEL CONSTRAINT: ?? 


You mention Crosslagged modeling but your first message mentions 10 y's but only 1 x and 1 m so I don't know what's crosslagged. It is not clear how your second message relates to the first  and we ask that postings be limited to one window  longer messages should be sent to Support along with your license number. 


Sorry about confusion in the previous message. In my model X is measured only in year 1, other variables M, V and Y measured in 10 waves. The model actually resembles Precher et al's (2007) model 3. Can I test moderated mediation in CLPM framework? 


If a model to test this makes sense, Mplus can do it. What is the Preacher et al (2007) article? There are several recent articles related to this. 


Hi all, I am testing a moderated mediation model with one predictor (X), two mediators (M1 and M2), two outcomes (Y1 and Y2), and one moderator (W). All are continuous. M1 mediates the relationship between X and Y1, while M2 mediates the relationship between X and Y2. W moderates the relationships between X and M1 as well as X and M2. I'm struggling to understand how to use the MOD function, though I read in the Version 7.2 language addendum that the exposure variable has to be binary (p. 3). This is the syntax I tried using and the error message I got. I'm not sure I used the right model. DEFINE: CENTER X W (GRANDMEAN); int=X*W; MODEL: ! Structural Model M1 M2 ON X W int; Y1 ON X W int; Y2 ON X W int; MODEL INDIRECT: Y1 MOD M1 W (1 4 1) int X; !Y2 MOD M2 W int X; "WARNING in OUTPUT command STANDARDIZED (STD, STDY, STDYX) options are not available for analysis with the MOD statement in MODEL INDIRECT. Request for STANDARDIZED (STD, STDY, STDYX) is ignored." Any guidance would be greatly appreciated, I'm working on a tight deadline! 


The MOD option is for singlemediator cases only. Any indirect and direct effects can however be expressed using Model Constraint. The formulas are given in our Short Course Topic 11 video and handout on our website as well as in our RMA book  see Case 1 moderation in Chapter 2 with book scripts on our web site. For each mediator the indirect effect is of the kind (b1 + b3*W) (x1x0) where b3 is the coefficient for the x*w interaction. With a binary x, (x1x0)=1 and for a continuous x you can choose the difference between the 2 x values to be compared; e.g. x0=mean(x), x1= 1SD+mean(x). 


Dear Sir, Thank you very much for your reply.I know MPlus can do anything. I am a new user of MPlus that is why I am struggling with making MPlus understand how to do it. There are some more challenges with the data as well. I am trying to use secondary data and use proxies to operationalize the variables I am using (that is why the X 'Business Relatedness' is measured only once by using SIC code). Really looking forward to get your valuable comments how I can approach these problems. 


For general analysis strategy questions, you may want to post on SEMNET. 


Thank you Sir for your suggestion. I have tried that as well. They suggest to post it here. Apologies. I will try again then. 


Dear Drs. Muthen, I am estimating a moderated mediation model with dichotomous IV (imbal), a continuous mediator (depres), and a dichotomous DV (poorhlth). My moderator is a 4category dummycoded sex/race variable: WM (referent), WF, BM, and BF. This moderator is hypothesized to moderate paths a, b, and c. Mplus is using WLSMV due to weighting. Is it a legitimate use of the MODEL CONSTRAINT command to test for differences of individual effects, indirect effects, and total effects between categories of the moderator as I have specified below? Also, because WLSMV is being used is the metric for all the indirect, direct, and total effects being calculated expressed as probit regression? The model constraint command follows in the next post. MODEL: depres ON imbal (a1); depres on wf (a2); depres on bm (a3); depres on bf (a4); depres on imbxwf (a5); depres on imbxbm (a6); depres on imbxbf (a7); poorhlth ON depres (b1); poorhlth on depxwf (b2); poorhlth on depxbm (b3); poorhlth on depxbf (b4); poorhlth ON imbal (c1); poorhlth on wf (c2); poorhlth on bm (c3); poorhlth on bf (c4); poorhlth on imbxwf (c5); poorhlth on imbxbm (c6); poorhlth on imbxbf (c7); 


Here are selected model constraint expressions: MODEL CONSTRAINT: ef_im_wf=a1+a5; ef_im_bm=a1+a6; dif_im=ef_im_wfef_im_bm; ef_im2wf=c1+c5; ef_im2bm=c1+c6; dif_im2=ef_im2wfef_im2bm; ind_wm=a1*b1; ind_wf=(a1+a5)*(b1+b2); diffind=ind_wfind_wm; tot_wm=ind_wm+c1; tot_wf=ind_wf+(c1+c5); difftot=tot_wftot_wm; 


Q1: Yes Q2: No, the regular WLSMV effects are for the y* DV (the continuous latent response variable). You can use "counterfactually defined effects" which refer to the observed binary y. See the Topic 11 YouTube videos on or website. 


Also, we ask that postings be limited to one window. 


Hi Dr. Muthen, First, my sincere apologies for using multiple windows for a single post. I viewed the first 3 videos for topic 11 focusing mainly on video 3 which discusses how to obtain the counterfactually defined effects. It seems that this is being done with the MODEL INDIRECT command and the MOD statement. I tried experimenting with this and am coming to the conclusion that this will not work with a categorical moderator. Am I correct here? If so, is there another reference for alternatives to getting these counterfactually defined effects? 


Counterfactual effects are also available with a categorical moderator  you can just split it into a set of dummy variables. 


Hi Dr. Muthen, Yes, I had already created 3 dummy variables from my 4category moderator variable. I looked at the documentation for the MOD statement in the Mplus manual and also tried the command in the Mplus program I had set up. From the manual, it looks like I need to specify a single moderator variable. When I try to include multiple MOD statements in the program I get an error that only one MOD statement is allowed. So can I use the MOD statement in the case of a categorical moderator? If not, can you point me to some documentation or an example for obtaining counterfactually defined effects for a moderated mediation model with a categorical moderator? I really appreciate you taking your time to help me with this as I am fairly new to Mplus. 


You are right the the case of several moderators is not included in the automatic computation of counterfactuallydefined effects using MOD that is called for because of the binary DV. You would have to express these effects using Model Constraint. That is more involved because you have to express the probit formulas in line with page 312 of our RMA book, modifying equation (8.21). It is clear to me how the formulas should be modified. But if you don't want to get into that exercise, you may want to stay with the (noncounterfactual) effects for Y*. Unless you want to try one moderator at a time. 


Hi Dr. Muthen, Thanks so much for your response. It looks like, in the short term, we are going to have to go with the noncounterfactual effects. Meanwhile I have used the MODEL CONSTRAINT command to compute the a, b, c', a*b, and (a*b)+c' effects for the 4 race/sex groups. From these I then computed the differences for the 6 combinations of the groups. From everything I have read, the WLSMV estimation is probit regression in the case of a binary DV and regular OLS regression in the case of a continuous DV. So are the the following following interpretations accurate? 1) Since Y is binary, the effects of m on y* (b) and the effects of x on y* (c') are the effects had the continuous y been observed. These are expressed in the output as probit regression coefficients. 2) Since m is continuous, the effects of x on m (a) are expressed as regular OLS regression coefficients. 3) The mediation effects a*b, is the effect of x on y* through m had the continuous y* been observed. These coefficients seem difficult to describe because of the differencs in the coefficients a and b. The same seems to be true for the total effects (a*b)+c' as well. This may not matter because what we really want to do is compare the mediation and total effects across the 4 groups. 


Hi Dr. Muthen, Since the last post, I started reading your 2015 "Causal Effects" article. In it when discussing a binary y and continuous m you write "The coefficient b is a probit or a logit coefficient when considering y to be the dependent variable and a linear regression coefficient when considering y* to be the dependent variable." So the b and c' effects are interpreted as regression coefficients when y* is assumed to be continuous. This would make the indirect and total effects interpreted as in OLS regression, correct? But am I correct that b and c' are estimated using probit? It's just that, depending on your assumptions, they can be interpreted as either? It's a little hard to wrap my head around this. 


Answer to 10:57 post: Q1: Yes Q2: Yes Q3: It depends on whether the DV of interest is y* or y. 


Answer to 7:15 post: 1) That's an ok way to express it. 2) Right 3) When you consider y* as the DV of interest, both a and b refer to linear regressions with continuous DVs (doesn't matter that y* is latent). 


Hi all, I posted a while back about my moderated mediation model, and your advice was helpful. I got results (no error messages) using code I've partially included below, but I don't think I did enough for my hypothesis testing and I'm not sure how to proceed. MODEL: [TaskPerf] (b0); TaskPerf ON LMCQ (b1); TaskPerf ON FTM (cdash); [LMCQ] (a0); LMCQ ON FTM (a1); LMCQ ON LTM (a2); LMCQ ON int (a3); MODEL CONSTRAINT: NEW(LOW_W MED_W HIGH_W IND_LOWW IND_MEDW IND_HIW TOT_LOWW TOT_MEDW TOT_HIW); LOW_W = 0.358985; MED_W = 0; HIGH_W = 0.358985; IND_LOWW = a1*b1 + a3*b1*LOW_W; IND_MEDW = a1*b1 + a3*b1*MED_W; IND_HIW = a1*b1 + a3*b1*HIGH_W; TOT_LOWW = IND_LOWW + cdash; TOT_MEDW = IND_MEDW + cdash; TOT_HIW = IND_HIW + cdash; I ignored the fact that my data are nested (followers within leaders) as well as the fact that I have parallel mediators and a second outcome variable (paths don't cross). The second pathway is between FTM, Empathy, and OCB2. Same moderation relationship with LTM. What do I have to do to capture/control for the nested nature of the data? FTM is level 1, LTM is level 2. 


In a Type=Twolevel Random analysis, you replace the interaction with a random slope that is regressed on the LTM moderator on the Between level. So the model can look something like this (staying with your parameter labels): Within=FTM; Between=LTM; %Within% Taskperf ON LMCQ (b1); Taskperf ON FTM (cdash); S  LMCQ ON FTM; %Between% s ON LTM (a3); [s] (a1); s LMCQ Taskperf WITH s LMCQ Taskperf; I think the effects will then be as you have them (check me). See also the Preacher pdf on our web page: http://www.statmodel.com/Mediation.shtml 


Thank you so much! I altered the code using the above and what I found for model F in the Preacher pdf. I'm getting an error message I'm not sure how to fix: "*** ERROR in VARIABLE command TYPE=TWOLEVEL requires specification for the CLUSTER option." I tried looking it up to try and fix on my own, but I'm so new to MPlus that I can't make much sense out of the other forums. Is this an error message related to the way I'm writing the syntax or is this something I need to fix in my data before running the syntax? Thank you so much for all your help! 


You said your level 2 is leaders, so you have to add Cluster = z; where the variable z refers to the leaders. See our Short Course Topic 7 video and handout for Twolevel analysis. 


Hmm, I had that statement in my code when I got the error message: DEFINE: CENTER FTM LTM (GRANDMEAN); WITHIN = FTM; BETWEEN = LTM; CLUSTER = leader; I'll check out the short course video and handout for sure. Thank you again! 


Note that the 3 statements WITHIN = FTM; BETWEEN = LTM; CLUSTER = leader; should be in the Variable command. 


Ok, that was an easy fix. Now I'm getting this error message: ERROR in MODEL command: Betweenlevel variables cannot be used on the within level. Betweenlevel variable used: LTM The following MODEL statements are ignored: Statements in the WITHIN level: TASKPERF ON LTM _______________________________________________________ VARIABLE: NAMES are […]; use variables are […]; WITHIN = FTM; BETWEEN = LTM; CLUSTER = leader; DEFINE: CENTER FTM LTM (GRANDMEAN); ANALYSIS: TYPE = Twolevel random; Iterations = 1000; Convergence = 0.00005; MODEL: %WITHIN% TaskPerf ON LMCQ (b1); TaskPerf ON LTM (cdash); sLMCQ ON FTM; %BETWEEN% s ON LTM (a3); [s](a1); s LMCQ TaskPerf WITH s LMCQ TaskPerf; MODEL CONSTRAINT: NEW(LOW_W MED_W HIGH_W IND_LOWW IND_MEDW IND_HIW TOT_LOWW TOT_MEDW TOT_HIW); LOW_W = 0.358985; MED_W = 0; HIGH_W = 0.358985; IND_LOWW = a1*b1 + a3*b1*LOW_W; IND_MEDW = a1*b1 + a3*b1*MED_W; IND_HIW = a1*b1 + a3*b1*HIGH_W; TOT_LOWW = IND_LOWW + cdash; TOT_MEDW = IND_MEDW + cdash; TOT_HIW = IND_HIW + cdash; 


The error message says it  because you say that LTM varies only on Between, you should get rid of the Withinlevel statement: TaskPerf ON LTM (cdash); Perhaps you want it on Between. 

John C posted on Tuesday, August 28, 2018  2:48 pm



I wish to specify a case 2 type moderated mediation with a binary mediator, a binary outcome, a binary moderator, and a covariate(c). Looking at the documentation, one way specify it is in conjunction with the model constraint command, as in: Variable: ... Categorical = y m; Model: [m$1] (fm0); m on x (fm1); m on c; [y$1] (fy000); y on x (fy100); y on m (fy010); y on z (fy001); y on mz(fy011); y on c; Model constraint: NEW( pfm0 pfm1 pfy000 pfy100 ... de ie) ... de = (pfy100pfy000)*(1pfm0) + (pfy110fy010)*pfm0; ie = ... etc. Another much simpler way would seem to be via the MOD operator, as in: Model: y on m x z mz c; m on x c; Model Indirect: y MOD m z mz x; My main goal is to determine if the indirect effect varies for the two different values of the moderator. My main question is whether the latter specification is indeed valid in this case when both y and m are binary? 


Yes, try y MOD m z(0,1,1) mz x; so that you get the effects evaluated at z=0 and z=1. 

John C posted on Wednesday, August 29, 2018  2:43 pm



Thanks you, I have one followup question. I would like ultimately to estimate the effect on two dependent variables, both binary, with correlated errors, so it would be the following assuming I can extend the syntax. Would this also be a valid specification: Model: y1 y2 on m x z mz c; m on x c; y1 with y2; Model Indirect: y1 MOD m z(0,1,1) mz x; y2 MOD m z(0,1,1) mz x; 


You will have to do the analysis one DV at a time. The current checks of the MOD procedure are such that two DVs are not allowed (with missing data on one DV, the results for the other could change). 

John C posted on Thursday, August 30, 2018  1:54 pm



Thanks, what about if I did it the former way with the model constraints (i.e, without the MOD operator), could both outcomes be analyzed simultaneously in that case? 


Yes, but in your case I don't think you have missing data on M or Ys so it doesn't buy anything to analyze both Y's together. 


Hi Dr Muth, I have successfully executed a 112 MSEM based on your advise. Following is the syntax I have used with Bayesian estimator: usevariables are X M Y; Between= Y; Estimator= Bayesian; %Within% M on X; %Between% M on X (a); Y on M (b); Model Constraint" New (Indirect); Indirect= a*b; Now in the next stage, I want to test a moderated mediation hypothesis. I have level 2 moderator (with no within variation) on the path of M to Y. May I please know what additions do I have to make to the syntax which I wrote? Thanks so much. 


For a betweenlevel moderator w, just say Between = w; %Between% ...what you have before int  w XWITH m; ! XWITH needed  m is latent on this level y on int; Then just pretend that the between level mediation is a singlelevel moderated mediation and use the regular singlelevel effect formulas for that. 

Back to top 