Mediator

A mediator is a variable M that is caused by some variable X and itself causes a variable Y.

Not to be confused with a moderator.


Description

Mediators are one possible failure of causal inference. An association has been identified between two variables, X and Y, but in actuality there is a mediator M between them. X causes M and M causes Y. This is called mediation.

First, consider the case where the mediator explains all causation. In this example, controlling for M explains all correlation.

> X <- rbinom(1000, 1, 0.5)
> M <- rbinom(1000, 1, 0.9*(1-X) + 0.1*X)
> Y <- rbinom(1000, 1, 0.9*(1-M) + 0.1*M)
> cor(X,Y)
[1] 0.6440206
> cor(X[Z==1], Y[Z==1])
[1] 0.02818287
> cor(X[Z==0], Y[Z==0])
[1] 0.0464756

Note that in R, the Bernoulli distribution is handled as a special case of the Binomial distribution. Note furthermore the similarities between this and confounding.

Consider now the more general case, where some but not all causation is mediated. This can be explained visually as:

path.png

The causal effects are:

See here for analysis of this system.


CategoryRicottone

Statistics/Mediator (last edited 2026-02-17 16:58:26 by DominicRicottone)