Home  /  Stata News  /  Vol 39 No 1  /  In the spotlight: Disentangling causal mechanisms by using causal mediation models
The Stata News

«Back to main page

In the spotlight: Disentangling causal mechanisms by using causal mediation models

Research problems across disciplines are often based on questions that are causal in nature.

  • Does increasing the price of sugary drinks lead to a decline in their consumption?
  • Will increased penalties for certain crimes help prevent those crimes?
  • Does this new drug help cure a certain disease?

The causal inference literature provides a variety of techniques with which to tackle such questions statistically.

However, these types of causal questions can be taken a step further. In addition to finding out whether some event causes some outcome of interest, we may wonder why that is so. Could there be an underlying mechanism that would explain the causal relationship we observe? To answer such questions, we need a causal mediation model, which aims to identify a causal effect and disentangle it into direct and indirect components. In this context, indirect effects are effects that follow a causal pathway from some cause to the outcome of interest through another variable, a mediator. Direct effects, on the other hand, provide a measure of the causal effect that is due to mechanisms other than the one captured by the mediator.

For example, suppose we recently did a study and found that physical exercise leads to an increase in subjective well-being. While this could be an important result in its own right, we may wonder why this is the case. What is the underlying mechanism that connects physical exercise to well-being? We pretend that one member of our research team has heard about a hormone that was found to be strongly related to well-being. Could it be that exercise leads to higher levels of that hormone in the human body, which leads to an increase in well-being?

Suppose we did an additional study and now have some data to address this question:

. use https://www.stata-press.com/data/r18/wellbeing.dta
(Fictional well-being data)

. list wellbeing bonotonin exercise in 1/5, abbreviate(10)

wellbeing bonotonin exercise
1. 71.73816 196.5467 Control
2. 68.66573 195.8572 Exercise
3. 71.05155 228.6035 Exercise
4. 69.44469 206.6651 Exercise
5. 75.62035 261.6855 Exercise

This excerpt of the fictional dataset shows our main variables of interest: wellbeing is the outcome of interest and measures well-being on a (theoretical) scale ranging from 0 to 100. bonotonin is the hormone as measured in ng/mL according to the participants' blood samples; this is our mediator. Finally, exercise is a binary variable indicating treatment status.

Here about half the subjects were assigned to participate in some physical exercise, while the remaining subjects spent the same amount of time in a resting state. In addition, well-being and bonotonin were measured prior to the experiment such that we can control for their respective baseline levels. Because the design of the study is that of a randomized experiment, or randomized controlled trial, we do not have to be concerned about treatment-mediator or treatment-outcome confounders. That is, because of the randomization with respect to the treatment condition, we are not worried about confounding variables that affect the relationship between treatment and outcome or treatment and mediator. However, we do have to be concerned about mediator-outcome confounders because bonotonin levels were not controlled for as part of the experimental design. Here we control for age, gender, and health status—variables which could be related to both bonotonin levels and well-being.

This leads us to the following model specification using the mediate command. We specify a linear model for the outcome (first set of parentheses), a linear model for the mediator (second set of parentheses), and the treatment variable (third set of parentheses). By default, mediate includes a treatment-mediator interaction term in the outcome equation to allow the effect of the mediator on the outcome to vary by treatment group. In this case, however, we wish to assume that the effect of bonotonin on well-being does not depend on the experimental condition, so we specify the nointeraction option:

. mediate (wellbeing basewell age i.gender i.hstatus) (bonotonin basebono) 
     (exercise), nointeraction

Iteration 0:  EE criterion =  3.966e-28  
Iteration 1:  EE criterion =  1.119e-28  

Causal mediation analysis                                Number of obs = 2,000

Outcome model:     Linear
Mediator model:    Linear
Mediator variable: bonotonin
Treatment type:    Binary
Robust
wellbeing Coefficient std. err. z P>|z| [95% conf. interval]
NIE
exercise
(Exercise
vs
Control) 9.898804 .2170373 45.61 0.000 9.473418 10.32419
NDE
exercise
(Exercise
vs
Control) 3.126407 .1544052 20.25 0.000 2.823778 3.429035
TE
exercise
(Exercise
vs
Control) 13.02521 .2357093 55.26 0.000 12.56323 13.48719
Note: Outcome equation does not include treatment-mediator interaction.

