= Mediation Analysis = '''Mediation analysis''' is a decomposition of causal effects with [[Statistics/Mediator|mediation]]. <> ---- == Background == [[Statistics/Mediator|Mediation]] looks like the following diagram. {{attachment:path.png}} where the true causal effects are as follows: * '''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,,)'' ---- == Description == === Sobel Test === The [[Statistics/SobelTest|Sobel test]] is a common approach for identifying and decomposing the mediated effects. This example uses the [[R/Multilevel|multilevel package]]: {{{ library(multilevel) sorel(data$X, data$M, data$Y) }}} This displays: * the component models, including the estimated coefficients and intercepts * the indirect effect * the pooled standard error * the calculated Z statistic === Bootstrapping === A bootstrapping approach is more accurate. This example also uses the [[R/Mediation|mediation package]]: {{{ XonY <- lm(Y ~ X, data = data) XonM <- lm(M ~ X, data = data) XMonY <- lm(Y ~ X + M, data = data) library(mediation) mediate(XonM, XMonY, treat='X', mediator='M', boot=TRUE, sims=500) }}} This displays: * the '''average causal mediation effects''' ('''ACME'''), the key measure of this bootstrapping method * if significantly different than 0, then there is a significant '''mediation effect''' * the '''average direct effects''' ('''ADE''') * the total effect * ''total effect = ACME + ADE'' * the proportion of the total effect that was mediated * ''prop = ACME / total effect'' ---- CategoryRicottone