Causal mediation PreviousNext
Mplus Discussion > Structural Equation Modeling >
 Emil Coman posted on Tuesday, January 13, 2015 - 1:50 pm
I am running the new 'causal mediation' command, using something like
DV MOD M TxbyM Tx;
However I would like to generate a new parameter besides the four listed in the output (PNDE, TNIE, TNDE, PNIE), based on VanderWeele's paper
I would want specifically to estimate TNDE-PNDE=IntRef as a new parameter.
How could I do this, what labels does Mplus use by default for PNDE, TNIE, TNDE & PNIE behind our backs (if so), that I could use to generate IntRef?
I would not want of course to calculate & labeled by hand TNDE and PNDE themselves as new parameters only to have them labeled... Thanks!
 Bengt O. Muthen posted on Tuesday, January 13, 2015 - 2:02 pm
Sorry, the PNDE etc quantities are not accessible but all have to be expressed as in my 2011 paper.
 Emil Coman posted on Wednesday, January 14, 2015 - 8:34 am
Thanks, Bengt; 1 more quick one: can you see a way to run causal mediation like a
where however LM is now a latent, but a latent change/difference score, not a multi-item scale, so it is defined like:

LM by wave2M@1;
wave2M on wave1M@1;
wave2M on LM@1;
LM on wave1M *; !a good way to define LCS scores

My problem of course is I cannot include a TxbyLM in the DEFINE section, as the LM latent is defined below that... The only (bad!) workaround I see is to compute mere difference score in DEFINE as DifM=(wave2M -wave1M) and then compute a TxbyM =DifM*Tx. Any suggestion/comment? Thanks!
 Tihomir Asparouhov posted on Wednesday, January 14, 2015 - 12:12 pm
You can define that interaction in the model statement using


and add type=random in the analysis command.
 Emil Coman posted on Wednesday, January 14, 2015 - 1:12 pm
Thanks, Tihomir, I found this option mentioned here in the listserv, and tried it... it gets to:
"*** ERROR
MODEL INDIRECT is not available for TYPE=RANDOM."
 Tihomir Asparouhov posted on Wednesday, January 14, 2015 - 3:00 pm
You have to use the 2011 paper and model constraints to get the effects you need.
 John C. posted on Monday, February 15, 2016 - 12:09 pm
I would like to implement a model with a nominal mediator, based on the discussion in section 8 of your paper, “Applications of causally defined direct and indirect effects in mediation analysis using SEM in Mplus.” However, my model differs from in that the x variables are not necessarily binary.

The framework presented in Muthen (2011) is for a binary x which acts as treatment, but I’m assuming the approach is fully extendable to models where x may be continuous or, in my case, a factor?

For example, the formulation of a direct effect give in the paper is “ the conditional expectation, given the covariate, of the difference between the outcome in the treatment and control group when the mediator is held constant at the values it would obtain for the control group.”

In the case where x is continuous, what would be the analogous formulation?
 Bengt O. Muthen posted on Tuesday, February 16, 2016 - 6:36 am
Yes, you can have a continuous exposure variable. The effects are then evaluated by comparing two exposure values, for example, the mean and one SD above the mean.

I will present a paper on nominal mediation at the M3 meeting at UCONN in May.
 John C. posted on Wednesday, February 17, 2016 - 8:23 am

I have a follow up on this as it means the Mplus code examples (Tables 50 and 51) would have to be modified appropriately.

For example, as formulated:

p10 is probability of mediator category 1 when x is zero
p11 is probability of mediator category 1 when x is one

so the formulas for these would have to be modified to take account of the two exposure values.

Must the exposure values be hardcoded (in the Model Constraint section)?

Second, the x in my case is actually a factor with categorical indicators. Does this then mean that I would have to perform the analysis in two stages, i.e., first derive the factor scores, then insert the appropriate hardcoded exposure values?
 Bengt O. Muthen posted on Wednesday, February 17, 2016 - 4:35 pm
The effects in those tables is for a change from x=0 to x=1. The formulas in Table 51 are making use of these simplifications for x. If you have a continuous x you need to consider say the mean of x and 1SD above the mean of x instead of 0 and 1. That changes the formulas because those x values enter into both the gamma and the beta terms of Model Constraint in line with equations (94) and (95).

So it takes a little doing to modify the Table 51 input.
 John C. posted on Friday, February 19, 2016 - 3:16 pm
Just as a follow-up, in my case the x is a factor with ordinal indicators with values 1,2 or 3. However the continuous factor scores range from around -2.5 to +0.2. For the mediation equations above, should the mean and 1SD above the mean be in terms of the scale of the underlying factor scores?
 Bengt O. Muthen posted on Friday, February 19, 2016 - 6:20 pm
 John C. posted on Wednesday, February 24, 2016 - 9:25 am
I have a follow up question on this which may be obvious but would like to check for sure.

To proceed here I need to first generate the factor scores before I execute the fully specified model with the Model Constraint command.

I can generate the factor scores either by running the measurement model alone, or by running the fully specified model (with the measurement model as part of it).

I presume the latter is the best option to guarantee the factor scores I specify in the Model Constraint section are correct?

In that case, there should be no reason to substitute the factor scores as predictors in place of the measurement model. Is that correct?
 Bengt O. Muthen posted on Wednesday, February 24, 2016 - 3:06 pm
You don't need to estimate factor scores. You just use the model-estimated factor variance (mean is zero I assume) to give the range.
 John C. posted on Friday, February 26, 2016 - 10:47 am
I asked above if one has to specify the mean and 1 SD above the mean for the mediation equations (Tables 50 and 51) in terms of the scale of the underlying factor scores to which you indicated "Yes."

Now you're saying I don't need to estimate the factor scores. Perhaps it would be easier if you could provide the Mplus syntax for:

p10 is probability of mediator category 1 when f is at the mean
p11 is probability of mediator category 1 when f is 1 SD above the mean.
 Bengt O. Muthen posted on Friday, February 26, 2016 - 11:29 am
When you said scale of the underlying factor scores I thought you meant the scale of factor variable in the model - people often refer to it that way. I couldn't imagine that you thought you needed estimated factor scores. You should just treat the factor as an observed variable in the formulas - if it has mean zero and estimated standard deviation SD, then the 2 values are 0 and SD. You can make it easy by setting the metric of the factor as variance fixed at 1. See also Section 13.4 in the 2011 paper.
 John C. posted on Wednesday, March 02, 2016 - 5:55 am
Thanks, here is what prompted my original concern. If I look at the factor scores, the mean is -.09, and the range goes from -2.5 to .245, so highly skewed. If I add the SD (around 0.5) to the mean, I'm way out of range of any of the factor scores.

Is this a little strange, or is it still ok to just use, f*0 for the mean and f*0.5 for 1 SD above the mean (in the model constraint command).

Apologies for dragging this out.
 Bengt O. Muthen posted on Wednesday, March 02, 2016 - 6:47 pm
Yes, I would go by the metric of the factor in the model which is assume normal and gets an estimated factor SD. The model distribution is like the prior and the estimated factor scores like the posterior so they can be different.
 John C. posted on Wednesday, March 09, 2016 - 1:40 pm

Thanks, if I could shift to a different topic related to this model.

With my factor as a predictor in this mixture model I specify ALGORITHM=INTEGRATION, as indicated as required in the Mplus output

This works but then I run into a problem when modeling error correlations across the indicators. The first error is that "For covariances between categorical variables, specify PARAMETERIZATION=RESCOV in the ANALYSIS command."

However, when I add this specification, I get the following error: "Categorical variables are not allowed as factor indicators for PARAMETERIZATION=RESCOV."

In short, can these mixture models work with covariances across categorical indicators?
 Bengt O. Muthen posted on Wednesday, March 09, 2016 - 4:35 pm
You will have to put a factor behind the pair of indicators to let their residual correlate.
 Aniruddha Das posted on Tuesday, September 12, 2017 - 8:56 am
Dear Drs. Muthen,

Quick question: the user guide provides the following code for the MOD option with 4 arguments, when there’s a separate moderator that interacts with the mediator:

y MOD m z (-1 1 0.1) mz x;

where y is the outcome, m is the mediator, z is the moderator, mz is the interaction between m and z, and x is a binary exposure variable

