Categorical mediator in SEM PreviousNext
Mplus Discussion > Categorical Data Modeling >
 Minseop Kim posted on Tuesday, August 10, 2010 - 1:02 pm
Dear Linda,

Although I reviewed threads regarding categorical mediators, I am still confused.

Usevariables are m1 m2 m3 X1 X2 X3;
Categorical = X3;

! m1-m3 are indicators
! X1 & X2 are continuous observed var
! X3 is dichotomous observed var
Model: Y by m1 m2 m3 ;
Y on X1 X2 X3;
X2 X3 on X1;
Model indirect:
Y ind X1;

Q1. Based on your answers, I thnik if I use ML treating categorical mediators as continuous variables, a coefficient (X1->X3) is a logit coefficient and the rest (X1 -> X2, X1-> Y, X2->Y, and X3->Y) are regression coefficients. If I don¡¯t specify the method of estimation, by default(WLS?), the coefficient (X1->X3) is a probit coefficient whereas the rest of coefficients are still the regression coefficient. Is it right?

Q2. By the way, you also said ¡°A nominal variable cannot be used as a mediator. You could look at each category separately or use the nominal variable as a grouping variable." But, I think a nominal variable is a sort of categorical variable. Do you mean that if a nominal variable has more than two categories, it is impossible to fit a model with the nominal mediator?

Q3, How can we interpret an indirect effect of X1 on Y via X3 if a coefficient (X1-X3) is logit or probit coefficient and X3->Y is regression coefficients?

 Linda K. Muthen posted on Wednesday, August 11, 2010 - 10:14 am
If you treat a variable as continuous, the regression is a linear regression.

You cannot use a nominal variable as a mediator.

In Mplus, an indirect effect can be computed for a categorical mediator only when probit regression and weighted least squares estimation is used.
 Mr Mo DANG-ARNOUX posted on Friday, May 06, 2011 - 6:12 am
Dear Mplus experts,

I would welcome a new clarification on categorical mediators, indirect effects, and logit/probit.

(1) Consider path

X -> M -> F -> u1-u4

. M = categorical (ordinal) mediator
. F = latent trait observed through ordinal outcomes u1-u4.

A) If M is predicted by a logit regression on X, then M is treated as a continuous covariate of F regression. No indirect effect X->M->F is available.

B) If M if predicted by probit, then M is treated as its underlying LRV M*. The indirect effect, actually X->M*->F, is the product of the regression coefficients of X->M* and M*->F ; SE + significance are derived using a Sobel approach. With WLSMV estimator, we use MODEL INDIRECT; with ML, MODEL CONSTRAINT.

What is the rationale for the difference A / B?
Is it because with logit, the underlying LRV M* has a non-normal (logistic) residual, thus the overall residual of X-(M)->F has no known distribution?

(2) Ordinal M has 3 levels. Simple regression M -> F suggests a non linear relationship. Isn't it then better to regress F on 2 dummy binary variables M_2 and M_3, than on M as a continuous covariate?

Is there any simpler model than having 2 paths:

Thank you very much for any help.
 Linda K. Muthen posted on Friday, May 06, 2011 - 10:05 am
11A. Yes.
1B. Yes for WLSMV. No for ML.

The reason that it is yes for WLSMV is that m is treated as m* both when m is a dependent variable and an independent variable. The reason it is no for ML is that m is treated as m* when m is a dependent variable and m when it is an independent variable.

2. If m is ordinal, you can regress f ON m and m ON x; Creating two dummy variables for a mediator will not work.
 Mr Mo DANG-ARNOUX posted on Monday, May 09, 2011 - 7:24 am
Dear Dr Muthen, thank you very much for your prompt answer.

(1B[2]). In other threads, it is suggested that the indirect effect X->M->F can be derived in ML with probit. Instead of MODEL INDIRECT (WLSMV), we are instructed to use MODEL CONSTRAINT in ML/MLR: define the overall coef as the product of the two path's coefficients X->M(*?) and M(*?)->F. See e.g.:

Did I get it right? I.e. may we write it as follows?
(nu_ = intercepts, b_ = loadings, eps_ = residuals)

F = nu_2 + b_2 M* + eps_2
= nu_2 + b_2 (nu_1 + b_1 X + eps_1) + eps_2
= (nu_2 + b_2 nu_1) + (b_1 b_2) X + (b_2 eps_1 + eps_2)

How is the overall SE computed? (Sobel...)

