Description Usage Arguments Value Author(s) References See Also Examples
View source: R/main_function.R
The main function for estimating the average treatment effect or the average
treatment effect on the treated. This function creates an ATE
object
which can be used as inputs for generic S3 plot
or summary
functions. This function uses a covariate balancing method which creates
weights for each subject, without a need to specific a propensity score
or an outcome regression model. The main function implements the BFGS
algorithm with backtracking. For details of the estimator
see Chan et al. (2015).
1 2 3 4 5 |
Y |
The response vector of length n. This has to be a numeric vector. |
treat |
The vector of treatment assignments of length n. Must be
coded as {0, 1, ...} and must be binary
vector when |
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). See |
ATT |
A logical value indicating whether to estimate the treatment effect on the treated. |
verbose |
A logical value indicating whether to print the progress of the function.
Default value is |
max.iter |
The maximum number of iterations for the BFGS algorithm. |
tol |
The absolute tolerance used to determine a stopping criteria for the BFGS algorithm. |
initial.values |
A numeric vector or matrix of possible initial values for the BFGS algorithm.
Must be a J x K matrix where J is the number
of treatment arms. For |
backtrack.alpha |
A scalar parameter for the backtracking line search algorithm with α in (0,0.5). |
backtrack.beta |
A scalar parameter for for the backtracking line search algorithm with β in (0,1). |
The function reruns an object of type 'ATE'
, a list with the following elements
estimate |
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. |
lambda |
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 |
converge |
A logical value indicating convergence of BFGS algorithm. |
X, Y, treat |
The data used for estimation. |
J |
A scalar indicating the number of treatment arms. |
K |
A scalar indicating the one plus the dimension of the range space of X. K = 1 + p. |
call |
The matched call. |
Asad Haris, Gary Chan.
Chan, K. C. G. and Yam, S. C. P. and Zhang, Z. (2015). "Globally Efficient Nonparametric Inference of Average Treatment Effects by Empirical Balancing Calibration Weighting", under revision.
Haris, Asad and Chan, K. C. G. (2015). "ATE: An R
package for Nonparametric Inference of Average Treatment Effects", under revision
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | library(ATE)
# Binary treatment.
set.seed(25)
n <- 200
Z <- matrix(rnorm(4 * n), ncol = 4, nrow = n)
prop <- 1 / (1 + exp(Z[, 1] - 0.5 * Z[, 2] + 0.25 * Z[, 3] + 0.1 * Z[, 4]))
treat <- rbinom(n, 1, prop)
Y <- 200 + 10 * treat + (1.5 * treat - 0.5) *
(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 average treatment effects (ATE).
fit1 <- ATE(Y, treat, X)
summary(fit1)
# plot(fit1)
# Estimation of average treatment effects on treated (ATT).
fit2 <- ATE(Y, treat, X, ATT = TRUE)
summary(fit2)
# plot(fit2)
# Four treatment groups.
set.seed(25)
n <- 200
Z <- matrix(rnorm(4 * n), ncol = 4, nrow = n)
prop1 <- 1 / (1 + exp(1 + Z[, 1] - 0.5 * Z[, 2] + 0.25 * Z[, 3] + 0.1 * Z[, 4]))
prop2 <- 1 / (1 + exp(Z[, 1] - 0.5 * Z[, 2] + 0.25 * Z[, 3] + 0.1 * Z[, 4]))
U <- runif(n)
treat <- numeric(n)
treat[U > (1 - prop2)] = 2
treat[U < (1 - prop2) & U > (prop2 - prop1)] = 1
Y <- 210 + 10 * treat + (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)
fit3 <- ATE(Y, treat, X)
summary(fit3)
# plot(fit3)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.