Message/Author 


Hi, I want to test a mediation model, where IV and mediator are continuous and DV is a count variable. It was no problem to specify the model itself but unfortunately MPlus (6.1) cannot determine indirect effects when using count data (error: "BOOTSTRAP is not allowed with ALGORITHM=INTEGRATION."). Is there any workaround (f.e. with MODEL CONSTRAINT command), so I can test the assumed mediation effect formally? Thanks in advance, Sebastian 


In this situation you can use MODEL CONSTRAINT to define the indirect effect. 


Thank you for the quick response. I'm not sure if I did it correct, but I finally specified a constraint model with 4IV, 1 Med and 1 CountDV (see below). Is this the way you thought of? If possible, I additionally want to determine the overall mediation effect (med_total). According to Preacher & Hays (2008) the total indirect effect is the sum of the specific indirect effects. Unfortunately, they used the bootstrapprocedure to analyze indirect effects and they had several mediators, not several IVs. Do you think I can still apply this rule to the current model (like I have done)? Thank you very much, Sebastian Title: Mediation with model constraints 4 IV, 1 Med, 1 DV (count) Data: File is MPLUS3.dat ; Variable: Names are age sex type y2 y1 y3 x4 x1 x2 x3 m2 m1 sq2 sq3 sq1; usevariables are y1 m1 x1 x2 x3 x4; count is y1; analysis: estimator=ml; model: m1 on x1 (a1); m1 on x2 (a2); m1 on x3 (a3); m1 on x4 (a4); y1 on m1 (b); y1 on x1 x2 x3 x4; Model Constraint: new (med1 med2 med3 med4 med_total); med1 = a1*b; med2 = a2*b; med3 = a3*b; med4 = a4*b; med_total = med1+med2+med3+med4; output: samp; stdyx; tech1; 


This looks correct. 


Great. Thank you! 


Respected Prof. Muthen. In the model I am testing, I have a count mediator and continuous DV. The count variable's distribution is zero inflated negative binomial. Model specification is done for the zero inflation parameter as well and the model runs fine. However, my challenge is 1.)How to test for indirect effect? I read in one of your papers, it is incorrect to test just product (i.e. a * b) for noncontinuous mediators. Could you please advice a sample Mplus code to properly do this please? 2.)How to bootstrap the indirect effects captured in step 1. I am unable to do with ESTI=MLR. 3.)How to test indirect effect for model in step 1 using ESTI=Bayes. 4.)As additional analysis I introduce a continuous moderator to model in step 1. Is it possible to test this model after properly undertaking the mediation with count variable? As always, my sincere gratitude in advance!! 


A count mediator is a tricky situation. In the M on X regression you want to specify M as a count variable to get Poisson regression. But in the Y on M regression there isn't a way to treat M as count. There is not a continuous latent response variable formulation for count. So when you regress Y on M you have to treat M as continuous. I discuss it in the paper on our website Muthén, B. (2011). Applications of causally defined direct and indirect effects in mediation analysis using SEM in Mplus. 


Thanks a lot, Prof. I checked this paper and the new paper forthcoming in structural equation modeling. I don't see specific code for count mediator. Could you please share that code. Also in my model I specify count as negative binomial (with zero inflation) rather than Poisson because the mean and variance are unequal. So is that possible as well or I should force fir a Poisson? To above points, is it possible to test moderated mediation using the steps by Preacher et al for these types of count mediators? If so what would be the right formula to specify in the MODEL CONSTRAINT statement? 


The technical appendix, Secton 13.5 says: "The count variable can also be a mediator in which case the integral is replaced by a sum over the possible counts and using the probabilities determined by the Poisson distribution. Using m to predict y, m may be treated as continuous." Although possible, I have not tried this out in Mplus and therefore don't have code for it. It is advanced stuff, so unless you are a statistical expert I would not recommend that you get into this. Instead you would have to make approximations such as treating the mediator as a continuous variable. 