(2[2]). The simple regression of F on M suggests that M at level 2 has a stronger effect (regression coefficient) on F than M at levels 3 and 1. This non-linearity makes me hesitant to consider M as a continuous covariate of F regression. How else may I model M mediating the influence of X on F?

Thank you again for your greatly responsive support, and for developing and maintaining this excellent software.
 Linda K. Muthen posted on Monday, May 09, 2011 - 10:02 am
I think the confusion arises from the fact that it is only when the mediator is categorical that indirect effects cannot be computed with ML using MODEL CONSTRAINT or MODEL INDIRECT. If the mediator is continuous and the final variable categorical, this is not a problem. Following is a summary:

MODEL INDIRECT for weighted least squares and MODEL CONSTRAINT for maximum likelihood can be used for indirect effects when:

x -> continuous -> categorical
x -> continuous -> continuous

MODEL INDIRECT for weighted least squares but no MODEL CONSTRAINT for maximum likelihood when:

x -> categorical -> categorical
x -> categorical -> continuous

The reason that it is yes for WLSMV is that m is treated as m* both when m is a dependent variable and an independent variable. The reason it is no for ML is that m is treated as m* when m is a dependent variable and m when it is an independent variable.
 Mr Mo DANG-ARNOUX posted on Tuesday, May 10, 2011 - 2:44 am
Many thanks for this clarification, Dr Muthen. I understand better now the differences.

Actually, I wish to use logit links between factor F and ordinal outcomes u1-u4, in order to have an easier odds-ratio interpretation of the regression coefficients. This restricts the estimation choice to ML/MLR. To adapt to the framework you just told, I am rewriting my model in order to consider M now as continuous.

I would like to know if the indirect effect b_ind (X -> M -> F) can then be obtained by multiplying the two regression coefficients b_1 (X -> M) and b_2 (M -> F), within a MODEL CONSTRAINT option? How safe is it to interpret the z-score of b_ind in order to infer the significance of the indirect effect?
 Bengt O. Muthen posted on Tuesday, May 10, 2011 - 10:27 am

Very safe unless the sample size is less than say 50.
 jtw posted on Monday, May 30, 2011 - 1:58 pm
I have a mediating variable that is nominal in nature with six categories.

I understand one cannot use this variable in observed form as a mediating variable in Mplus. I have seen the creating latent categorical variables from nominal variables work around (i.e., "Making an observed categorical variable u equivalent to a latent class variable c" handout). Can this procedure be generalized to the case where there are six categories? If so, what would the code be? I can't seem to get it to work. Thanks.

As an alternative to the above procedure, would a simple dummy variable approach work (five dummies with one left out as reference) to assess mediation effects in this case? Thanks.
 Bengt O. Muthen posted on Monday, May 30, 2011 - 3:45 pm
I think modeling with a nominal mediator is an unresolved methods research topic. You can translate an observed nominal mediator into a latent class variable for any number of categories. But it isn't clear how to define indirect effects in this modeling, so that solution isn't all that's needed. I also don't think turning the nominal mediator into a series of dummy variables is a solution gets you to the goal of indirect effects.

The closest one can get would seem to be to dichotomize the nominal variable and define indirect effects via the underlying continuous u* as mediator using WLSMV.
 jtw posted on Tuesday, May 31, 2011 - 7:56 am
Thanks. I have a follow up question. You note that one could dichotomize the nominal variable as probably the best approach to assessing indirect effects at this point in time. Generally, I understand the logic of using the underlying continuous u* as the mediator but when you say to dichotomize the six category nominal variable, do you mean collapse the six categories into just two? In my case, I don't think theory would justify this option. Alternatively, did you suggest creating five dichotomies and treating them as categorical mediators simultaneously within the same model?
Or, create the five dichotomies and use sub-samples to test each condition versus the reference group separately when defining the mediating variable as categorical (e.g., Model 1 sub-sample: Cat1 vs. ref group; Model 2 sub-sample: Cat2 vs. ref group, etc.)?
Any clarification would be most helpful. Thank you in advance for your time.
 Bengt O. Muthen posted on Tuesday, May 31, 2011 - 8:36 am
Answers to your 3 paragraphs:

1. Yes, that's what I suggested. So for example "taking the bus" versus all other modes of transportation.

2. No, I don't suggest breaking up into several dummies - I don't know how that would be correctly analyzed in a mediation context.

3. I am not sure about this approach.

Perhaps you simply want to do a multiple-group analysis with the 5 categories, and forego the mediation aspect.
 Kesinee posted on Tuesday, October 11, 2011 - 3:31 pm
Dear Dr. Linda,

Regarding to your post on Monday, May 09, 2011 - 10:02 am

