MB | R Documentation |
Mahalanobis balancing is a multivariate perspective of approximate covariate balancing method to estimate average treatment effect.
MB( x, treat, group1, group2 = NA, outcome, method = "MB", delta.space = c(0.1, 0.01, 0.001, 1e-04, 1e-05, 1e-06), iterations = 1000 )
x |
covariates. |
treat |
treatment indicator vector. |
group1 |
see Details. |
group2 |
see Details, Default: NA. |
outcome |
outcome vector. |
method |
a string that takes values in "MB", "MB2", "kernelMB". See Details. Default: 'MB'. |
delta.space |
tuning parameter in balancing. See Details. Default: c(1e-1, 1e-2, 1e-3, 1e-4, 1e-5, 1e-6). |
iterations |
iteration time in optimization problem, Default: 1000. |
group1
and group0
To estimate E(Y (1)) (average treatment effect for group 1),
you need to set group1
= 1 and ignore group2
. Similarly,
To estimate E(Y (0)) (average treatment effect for group 0),
you need to set group1
= 0 and ignore group2
.
To estimate average treatment effect on the control group E(Y (1) | T = 0),
you need to set group1
= 1 and group2
= 0. Similarly, To estimate
average treatment effect on the treated group E(Y (0) | T = 1),
you need to set group1
= 0 and group2
= 1.
This function is feasible when there are more than two groups.
method
can be a valid string, including
"MB": We choose the weighting matrix {W}_1=[diag(\hat{Σ})]^{-1} where \hat{Σ} denotes sample covariance matrix.
"MB2": We choose the weighting matrix {W}_2={[\hat{Σ}]^{-1}} where \hat{Σ} denotes sample covariance matrix.
"kernelMB": Firstly, we modify our covariate to X_i* = (Φ(X_1,X_i), ..., Φ(X_n,X_i)), then we apply method "MB" to produce Mahalanobis balancing weights.
delta.space
grid of values for the tuning parameter, a vector of
candidate values for the degree of approximate covariate balance. The default
is c(1e-1, 1e-2, 1e-3, 1e-4, 1e-5, 1e-6).
a MB object with the following attributes:
AT: the estimate of average treatment effect in group1 (i.e, E(Y(group1))).
weight: the estimated Mahalanobis balancing weight.
GMIM: Generalized Multivariate Imbalance Measure that defines in our paper.
delta: the tuning parameter we choose.
##estimating ATE## set.seed(0521) data <- si.data() result1 <- MB(x = data$X, treat = data$Tr, group1 = 1, outcome = data$Y, method = "MB") result2 <- MB(x = data$X, treat = data$Tr, group1 = 0, outcome = data$Y, method = "MB") ##an estimate of ATE result1$AT - result2$AT ##estimating ATC## result3 <- MB(x = data$X, treat = data$Tr, group1 = 1, group2 = 0, outcome = data$Y, method = "MB") ##an estimate of ATC result3$AT - mean(data$Y[data$Tr == 0])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.