The code to reproduce the figures in the manuscript "Model selection for estimation of causal parameters" can be found in simulations.R.
This package provides a function for selecting among a set of estimators, if the goal is to minimize the mean-squared error with respect to a finite-dimensional parameter of interest.
install.packages("devtools")
.devtools::install_github("rothenhaeusler/tms")
.n <- 100
Tr <- rbinom(n,1,.5)
X <- .5*Tr + rnorm(n)
Y <- .5*X + rnorm(n) + .01*Tr
df <- as.data.frame(cbind(Tr,X,Y))
surrogate_estimator <- function(df) coef(lm(Y~X,data=df))[2]*coef(lm(X~Tr,data=df))[2]
difference_in_means <- function(df) coef(lm(Y~Tr,data=df))[2]
# The first argument should be an asymptotically unbiased estimator for the parameter of interest; it serves as a benchmark.
tms(difference_in_means,surrogate_estimator,df)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.