“MODEL INDIRECT for weighted least squares but no MODEL CONSTRAINT for maximum likelihood when:
x -> categorical -> categorical
x -> categorical -> continuous ”
Could you please give me, some references? Thank you.

Sincerely yours,
 Linda K. Muthen posted on Tuesday, October 11, 2011 - 5:58 pm
See Introduction to statistical mediation analysis by David MacKinnon.
 Kesinee posted on Wednesday, October 12, 2011 - 6:16 am
Dear Dr. Linda,

Thank you very much.

Sincerely yours,

 Selahadin Ibrahim posted on Monday, October 29, 2012 - 12:27 pm
Hi Dr. Muthen,

I have reviewed your paper here ( on nominal mediation.

I have an outcome which is continuous, and a mediator which is nominal with ten categories.

How reliable is the method described in the paper noted above when you have ten categories in the nominal mediator?

Thanks for considering this question,
 Bengt O. Muthen posted on Tuesday, October 30, 2012 - 5:35 pm
You should have a large enough number of observations in each category - how many is unknown without a simulation. I think the approach is cumbersome from an interpretation point of view with many categories.
 Selahadin Ibrahim posted on Wednesday, October 31, 2012 - 6:24 am
Thanks a lot

 Selahadin Ibrahim posted on Friday, January 25, 2013 - 5:55 am
Good morning Bengt,

In follow up to the question above, we were wondering if instead of a nominal mediator with ten categories, would a nominal mediator with three categories work?

More specifically, I have a dichotomous outcome with one nominal mediator (with three categories) and 9 dichotomous mediators. Eight of the nine dichotomous variables are thought to act on the outcome in a second level mediation through the ninth dichotomous variable (a->b->c->d). How feasible is the new causally-defined effects method for this complex model?

We feel confident that we have a large enough sample (with nearly 400k observations).

 Bengt O. Muthen posted on Friday, January 25, 2013 - 4:50 pm
Second-level (chained) causally-defined mediation with both nominal and binary mediators would be quite complex to set up I would think. Both the use of a nominal mediator and the use of a chain of mediators is new; I haven't seen applications of it. I would try to simplify the model or the analysis if possible.
 Selahadin Ibrahim posted on Monday, January 28, 2013 - 5:05 am
Thanks a lot.
 HwaYoung Lee posted on Thursday, June 20, 2013 - 9:22 am
Hi Drs. Muthen,

I have a categorical mediating variable (0/1) and one binary independent variable. Also, there were 16 covariate variables (dichotomous and continuous). A dependent variable is continuous variable.

I would like to calculate indirect effect.

Here is my code.

M on X;
Y on M;
Y on Cov1 to COV16;
X with COV1-COV16;
M with COV1-COV16;

Model Indirect:
Y ind M X;

Well, it didn't work.
Any suggestions?
 Linda K. Muthen posted on Thursday, June 20, 2013 - 12:12 pm
You get this message because you include the covariates in the model:

X with COV1-COV16;
M with COV1-COV16;

The model is estimated conditioned on the covariates. You should remove the above statements.
 HwaYoung Lee posted on Thursday, June 20, 2013 - 12:51 pm
Thank you for your suggestion.
Is there any way to include these paths?
The reason why I inlcuded all cov variables is that I would like to test whether the mediating variable impact the dependent variable controlling all covariate variables.
 Linda K. Muthen posted on Thursday, June 20, 2013 - 2:45 pm
The following two lines test the impact of m on y controlling for the exogenous covariates:

Y on M;
Y on Cov1 to COV16;

You don't need the WITH statements and should not include them.
 HwaYoung Lee posted on Monday, June 24, 2013 - 7:12 am
I really appreciate your help.

I have three more questions.
1) When I used bootstrap option, I coudldn't get CFI, TLI, RMSEA...but I got only WRMR. WRMR is 1.672 (I think it indicates that model fit is not good).
If I am interested in getting only indirect effects, is it okay to ignore poor model fit?
2)How can I get TLI, CFI.... and so on with bootstrap option?
3)When I looked at the diagram porvided from Mplus, all cov variables are correlated even though I didn't put the paths among those variables?
Could you explain why the diagram showed like this?

Again, thank you so much for your BIG help.
 Linda K. Muthen posted on Monday, June 24, 2013 - 11:21 am
The BOOTSTRAP option bootstraps only standard errors. Run the model without the BOOTSTRAP option to get the fit statistics. Ignore WRMR. It is an experimental fit statistic.

