Learn R Programming

grf (version 0.9.6)

average_partial_effect: Estimate average partial effects using a causal forest

Description

Gets estimates of the average partial effect, in particular the (conditional) average treatment effect (target.sample = all): 1/n sum_i = 1^n Cov[Wi, Yi | X = Xi] / Var[Wi | X = Xi]. Note that for a binary unconfounded treatment, the average partial effect matches the average treatment effect.

Usage

average_partial_effect(forest, calibrate.weights = TRUE)

Arguments

forest

The trained forest.

calibrate.weights

Whether to force debiasing weights to match expected moments for 1, W, W.hat, and 1/Var[W|X].

Value

An estimate of the average partial effect, along with standard error.

Examples

Run this code
# NOT RUN {
n = 2000; p = 10
X = matrix(rnorm(n*p), n, p)
W = rbinom(n, 1, 1/(1 + exp(-X[,2]))) + rnorm(n)
Y = pmax(X[,1], 0) * W + X[,2] + pmin(X[,3], 0) + rnorm(n)
tau.forest = causal_forest(X, Y, W)
tau.hat = predict(tau.forest)
average_partial_effect(tau.forest)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab