Testing a Mediation with Count data. PreviousNext
Mplus Discussion > Categorical Data Modeling >
 Sebastian Nitsche posted on Monday, March 07, 2011 - 2:15 am

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,
 Linda K. Muthen posted on Monday, March 07, 2011 - 9:27 am
In this situation you can use MODEL CONSTRAINT to define the indirect effect.
 Sebastian Nitsche posted on Friday, March 11, 2011 - 6:26 am
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 Count-DV (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 bootstrap-procedure 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,

Title: Mediation with model constraints
4 IV, 1 Med, 1 DV (count)

File is MPLUS3.dat ;
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;
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;
 Linda K. Muthen posted on Friday, March 11, 2011 - 9:10 am
This looks correct.
 Sebastian Nitsche posted on Friday, March 11, 2011 - 11:47 am
Great. Thank you!
 S.Arunachalam posted on Friday, May 02, 2014 - 7:11 am
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 non-continuous 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!!
 Bengt O. Muthen posted on Friday, May 02, 2014 - 8:52 am
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.
 S.Arunachalam posted on Friday, May 02, 2014 - 10:19 am
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?
 Bengt O. Muthen posted on Friday, May 02, 2014 - 4:18 pm
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.
 S.Arunachalam posted on Friday, May 02, 2014 - 9:02 pm
Dear Prof. Muthen. Thanks a lot for your advice. My sincere gratitude to you.
 S.Arunachalam posted on Saturday, May 03, 2014 - 9:31 am
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.
 Linda K. Muthen posted on Sunday, May 04, 2014 - 4:54 pm
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.
 S.Arunachalam posted on Sunday, May 04, 2014 - 8:44 pm
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!
 Bengt O. Muthen posted on Thursday, May 15, 2014 - 3:52 pm
You should have no problem estimating 2-level 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.

COUNT=Y (nb);
CLUSTER = tchid;

X (aw);
M (bw);
X (ab);
M (bb);

NEW(indw indb);
 Linda K. Muthen posted on Friday, May 16, 2014 - 10:02 am
Please send your output and license number to support@statmodel.com.
 Brian Johnston posted on Thursday, September 25, 2014 - 7:37 am
I have analyses somewhat similar to what Sebastian Nitsche posted on Friday, March 11, 2011, but it is with a zero-inflated outcome. As a simplified example, say I have a continuous predictor (x), a continuous mediator (m), and a zero-inflated outcome (y). I have input for a zero-inflated model with indirect effect estimates below, and, following that, I’d be grateful for your feedback on some questions.

FILE IS data.dat;
x m y
count is y(i);
x m y
estimator = ml;
m on x(a);
y on x
y#1 on x
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!

 Bengt O. Muthen posted on Thursday, September 25, 2014 - 5:13 pm
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
 Brian Johnston posted on Friday, September 26, 2014 - 9:56 am
Many thanks! These papers are very helpful.
 Brian Johnston posted on Saturday, September 27, 2014 - 8:53 pm
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, zero-inflated y):

x m y
count is y(i);
x m y
estimator = ml;
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,
 Bengt O. Muthen posted on Sunday, September 28, 2014 - 12:03 pm
You should look under the new heading saying "counterfactuals":


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.
 Brian Johnston posted on Sunday, September 28, 2014 - 1:41 pm
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.
 Bengt O. Muthen posted on Monday, September 29, 2014 - 9:02 am
It sounds like what you are looking at are the Specific indirect effects referring to the old-fashioned effects, that is, effects for the Y log-rate (log-mean), 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 log-rate results are of some use, but it is not an optimal approach. You may also find this article useful since it discussed counterfactually-defined effects in the presence of multiple mediatiors:

Tyler VanderWeele & Stijn Vansteelandt (2013) Mediation Analysis with Multiple Mediators. Epi Methods.
 Brian Johnston posted on Monday, September 29, 2014 - 9:21 am
Thank you!
 Nassim Tabri posted on Saturday, December 23, 2017 - 10:36 am
Dear Mplus team,

I want to test a moderated-mediation 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, continuous-time 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!

 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 moderated-mediation 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 zero-inflation 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!
 Bengt O. Muthen posted on Saturday, December 23, 2017 - 2:40 pm
That's right - providing Bayes for counts is still on our to-do list. But why not use ML? Note also the special considerations for indirect and direct effects for count outcomes, needing counterfactually-defined effects as described in our book.

If you have a long tail, you could turn the count variable model into a two-part model (also described in our book).
 Alexis Brieant posted on Friday, January 25, 2019 - 2:09 pm
I am testing a two-group 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.
 Bengt O. Muthen posted on Saturday, January 26, 2019 - 1:17 pm
Note that with a count outcome, you should really use counterfactually-defined 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
Add Your Message Here
Username: Posting Information:
This is a private posting area. Only registered users and moderators may post messages here.
Options: Enable HTML code in message
Automatically activate URLs in message