get_outcome_weights.instrumental_forest {OutcomeWeights} | R Documentation |
Outcome weights for the instrumental_forest
function
Description
Post-estimation command to extract outcome weights for instrumental forest
implemented via the instrumental_forest
function from the grf package.
Usage
## S3 method for class 'instrumental_forest'
get_outcome_weights(object, ..., S, newdata = NULL, checks = TRUE)
Arguments
object |
An object of class |
... |
Pass potentially generic get_outcome_weights options. |
S |
A smoother matrix reproducing the outcome predictions used in building the |
newdata |
Corresponds to |
checks |
Default |
Value
get_outcome_weights object with omega
containing weights and treat
the treatment
References
Athey, S., Tibshirani, J., & Wager, S. (2019). Generalized random forest. The Annals of Statistics, 47(2), 1148-1178.
Knaus, M. C. (2024). Treatment effect estimators as weighted outcomes, https://arxiv.org/abs/2411.11559.
Examples
# Sample from DGP borrowed from grf documentation
n = 2000
p = 5
X = matrix(rbinom(n * p, 1, 0.5), n, p)
Z = rbinom(n, 1, 0.5)
Q = rbinom(n, 1, 0.5)
W = Q * Z
tau = X[, 1] / 2
Y = rowSums(X[, 1:3]) + tau * W + Q + rnorm(n)
# Run outcome regression and extract smoother matrix
forest.Y = grf::regression_forest(X, Y)
Y.hat = predict(forest.Y)$predictions
outcome_smoother = grf::get_forest_weights(forest.Y)
# Run instrumental forest with external Y.hats
iv.forest = grf::instrumental_forest(X, Y, W, Z, Y.hat = Y.hat)
# Predict on out-of-bag training samples.
iv.pred = predict(iv.forest)$predictions
omega_if = get_outcome_weights(iv.forest, S = outcome_smoother)
# Observe that they perfectly replicate the original CLATEs
all.equal(as.numeric(omega_if$omega %*% Y),
as.numeric(iv.pred))