= 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 [[Statistics/Moderator|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 [[Analysis/BernoulliDistribution|Bernoulli distribution]] is handled as a special case of the [[Analysis/BinomialDistribution|Binomial distribution]]. Note furthermore the similarities between this and [[Statistics/Confounder|confounding]]. Consider now the more general case, where some but not all causation is mediated. This can be explained visually as: {{attachment:path.png}} The causal effects are: * '''direct effect''' of ''X'' on ''Y'' = ''β,,1,,'' * direct effect of ''X'' on ''M'' = ''β,,2,,'' * direct effect of ''M'' on ''Y'' = ''β,,3,,'' * '''indirect effect''' of ''X'' on ''Y'' = ''β,,2,,*β,,3,,'' * '''total effect''' of ''X'' on ''Y'' = ''β,,1,, + (β,,2,,*β,,3,,)'' See [[Statistics/MediationAnalysis|here]] for analysis of this system. ---- CategoryRicottone