Function to estimate causal mediation effects.
medeff (equation 1) (equation 2) [if] [in] [[weight]] , [sims(integer) seed(integer) vce(vcetype) Level(#) interact)(varname) ] mediate(varname) treat(varname)
Description
medeff is the workhorse function for estimating mediation effects for a variety of data types. For a continuous mediator variable and a continuous outcome variable, the results will be identical to the usual Baron and Kenny method. The function can, however, accomodate other data types including binary outcomes and mediators and calculate the correct estimates.
SE/Robust
vce(vcetype)vcetype may be robust, cluster clustvar, bootstrap, or jackknife.
Options
sims(integer) specifies the number of simulations to run for the quasi-Bayesian approximation of parameter uncertainty. The default value is 1000. Higher values will increase the computational time.
seed(integer) sets the random number seed for precise replicability though with sufficient sims results will be very similar. The default value is the random seed Stata draws when starting a session.
vcetype(vcetype) allows users to specify how the standard errors will be calculated.
Level(#) sets the confidence interval; default is level(95).
interact(varname) allows for an interaction between the treatment and mediating variable. Interaction terms must be created prior to running and included in the model for the outcome variable.
mediate(varname) is required and specifies the mediating variable to be used in the analysis
treat(varname integer integer) is also required and specifies the treatment variable used in the analysis. The values of the treatment variable can be specified. If no values are specified, values of 0 and 1 are assumed.
Examples
. medeff (regress M T x) (regress Y T M x) , treat(T) mediate(M) sims(1000) seed(1) . medeff (probit M T x) (regress Y T M x) , treat(T) mediate(M) sims(1000) . medeff (regress M T x) (probit Y T M x) , treat(T) mediate(M) sims(1000) . medeff (regress M T x) (probit Y T M x) if x>0 , treat(T) mediate(M) sims(1000)
Remarks
medeff only supports OLS, probit, and logit in either stage of the analysis so far. Any estimation technique other than those will produce an error. After conducting mediation analysis users should conduct a formal sensitivity analysis and report these results (see medsens). Currently the mediate function does not handle interactions between pre-treatment x variables and either the treatment or mediator. A requirement for causal mediation analysis is that the same observations are used in the mediator and outcome regressions. The function will automatically restrict samples in order to do this.
Saved results
The program stores the Average Causal Mediation Effect (ACME) in the scalars r(delta0) and r(delta0). The direct effects are stored in r(zeta0) and r(zeta1) and the total effect is stored in r(tau). For each of these, the low and high bounds of the confidence interval are stored in the lo and hi scalars.
Authors Raymond Hicks Niehaus Center for Globalization and Governance, Princeton University Dustin Tingley Government Department, Harvard University Email rhicks@princeton.edu or dtingley@gov.harvard.edu if you observe any probl > ems. Please cite upon use: Hicks, Raymond and Dustin Tingley (2011) mediation: STATA package for causal mediation analysis, as well as the below journal articles that form the theoretical basis of the package.
Also see
Further details on the analytical formulas and on the algorithms used in these programs can be found under http://imai.princeton.edu/projects/mechanisms.html
Bibliography and Sources
The procedures used for estimation are discussed extensively elsewhere.
Imai, Kosuke, Luke Keele and Dustin Tingley (2010) A General Approach to Causal Mediation Analysis, Psychological Methods 15(4) pp. 309-334.
Imai, Kosuke, Luke Keele and Teppei Yamamoto (2010) Identification, Inference, and Sensitivity Analysis for Causal Mediation Effects, Statistical Sciences, 25(1) pp. 51-71.
Imai, Kosuke, Luke Keele, Dustin Tingley, and Teppei Yamamoto. (2009) "Causal Mediation Analysis Using R" in Advances in Social Science Research Using R, ed. H. D. Vinod New York: Springer. Forthcoming.
A companion package in R is available at http://cran.r-project.org/web/packages/mediation/.