Skip to content

davidahirshberg/amlinear

Repository files navigation

amlinear: Augmented Minimax Linear Estimation

This package implements the augmented minimax linear estimator (AML) for estimating average partial effects, as proposed by Hirshberg and Wager (2017). We consider a setup where we observe data (X, Y, W) generated according to a conditionally linear model,

Y = f(X) + W tau(X) + noise

and want to estimate the average effect theta = E[tau(X)] (both W and Y are taken to be real valued). In the case where W is binary, then theta corresponds to the average treatment effect under unconfoundedness, and our AML estimator is closely related to approximate residual balancing as implemented in balanceHD.

This package is incompatible with the current version of glmnet.
To install the most recent compatible version, run the following command.

devtools::install_version("glmnet", "2.0-18")

It is, to some degree, incompatible with the current version of CVXR as well. That seems to depend on other configuration options. In any case, installing CVXR as follows seems to work.

devtools::install_version("CVXR", "0.99-7")

To install the package itself, run the following command.

devtools::install_github("davidahirshberg/amlinear")

Example usage:

library(amlinear)

n = 300; p = 600; nclust = 10
beta = 2 / (1:p) / sqrt(sum(1/(1:p)^2))
clust.alpha = rep(c(0.3, 0.7), nclust/2)
cluster.center = 0.5 * matrix(rnorm(nclust * p), nclust, p)
cluster = sample.int(nclust, n, replace = TRUE)

X = cluster.center[cluster,] + matrix(rnorm(n * p), n, p)
W = rbeta(n, clust.alpha[cluster], 1 - clust.alpha[cluster])
Y = X %*% beta + rnorm(n, 0, 1) + 2 * W * X[,2]

tau.hat = average_partial_effect(X, Y, W)
print(paste("true tau:", round(mean(2 * cluster.center[,2]), 2)))
print(paste("point estimate:", round(tau.hat[1], 2)))
print(paste0("95% CI for tau: (", round(tau.hat[1] - 1.96 * tau.hat[2], 2), ", ", round(tau.hat[1] + 1.96 * tau.hat[2], 2), ")"))

References

David Hirshberg and Stefan Wager. Augmented Minimax Linear Estimation. The Annals of Statistics, 49(6), 2021. [arxiv]

About

Augmented minimax linear estimation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published