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.
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