MED {MED} | R Documentation |
Estimate the Natural Indirect and Direct Effects
Description
The main function for estimating the natural direct and indirect effects. This function creates an MED
object which can be used as inputs for generic S3 summary
function. This function uses a covariate balancing method which creates weights for each subject, without a need to specify a propensity score, mediator regression or outcome regression models. The main function depends on a Newton-Raphson algorithm with backtracking.
Usage
MED (Y, Ti, M, X, theta = 0, verbose = FALSE,
PIE = FALSE, max.iter = 100, tol = 1e-10,
backtrack = TRUE, backtrack.alpha = 0.3,
backtrack.beta = 0.5, ...)
Arguments
Y |
The response vector of length |
Ti |
The vector of treatment assignments of length |
M |
A |
X |
A |
theta |
A real scalar parameter for the Cressie-Read family of objective functions. The default is |
verbose |
A logical value indicating whether to print the progress of the function. |
PIE |
A logical value indicating whether to estimate the pure indirect effect. |
max.iter |
The maximum number of iterations for the Newton-Raphson methods. For most problems (e.g. with well-behaved functions |
tol |
The absolute tolerance used to determine a stopping criteria for the Newton-Raphson algorithm. |
backtrack |
A logical value indicating whether to use backtracking in the Newton-Raphson algorithm. |
backtrack.alpha |
A scalar parameter for backtracking with |
backtrack.beta |
A scalar parameter for backtracking with |
... |
Additional arguments. |
Value
The function reruns an object of type "MED", a list with the following elements
est |
The vector of point estimates for the average treatment effect. For a binary treatment it also contains the average difference of treatment effects. |
vcov |
The estimated variance covariance matrix for the estimates of the treatment effects for each treatment group. |
lam |
The resulting solution of the main optimization problems, |
weights |
The weights obtained by the balancing covariate method for each treatment group. In the case of |
gp |
A string specifying the type of study design. For binary treatment effect with |
conv |
A logical value indicating convergence of Newton-Raphson algorithm. |
X , Y , Ti |
The data which was used for estimation. |
rho , rho1 , rho2 |
The Cressie-Read functions |
FUNu |
A function that append a vector of constants to the covariates. Required to make sure that the weights sum to 1 in each group. |
J |
A scalar indicating the number of treatment arms. |
K |
A scalar indicating the one plus the dimension of the range space of X. |
call |
The matched call. |
Author(s)
Gary Chan, based on package ATE developed with Asad Haris.
References
Chan, K. C. G., Imai, K, Yam, S. C. P. and Zhang, Z. (2016). "Efficient Nonpmarametric Estimation of Causal Mediation Effects.", under review.
See Also
Examples
library(MED)
#binary treatment and binary mediator
set.seed(25)
n <- 200
Z <- matrix(rnorm(4*n),ncol=4,nrow=n)
prop.e <- 1 / (1 + exp(Z[,1] - 0.5 * Z[,2] + 0.25*Z[,3] + 0.1 * Z[,4]))
treat <- rbinom(n, 1, prop.e)
prop.m <- 1 / (1 + exp(-(0.5 - Z[,1] + 0.5 * Z[,2] - 0.9 *Z [,3] + Z[,4] - 1.5 * treat)))
M <- rbinom(n, 1, prop.m)
Y <- 200 + treat + M + 27.4*Z[,1] + 13.7*Z[,2] +
13.7*Z[,3] + 13.7*Z[,4] + rnorm(n)
X <- cbind(exp(Z[,1])/2,Z[,2]/(1+exp(Z[,1])),
(Z[,1]*Z[,3]/25+0.6)^3,(Z[,2]+Z[,4]+20)^2)
#estimation of natural mediation effecs
fit1<-MED(Y,treat,M,X)
summary(fit1)