Do the total natural indirect effects (TNIE) then incorporate x-to-y paths through:
1. m and mz, OR:
2. m, z and mz?

I.e., is the moderator z also treated as a mediator, such that the path through it is incorporated into the TNIE?

Many thanks,
Bobby Das
 Bengt O. Muthen posted on Tuesday, September 12, 2017 - 6:26 pm
The answer is: 1.

See our book at
 Lynne W posted on Wednesday, January 10, 2018 - 1:41 pm
Dear Drs. Muthen,

I want to estimate a two-level mediation model with a binary mediating variable using the Bayes estimator. I would also like to get counterfactual causal effects using the INDIRECT command, but I run into the following error: MODEL INDIRECT is not available for TYPE=TWOLEVEL with ESTIMATOR=BAYES. I tried other estimators but they also fail.

Is there a way to estimate such models or to calculate the counterfactual effects in another way?

Many thanks,
 Bengt O. Muthen posted on Wednesday, January 10, 2018 - 2:42 pm
Yes, you can always express the effects in terms of model parameters using the Model Constraint command.

I don't know if your exposure variable is a within-level or a between-level variable and which level the binary mediator is on.
 Lynne W posted on Wednesday, January 10, 2018 - 3:09 pm
My exposure variable (kkz_dens) is on the between level and the binary mediator (LPART) is on the within level.

It looks like this






L_DIFF ON kkz_dens;

LPART ON kkz_dens(B);

I assume I can calculate the conventional indirect effects using the MODEL CONSTRAINT command and the product method:




but how would I calculate the counterfactual effects?
 Bengt O. Muthen posted on Wednesday, January 10, 2018 - 4:22 pm
a*b is indeed the indirect effect. But you have to fix a couple of things in your input:

- put kkz_dens on the Between list

- add on Between:

Lpart on kkz_dens (a);

L_diff on Lpart (b);

The within-level L_diff on Lpart slope does not play into the indirect effect. See e.g. Preacher's Appendix E for "2-1-1 (MSEM)".
 Lynne W posted on Thursday, January 11, 2018 - 12:17 am
Thank you for very much for the corrections and clarifications.
 Tor Neilands posted on Thursday, September 20, 2018 - 9:45 am
Dear Bengt,

I'm helping a colleague to fit a Cole-Maxwell type longitudinal mediation autoregressive SEM to data with 5 fixed time points. The exposure E is randomized assignment (0=control; 1=intervention), there are 3 observed mediators (1 continuous; 2 ordinal), and either a latent Y or observed Y (we haven't decided which, yet). The residuals of the mediators are pretty weakly correlated and we will use nested testing or BIC to see if we need to retain those correlations, but for now let's assume we'll retain them.

There is some interest in estimating causal direct, total, and indirect effects of X on Y through the M variables. I assume those effects are not available through MODEL INDIRECT at this time? (I would be overjoyed to be wrong about that).

If I am correct that those effects are not presently available through MODEL INDIRECT, could the MODEL CONSTRAINT examples of your 2011 paper be applied directly here? Or would more complex expressions be required due to the presence of the multiple mediators, correlated mediator residuals, and various autoregressive pathways?

If not, I suppose we could use WLSMV or Bayes (I imagine Bayes would be better due to some data missing due to loss to follow-up) to estimate the traditional non-causal indirect effects of X on Y through M* as long as we can demonstrate no X-M interactions on Y.

Thanks as always, Tor Neilands
 Bengt O. Muthen posted on Friday, September 21, 2018 - 5:42 pm
Are E, M's, and Y repeated 5 times?

Counterfactually-defined effects would be needed only if it is important to treat the 2 ordinal mediators as ordinal (as opposed to continuous). My writing does not cover the case of multiple mediators where some are ordinal.
 Tor Neilands posted on Friday, September 21, 2018 - 9:00 pm
Thanks, Bengt.

E is not repeated. It is randomization assignment/study arm assignment (0 = control; 1 = intervention). I suppose I should've called it X for consistency with the way such variables are described in the Mplus documentation and related literature.

M and Y are repeated 5 times.

