BestLinearProj: Best linear projection of conditional average treatment...

View source: R/BestLinearProj.R

BestLinearProjR Documentation

Best linear projection of conditional average treatment effect estimates

Description

Best linear projection of conditional average treatment effect estimates

Usage

BestLinearProj(
  myfit,
  coord_df,
  coord_id,
  site,
  treat,
  outcome,
  covars,
  subset = NULL,
  site_enc_tab = NULL,
  debiasing.weights = NULL,
  num.trees.for.weights = 500,
  vcov.type = "HC3"
)

Arguments

myfit

A fitted ensemble tree or forest.

coord_df

Data of coordinating site ('data.table').

coord_id

Site index for coordinating site.

site

Variable name for site indicator.

treat

Variable name for binary treatment.

outcome

Variable name for the outcome.

covars

A vector of covariate names used.

subset

Specifies subset of the training examples over which we estimate the ATE. WARNING: For valid statistical performance, the subset should be defined only using features Xi, not using the treatment Wi or the outcome Yi.

site_enc_tab

A data.table of mean outcome for each site. Default is NULL. If class of myfit is a 'grf', "site_enc_tab" should not be NULL.

debiasing.weights

(ignore, only equal weights are supported in current version) A vector of length n (or the subset length) of debiasing weights. If NULL (default) these are obtained via the appropriate doubly robust score construction, e.g., in the case of causal_forests with a binary treatment, they are obtained via inverse-propensity weighting.

num.trees.for.weights

(ignore, only equal weights are supported in current version) In some cases (e.g., with causal forests with a continuous treatment), we need to train auxiliary forests to learn debiasing weights. This is the number of trees used for this task. Note: this argument is only used when 'debiasing.weights' = NULL.

vcov.type

Optional covariance type for standard errors. The possible options are HC0, ..., HC3. The default is "HC3", which is recommended in small samples and corresponds to the "shortcut formula" for the jackknife (see MacKinnon & White for more discussion, and Cameron & Miller for a review). For large data sets with clusters, "HC0" or "HC1" are significantly faster to compute.

Value

An estimate of the best linear projection, along with coefficient standard errors.

Note

The function is modified based on the R package 'grf' https://github.com/grf-labs/grf/blob/master/r-package/grf/R/forest_summary.R.

References

Cameron, A. Colin, and Douglas L. Miller. "A practitioner's guide to cluster-robust inference." Journal of human resources 50, no. 2 (2015): 317-372.

MacKinnon, James G., and Halbert White. "Some heteroskedasticity-consistent covariance matrix estimators with improved finite sample properties." Journal of Econometrics 29.3 (1985): 305-325.

Semenova, Vira, and Victor Chernozhukov. "Debiased Machine Learning of Conditional Average Treatment Effects and Other Causal Functions". The Econometrics Journal (2020).

Examples

data(SimDataLst)
K <- length(SimDataLst)
covars <- grep("^X", names(SimDataLst[[1]]), value=TRUE)
fit_lst <- list()
for (k in 1:K) {
    tmpdf <- SimDataLst[[k]]
    fit_lst[[k]] <- grf::causal_forest(X=as.matrix(tmpdf[, covars, with=FALSE]),
                                       Y=tmpdf$Y, W=tmpdf$Z)
}
coord_id <- 1
coord_df <- SimDataLst[[coord_id]]
aug_df <- GenAugData(coord_id, coord_df, fit_lst, covars)

## ensemble forest
# Treat each site as a distinct factor
myfit <- EnsemForest(coord_id, aug_df, "site", covars)$myfit
BestLinearProj(myfit, coord_df, coord_id, "site", "Z", "Y", covars)

# Mean encoding as surrogate for site index
res_ef <- EnsemForest(coord_id, aug_df, "site", covars, is_encode=TRUE)
myfit <- res_ef$myfit
site_enc_tab <- res_ef$site_enc_tab
BestLinearProj(myfit, coord_df, coord_id, "site", "Z", "Y", covars, site_enc_tab=site_enc_tab)

## ensemble tree
myfit <- EnsemTree(coord_id, aug_df, "site", covars)$myfit
BestLinearProj(myfit, coord_df, coord_id, "site", "Z", "Y", covars)



ellenxtan/ifedtree documentation built on March 28, 2023, 9:09 a.m.