setup_X1: Setup function controlling the matrix X_1 in the BLP or GATES...

View source: R/initializers.R

setup_X1R Documentation

Setup function controlling the matrix X_1 in the BLP or GATES regression

Description

Returns a list with three elements. The first element of the list, funs_Z, controls which functions of matrix Z are used as regressors in X_1. The second element, covariates, is an optional matrix of custom covariates that shall be included in X_1. The third element, fixed_effects, controls the inclusion of fixed effects.

Usage

setup_X1(funs_Z = c("B"), covariates = NULL, fixed_effects = NULL)

Arguments

funs_Z

Character vector controlling the functions of Z to be included in X_1. Subset of c("S", "B", "p"), where "p" corresponds to the propensity scores, "B" to the proxy baseline estimates, and "S" to the proxy CATE estimates. Default is "B".

covariates

Optional numeric matrix containing additional covariates to be included in X_1. Default is NULL.

fixed_effects

Numeric vector of integers that indicates cluster membership of the observations: For each cluster, a fixed effect will be added. Default is NULL for no fixed effects.

Details

The output of this setup function is intended to be used as argument in the functions GenericML() and GenericML_single() (arguments X1_BLP, X1_GATES), as well as BLP() and GATES() (argument X1_control).

Value

An object of class "setup_X1", consisting of the following components:

funs_Z

A character vector, being a subset of c("S", "B", "p").

covariates

Either NULL or a numeric matrix.

fixed_effects

Either NULL or an integer vector indicating cluster membership.

See the description above for details.

References

Chernozhukov V., Demirer M., Duflo E., Fernández-Val I. (2020). “Generic Machine Learning Inference on Heterogenous Treatment Effects in Randomized Experiments.” arXiv preprint arXiv:1712.04802. URL: https://arxiv.org/abs/1712.04802.

See Also

GenericML(), GenericML_single(), BLP(), GATES(), setup_vcov(), setup_diff()

Examples

set.seed(1)
n <- 100 # sample size
p <- 5   # number of covariates
covariates <- matrix(runif(n*p), n, p) # sample matrix of covariates

# let there be three clusters; assign membership randomly
fixed_effects <- sample(c(1,2,3), size = n, replace = TRUE)

# use BCA estimates in matrix X1
setup_X1(funs_Z = "B", covariates = NULL, fixed_effects = NULL)

# use BCA and propensity score estimates in matrix X1
# uses uniform covariates and fixed effects
setup_X1(funs_Z = c("B", "p"), covariates = covariates, fixed_effects = NULL)


GenericML documentation built on June 18, 2022, 9:09 a.m.