In regression, the model is estimated conditioned on the covariates. Their means, variances, and covariances are not model parameters. They are not uncorrelated during model estimation. This is why the arrows are in the diagram.
 HwaYoung Lee posted on Monday, June 24, 2013 - 11:35 am
Thank you Dr. Muthen.
This would be the last question.
I am only interested in mediating effects.

In the model, CFI=0.645; TLI=0.223;RMSEA=0.083.

Even though model fit is very very poor, can I use (or trust) parameter estimates (mediating effect)?

Thank you,
 HwaYoung Lee posted on Tuesday, June 25, 2013 - 9:56 am
Dear Dr. Muthen,
When I put the paths from 16 cov variabls to the mediating variable, CFI and TLI were 1.000. RMSEA is 0.

HOwever, the relationships between the mediating variable and 16 covs were not causal effects, but they have relationshps.
When I put <--> among covs and the mediating variable (M), the model didn't work. However, I put --> from covs to the M, the model worked really well.

Should I use --> (causal effect) instead of <--> (correlation) even though they are not causal effects?
 Linda K. Muthen posted on Tuesday, June 25, 2013 - 10:27 am
If model fit is poor, you cannot use the results for the mediation part of the model. Misfit means that the model does not represent the data well.

Your model should be based on theory not searching for a model that fits the data by experimentation.
 Lars Bocker posted on Wednesday, January 29, 2014 - 7:57 am
Dear Linda and Bengt,

In my model I have several independent variables which predict y through two mediators, one of which is nominal (m1).

m1 m2 y ON x1-x10;
y ON m1 m2;
m2 ON m1;

1) Would the only way to model this nominal mediator be through a mixture analysis latent class approach described in your paper on causal mediation? I have problems applying the corresponding syntax in table 50 and 51, particularly the model constraint part, to my model.

2) Or could my 4-category nominal mediator also be represented through specifying three (or four?) correlated dummies in one model? As the choice for one dummy excludes the choice for the others, I guess these correlations should be (very close to) -1.

3) Or would you advice me to simplify the nominal mediator into one dummy. This would be less ideal from a theoretical point of view, but might be the only feasible option.

Thanks in advance...

 Bengt O. Muthen posted on Wednesday, January 29, 2014 - 11:38 am
1) that would be the best way.

2) I haven't explored how well this would work.

3) Probably the easiest approach. And you would have to use WLSMV unless you take the causal approach, so that the mediator is a latent response variable and you get linear regressions for both mediator and distal.
 Amanda Pollitt posted on Friday, April 29, 2016 - 2:08 pm
Is there any way to do moderated mediation with a nominal mediator with multiple group analysis? Currently only one knownclass variable can be specified in Mplus.
 Bengt O. Muthen posted on Saturday, April 30, 2016 - 6:20 am
It's a little involved but you can combine the class variables of the nominal and the groups so that if you have 3 nominal categories and 2 groups you would have 6 classes for the single Knownclass variable. You just have to set the parameter restrictions right.
 Chris Cambron posted on Thursday, April 13, 2017 - 2:59 pm
Is there a way in Mplus to test for mediation where X is continuous, M is dichotomous, and Y is a count specified as negative binomial? As far as I understand from previous posts, a dichotomous M should be estimated using WLSMV but the negative binomial Y requires MLR. Thanks!
 Bengt O. Muthen posted on Thursday, April 13, 2017 - 4:34 pm
Use ML - this will give you the correct counterfactually-defined indirect and direct effects. The mediator will be treated as binary in both regressions but that is ok visavis the effects (see our new book).
 Chris Giebe posted on Friday, April 21, 2017 - 3:48 am

I am looking into using latent class membership as a nominal mediator (my predictor and outcome variables are both continuous).