By the way, I really enjoyed your 13-minute video on mediation linked from the Mplus home page this week. I found it very relevant to several applied data analyses I'm helping early-career scholars with presently. One comment you made in the video that I found especially interesting was your remark that there may be benefits to including X-M interactions and using the causal effects framework even if the X-M interaction is not statistically significant. Could you elaborate further on why that's the case? I found that statement to be very interesting and was hoping to learn more. Thanks!

 Bengt O. Muthen posted on Sunday, September 23, 2018 - 4:27 pm
The idea of including an X-M interaction comes from the 2015 VanderWeele book, page 46. He points to the low power to detect the XM effect and suggests checking for the need to include it by seeing if the indirect and direct effect estimates change much.

There has been several recent articles (MBR, Psych Meth?) on longitudinal mediation in addition to Maxwell's 2010, 2011 articles. See for instance

Huang & Yuan (2016; online). Bayesian dynamic mediation analysis. Psychological Methods

and also the work by

Lijuan Wang, University of Notre Dame
 Adam Garber posted on Wednesday, March 13, 2019 - 9:20 pm

I would like to run a casual effects model including the MX interaction (i.e. case 3 from the Mplus mediation book) but with 3 continuous mediators. Therefore, the model would include the following variables:
x (binary), m1, m2, m3, y, mx1, mx2, mx3, & c(continuous covariate)

To my knowledge it is not possible to use the MODEL INDIRECT (y mod m mx x) command with multiple mediators. I am aware of the relevant input example from your Muthen(2011) paper but am unable to translate this input (table 25) from the simulation to the data context.

Could you direct me to an example input to run a model which estimates the four causal effects (TNIE,PNIE,TNDE,PNDE) which could be extended to the case of multiple mediators?
 Bengt O. Muthen posted on Friday, March 15, 2019 - 11:31 am
Let me think about that and try to answer you later.
 Adam Garber posted on Wednesday, March 27, 2019 - 1:36 pm
Hello Dr. Muthen,

Would this work to specify a 3-mediator model with the MX interaction term?

Y (outcome)
X (predictor)
M1 (mediator 1)
M2 (mediator 2)
M3 (mediator 3)

MX1 = M1*X;
MX2 = M2*X;
MX3 = M3*X;

bootstrap = 10000;

Y on M1 (b1)
M2 (b2)
M3 (b3)
X (b4)
MX1 (b5)
MX2 (b6)
MX3 (b7);

M1 on X (g1);
M2 on X (g2);
M3 on X (g3);
[Y] (g0);

model constraint:

!x1=1, x0=0


Many thanks, Adam
 Bengt O. Muthen posted on Wednesday, March 27, 2019 - 4:05 pm
You may be right but I haven't derived that particular case. But you can derive it using the approach of Section 4.5.2 of our RMA book.
 Adam Garber posted on Monday, April 01, 2019 - 3:46 pm
Thank you Dr. Muthen for the reference,

I believe I was able to correctly specify a multiple mediator model using the potential outcomes approach derived in section 4.5.2

*There is an error in the syntax above from my comment, the gamma coefficients for the indirect effects should look as follows:

 Kirsten Smith posted on Thursday, October 31, 2019 - 11:01 am
I have managed to specify and run a causal mediation model in Mplus V8 (thanks to Linda on SEMNET for her advice) with two X variables (X1, X2) and 1 mediator. X1 and X2 are second order latent variables with ordinal indicators, M is a first order latent variable with a mix of continuous and ordinal data, the the outcome Y is and observed continuous indicator. I am using WLSMV.

However when I add bootstraps to the model the output does not get produced. The analysis runs but the output has only the syntax for the model, the warnings and then title of the syntax, nothing else.

Is this because I am using WLSMV? Is this estimator not compatible with the sensitivity analysis with bootstrapping?
 Bengt O. Muthen posted on Thursday, October 31, 2019 - 2:25 pm
We need to run this to see - please send your input and data to
 Kirsten Smith posted on Tuesday, November 05, 2019 - 5:40 am
Just thought I would update in case anyone else runs into the same difficulties that I did.

I was running version 8.0 and did not having a problem the sensitivity analysis without bootstrapping. When I added bootstrapping the analysis would seemingly run but then not produce the full output.

I ran it on an older version of Mplus (7.4) and it worked fine so perhaps try a different version if you have one. Linda said it also worked fine on version 8.2
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