Description Usage Arguments Value Author(s) References See Also Examples
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.
1 2 3 4 |
Y |
The response vector of length n. This has to be a numeric vector. |
Ti |
The vector of treatment assignments of length n. Must be coded as \{0,1 0,1. |
M |
A n x q-matrix of mediators |
X |
A n x p-matrix of covariates |
theta |
A real scalar parameter for the Cressie-Read family of objective functions. The default is θ=0 (exponential tilting). Other popular examples are θ=-1 (empirical likelihood) and θ=1 (quadratic loss). |
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 ρ and u) convergence of Newton-Raphson should be fairly quick. |
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 α in (0,0.5). |
backtrack.beta |
A scalar parameter for backtracking with β in (0,1). |
... |
Additional arguments. |
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, hat{λ}, as described in Chan et al.(2015). In the case of a simple, binary treatment study, the object has |
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 ρ used for estimation along with the first and second derivatives. |
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. |
Gary Chan, based on package ATE developed with Asad Haris.
Chan, K. C. G., Imai, K, Yam, S. C. P. and Zhang, Z. (2016). "Efficient Nonpmarametric Estimation of Causal Mediation Effects.", under review.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.