The output provides us with three estimated treatment effects: the total effect (TE), which is the total average treatment effect, as well as its decomposition into a direct (NDE, natural direct effect) and an indirect (NIE, natural indirect effect) average treatment effect. Notice that TE = NIE + NDE. The TE here is 13 and is interpreted in the same way as average treatment effects in other contexts. That is, if everyone in the population were to exercise, the average well-being would be higher by 13 points compared with the case where no one exercises. By looking at the decomposition into direct and indirect effects, we can answer our research question: Almost 10 points of the 13-point increase in well-being is due to increased bonotonin levels, and only a little over 3 points is due to other mechanisms. We could also evaluate the strength of the mediation by calculating the proportion of the effect of exercise on well-being that is mediated by increased bonotonin levels by using the estat proportion postestimation command:

. estat proportion

Proportion mediated                                      Number of obs = 2,000
Robust
wellbeing Proportion std. err. z P>|z| [95% conf. interval]
exercise
(Exercise
vs
Control) .7599726 .0106631 71.27 0.000 .7390733 .780872

We can see that 76% of the total effect of exercise on well-being is due to increased bonotonin levels.

In this example, we used the default linear model for both the outcome and the mediator. However, mediate allows us to choose from several models that can be freely combined between outcome and mediator equations. For example, if we had a binary outcome variable and a count mediator variable, we could specify a logit or probit model for the outcome and a Poisson or exponential mean model for the mediator. Note, however, that regardless of what models we specify, the estimated effects are population average treatment effects measured on the scale of the outcome variable, so their interpretation remains the same. For example, if the outcome were binary, we would interpret the effects on the probability scale. To illustrate, suppose our outcome represents an increase of at least 10% in well-being from the baseline. In this case, we could specify a probit model for the binary outcome but still use a linear model for the mediator:

. mediate (bwellbeing age i.gender i.hstatus, probit) (bonotonin basebono) 
     (exercise), nointeraction

Iteration 0:  EE criterion =  1.797e-27  
Iteration 1:  EE criterion =  1.030e-28  

Causal mediation analysis                                Number of obs = 2,000

Outcome model:     Probit
Mediator model:    Linear
Mediator variable: bonotonin
Treatment type:    Binary
Robust
bwellbeing Coefficient std. err. z P>|z| [95% conf. interval]
NIE
exercise
(Exercise
vs
Control) .2353956 .0115883 20.31 0.000 .2126829 .2581083
NDE
exercise
(Exercise
vs
Control) .0330115 .0219704 1.50 0.133 -.0100498 .0760728
TE
exercise
(Exercise
vs
Control) .2684071 .0201016 13.35 0.000 .2290086 .3078056
Note: Outcome equation does not include treatment-mediator interaction.

The total average treatment effect here is 0.27, which is to be interpreted as a risk difference: if everyone in the population were to exercise, the average probability of experiencing an increase in well-being would be 0.27 points higher compared with the case where no one exercises. Looking at the natural indirect effect, we can see that the increase in bonotonin accounts for roughly 0.24 points on the probability scale.

As an aside, instead of risk differences, we could also compute marginal risk ratios or odds ratios using postestimation commands estat rr and estat or, respectively. estat rr can also be used with a Poisson outcome model to compute the effects on the scale of rate ratios.

mediate has several other features that we have not touched upon here. For example, in addition to binary treatments, mediate supports multivalued and continuous treatments. The command also allows for flexible model specifications because additional interactions involving treatment or mediator variables are easily specified using Stata's factor-variable notation. For further discussion and more examples, look at the mediate manual entry; see [CAUSAL] mediate.

— Joerg Luedicke
Senior Social Scientist and Software Developer

«Back to main page