Dear Prof. Muthen. Thanks a lot for your advice. My sincere gratitude to you. 


Prof. Muthen. Sorry I forgot to request before. Could you please suggest a reference or citation for considering count as continuous in these kind of situation please. It is becoming extremely challenging for me to convince reviewers. 


I don't know of any references. If the tail is long enough, you could consider a censored variable. You need to look at the variable's distribution and be guided by that. This is a research topic. 


Thank you Prof. Muthen. 

Yan Liu posted on Thursday, May 15, 2014  11:03 am



Dear Dr. Muthen, I want to use the multilevel mediational models based on SEM proposed by Preacher, Zyphur and Zhang (2010). I have one predictor, one covariate, one mediator and one outcome, which were measured at individual level. In addition, I have another predictor, intervention (control vs. experiment), which was conducted at school level. When I treat the outcome as a continuous variable, the model works. However the model doesn't run when I define the outcome as a count variable using negative binomial (nb). I wonder if negative binomial works for Preacher's multilevel mediational model. Many thanks! 


You should have no problem estimating 2level model with a DV that is nb. Whether or not mediation effects can be logically defined is another matter. If you have problems with the run, send output and license number to Support. 

Yan Liu posted on Thursday, May 15, 2014  8:34 pm



Thanks for your reply! Before I send you the output, I would like you to take a quick look and see if there are something wrong with my Mplus code. The error message shows that the X (predictor), Cov (covariate), and M (mediator) cannot be used at between level. They have to be defined at within level. In addition, when I treat Y as continuous variable, the saddle point appears, so I decreased the criterion for MCONVERGENCE and increased the random starts. USEVARIABLES ARE COV X M Y tchid; COUNT=Y (nb); MISSING=ALL(999); CLUSTER = tchid; ANALYSIS: TYPE = TWOLEVEL; STARTS=500; STITERATIONS=1000; INTEGRATION =GAUSSHERMITE; MCONVERGENCE=0.08; MODEL: %WITHIN% M ON COV X (aw); Y ON COV X M (bw); %BETWEEN% M ON COV X (ab); Y ON COV X M (bb); MODEL CONSTRAINT: NEW(indw indb); indw=aw*bw; indb=ab*bb; 


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


I have analyses somewhat similar to what Sebastian Nitsche posted on Friday, March 11, 2011, but it is with a zeroinflated outcome. As a simplified example, say I have a continuous predictor (x), a continuous mediator (m), and a zeroinflated outcome (y). I have input for a zeroinflated model with indirect effect estimates below, and, following that, I’d be grateful for your feedback on some questions. DATA: FILE IS data.dat; VARIABLE: NAMES ARE x m y count is y(i); USEVARIABLES ARE x m y Analysis: estimator = ml; Model: m on x(a); y on x m(b1); y#1 on x m(b2); model constraint: new (med_pois med_zero) med_pois = a*b1; med_zero = a*b2; output: cinterval 1) If I understand this correctly, this output produces indirect effect estimates, one of which is a product of linear and Poisson estimates and another which is a product of linear and logistic estimates. As each of these is the product of a linear estimate and a natural log estimate, do I interpret their product also as being on a natural log scale? 2) If I can interpret the indirect effect estimates as being on a natural log scale, can I exponentiate them and interpret them as rate (for the Poisson estimate) and odds (for the logistic estimate)? Thank you very much in advance! Brian 


The answers are in the following two papers (to be read in that order) 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. download paper show abstract Muthén, B. (2011). Applications of causally defined direct and indirect effects in mediation analysis using SEM in Mplus. Click here to view the Technical appendix that goes with this paper and click here for the Mplus input appendix. Click here to view Mplus inputs, data, and outputs used in this paper. download paper contact author show abstract 


Many thanks! These papers are very helpful. 


I see now that version 7.2 can handle this mediation with the MODEL INDIRECT statement, which is very helpful  thank you! I do still have a question regarding output. Continuing with my previous example (continuous x, continuous m, zeroinflated y): VARIABLE: NAMES ARE x m y count is y(i); USEVARIABLES ARE x m y Analysis: estimator = ml; Model: m on x; y on x m; y#1 on x m; model indirect: y ind m x; y#1 on m x; Based on Muthén and Asparouhov (2014), I believe I have an understanding of the PNDE, TNIE, TNDE, and PNIE estimates (though I see these are only available with single mediation paths, unlike the above example). However, I'm not clear on the output labeled "Specific indirect" (with multiple mediation paths, as above), or, in other cases, labeled "Indirect" and "Direct Effect" (with a single mediation path). Should these be exponentiated to interpret indirect and direct rates (for Poisson) and odds (for logistic)? Thanks again, Brian 


You should look under the new heading saying "counterfactuals": TOTAL, INDIRECT, AND DIRECT EFFECTS BASED ON COUNTERFACTUALS (CAUSALLYDEFINED EFFECTS) The effects here are in terms of expected Y, so with a count Y no exponentiation should be done. (With binary Y the expectation is the probability of Y=1 instead of 0). And, yes, so far this is limited to a single mediator. 


Thank you again for your response. So should I not interpret the "Specific indirect" estimates whatsoever? I ask because I would like to test a model with multiple mediation pathways, and I cannot obtain the counterfactual estimates. 


It sounds like what you are looking at are the Specific indirect effects referring to the oldfashioned effects, that is, effects for the Y lograte (logmean), not effects for the Y mean that the counterfactual output provides. Seems like we are in a bit of a gray area here regarding how we should handle this and what journals would accept. Perhaps the lograte results are of some use, but it is not an optimal approach. You may also find this article useful since it discussed counterfactuallydefined effects in the presence of multiple mediatiors: Tyler VanderWeele & Stijn Vansteelandt (2013) Mediation Analysis with Multiple Mediators. Epi Methods. 


Thank you! 

Nassim Tabri posted on Saturday, December 23, 2017  10:36 am



Dear Mplus team, I want to test a moderatedmediation model using Bayesian estimation in which the DV is a count variable (the IV and mediator are both continuous). However, when I run this model, I get the following error message: “Estimator BAYES is not available for analysis with count, continuoustime survival, censored or nominal variables.” I understand the error message, but want to ask if there’s a work around in Mplus to estimate this model? Any advice would be much appreciated. Thank you for your time and hope you have a wonderful holiday! Best, Nassim 

Nassim Tabri posted on Saturday, December 23, 2017  11:16 am



Dear Mplus team, Apologies for posting a second message, I want to clarify what I meant by "work around" in my previous post on running a moderatedmediation model in which the DV is a count variable using Bayesian estimation. Based on the error message, I understand that this is currently not possible. But is there a work around? For example, could the count DV be included using two variables for which Bayesian estimation is available? For instance, the first variable would be binary (0 or 1; for the zeroinflation portion of the DV) and the second variable would be continuous (but not sure what to do about participants who score zero for the second variable). Appreciate any input and suggestions you may have. Thanks again for your time! Nassim 


That's right  providing Bayes for counts is still on our todo list. But why not use ML? Note also the special considerations for indirect and direct effects for count outcomes, needing counterfactuallydefined effects as described in our book. If you have a long tail, you could turn the count variable model into a twopart model (also described in our book). 


I am testing a twogroup mediation model with a count outcome. It seems that I cannot actually do this with a 2 group model, so I instead used KNOWNCLASS and model constraint (rather than ind). However, I still get the following message: "One or more MODEL statements were ignored. These statements may be incorrect or are only supported by ALGORITHM=INTEGRATION." Is there anything I can do to resolve this? Thank you. 


Note that with a count outcome, you should really use counterfactuallydefined effects. See our Topic 11 Short Course video and handout. Regarding the error message, we need to see the full output  send to Support along with your license number. 

Back to top 