I have been reading your causal mediation paper ( which refers in section 8 "Mediation modeling with a nominal mediator" to reference sections 13.4 for causal effects of a continuous outcome and 14.7 for Mplus syntax. However, these sections 13 and 14 seem to be omitted from the appendix.
I have also bought your book "regression and mediation analysis using Mplus" which contains a wonderful example 8.5.3. on data with a nominal mediator and a binary outcome. Both the MODEL part and MODEL CONSTRAINT seem very complex for my Mplus skills.

Do you know where I can find and example of input for a continuous predictor, nominal mediator, and continuous outcome? Is section 13.4 of the causal mediation paper available somewhere?
Or what changes would I have to do to the MODEL CONSTRAINT part of the nominal mediator, binary outcome example in your book to use a continuous outcome?

Thank in advance. -Chris
 Bengt O. Muthen posted on Friday, April 21, 2017 - 5:51 pm
You find the paper under

You will find what you search for by noting that there are 3 clicks here:

Muthén, B. (2011). Applications of causally defined direct and indirect effects in mediation analysis using SEM in Mplus. Click here to download the paper. 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.
 Chris Giebe posted on Tuesday, May 30, 2017 - 12:16 am
Thanks for providing the resources.
I do have a few follow-up questions based on the syntax in the appendix table 48: Input from step 2 y ON xm knownclass in the causal mediation paper:

(1) The example for a nominal M, continuous Y using a latent variable to represent M uses the knownclass option after step 1 of generating data. I have used step 1 of the manual BCH paper to generate a dataset with 4 latent classes I would like to use as the nominal mediator. Is it still appropriate to use knownclass when the latent classes aren't really known a priori?

(2) In the MODEL part: What are the numbers behind the * and where do they come from (ex. [c#1*-1](gamma01))? It looks like we're freeing up some parameters, but I'm not sure what this means and why those exact values are being used?

(3) Similarly, in the MODEL CONSTRAINTS: multinominal denominators (ex. NEW(denom0*1.9744 denom1*2.5585 ...)) are being created, but I'm again unsure of where those numbers come from.

For points (2) and (3): What kinds of changes do I have to make to extend this syntax from 3 to 4 classes?

Thanks again for your help.
 Bengt O. Muthen posted on Tuesday, May 30, 2017 - 5:46 pm
(1) Knownclass should not be used when the classes are unknown. The nominal mediation approach is appropriate also for unknown latent classes.

(2) - (3) Table 48 shows a Monte Carlo simulation study and in such studies the values after the * in Model statements give the true values used in the Monte Carlo summary. You wouldn't use such values in a real-data analysis.

Regarding your last question, you can simply say c on x and all classes will be regressed on x. The following statement don't need to be mentioned but are default in a real-data analysis:

[c#1*-1] (gamma01);
[c#2*-.5] (gamma02);

Because this is an advanced analysis you may want to consult with an Mplus mixture modeling expert. It can be hard to learn it step by step this way given that there is no explicit literature on it.
 Amanda Pollitt posted on Wednesday, May 31, 2017 - 8:33 am
Are the indirect effects estimates provided by the Mplus output correct for a model with binary x and m and continuous y considering the a and b paths are on different scales (WLSMV estimation)? Or should I use the equations in the counterfactual paper to calculate this correctly?
 Bengt O. Muthen posted on Wednesday, May 31, 2017 - 6:05 pm
I would use the counterfactual effects for this. See our new book.
 Geilson Lima Santana Junior posted on Monday, March 09, 2020 - 9:59 am
Hello, profs.

I am running a mediation model in which the predictor is an ordinal variable (included as dummies), the outcome is categorical and the 2 mediators are positve and negative affect, both were derived from Llikert Scales and their values vary from 11 to 50. I am considering positive and negative affect as continuous and using the estimator WLSMV, with delta parameterization and probit link.

My question is: Can I proceed this way? Is WLSMV appropriate for "continuous" non-normal variables? Or should I consider them ordinal variables? In this case, is it reasonable to divide tem into quartiles?
 Bengt O. Muthen posted on Monday, March 09, 2020 - 4:16 pm
I think the main issue here is that your outcome is categorical. Although perhaps you are saying that the 2 mediators are strongly non-normal, perhaps with a strong floor effect?
 Geilson Lima Santana Junior posted on Tuesday, March 10, 2020 - 9:01 am
Prof. Bengt, One of the mediators has a normal distribution (positive affect), but the other, no. Should I transform "negative affect" trying to make it more "normally distributed"? May I categorize it in quartiles, for example? Or is WLSMV appropriate for "Continuous" non-normal variables, such as negative affectivity in my study?

Thank you!
 Geilson Lima Santana Junior posted on Tuesday, March 10, 2020 - 9:21 am
Prof. Bengt, One of the mediators has a normal distribution (positive affect), but the other, no. Should I transform "negative affect" trying to make it more "normally distributed"? May I categorize it in quartiles, for example? Or is WLSMV appropriate for "Continuous" non-normal variables, such as negative affectivity in my study?

Thank you!
 Bengt O. Muthen posted on Tuesday, March 10, 2020 - 2:52 pm
Continuous non-normal is ok as long as you don't have a high percentage at the lowest (or highest) value (such as > 25%).
 Geilson Lima Santana Junior posted on Thursday, March 12, 2020 - 6:31 am
Ok! Great! Thank you very much, Prof. Bengt Muthen.
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