Multiple Mediation in Stata

This post will show how to test a mediation model with more than one mediator using Stata. In order to illustrate it, I will build on the example I used in my simple mediation post by adding job anxiety as an additional  mediator of the path between work incentives and job performance . In other words, my hypothesis is that both satisfaction and anxiety in the workplace mediate the relationship between work incentives and job performance.


CASE 1: No latent variables

Assuming the simple case in which all variables are observed, i.e. there are no latent variables, the following command syntax will fit the mediation model above:

 sem (satisfaction<-incentives)(anxiety<-incentives)(performance<-satisfaction anxiety incentives)

The direct effect of work incentives on job performance is estimated by the coefficient for performance<-incentives, indicated by c’ in the diagram.

Notice that in order to compute the indirect effect we now need to take into account that it is split into two paths, the path through satisfaction (mediator 1) and the path through anxiety (mediator 2).

The indirect effect through job satisfaction is estimated by the product of the coefficient for satisfaction<-incentives (a1) and the coefficient for performance<-satisfaction (b1), which we will the a1b1 product. Likewise, the indirect effect through anxiety is estimated by the product of the coefficient for anxiety<-incentives (a2) and the coefficient for performance<-anxiety (b2). We call this product: a2b2 .

The overall indirect effect is defined as the sum of both products:

Indirect effect = a1b1 + a2b2

Using the nlcom Stata command, already introduced in the previous post, the syntax to compute the individual and overall indirect effect for this example is:

nlcom b[satisfaction:incentives]*b[performance:satisfaction] // through satisfaction
nlcom b[anxiety:incentives]*b[performance:anxiety] // through anxiety
nlcom (b[satisfaction:incentives]*b[performance:satisfaction] + b[anxiety:incentives]*b[performance:anxiety]) // overall indirect effect

The total effect is defined as direct effect plus indirect effect

c=c’+ a1b1 + a2b2

and in Stata syntax, is computed as:

nlcom _b[performance:incentives]+ (b[satisfaction:incentives]*b[performance:satisfaction]+b[anxiety:incentives]*b[performance:anxiety])

Let’s assume now that our study variables are latent, in other words, we measure them through a list of items (e.g. commonly job satisfaction is measured through Likert scale survey questions). Continuing to expand on our previous example, let’s assume that our new construct anxiety is measured by 4 likert-scale questions.

The model with latent variables is drawn as


The following syntax shows how to incorporate the measurement model into the SEM equations:

sem (satis1 satis2 satis3 satis4 <-Satisfaction) // measurement piece
(incen1 incen2 incen3 <- Incentives) (perf1 perf2 <-Performance) // measurement piece
(anx1 anx2 anx3 anx4 <- Anxiety) //measurement piece
(Satisfaction<-Incentives)(Anxiety<-Incentives)(Performance<-Satisfaction Anxiety Incentives) // structural piece

I would like to end with a final note. Sometimes, the algorithms used to solve these models fail to converge. If several attempts such as changing the algorithm starting values, adding constraints, etc, fail to succeed, a simple way out is to compute the scales for each construct from its corresponding items and use the new scales to fit a SEM model with no latent variables (i.e. no measurement model piece).

About raquelandres75

I am an statistician/researcher who has decided to make a living by dedicating myself to help others who struggle with statistics.
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply