Fit a Heterogeneous Effect Forest for Observational Data
Source:R/fit_observational_forest.R
fit_observational_forest.RdWraps grf::causal_forest() with a column-name interface and returns a
unified heteff_fit object.
Usage
fit_observational_forest(
data,
outcome,
treatment,
covariates,
num.trees = 2000,
seed = 1,
...
)Arguments
- data
A data frame containing all required columns.
- outcome
Name of the numeric outcome column.
- treatment
Name of the binary or continuous treatment column.
- covariates
Character vector of baseline covariate column names.
- num.trees
Number of trees passed to
grf::causal_forest().- seed
Random seed passed to
grf::causal_forest().- ...
Additional arguments passed to
grf::causal_forest().
Examples
if (FALSE) { # \dontrun{
set.seed(1)
n <- 300
df <- data.frame(
y = rnorm(n),
w = rbinom(n, 1, 0.5),
x1 = rnorm(n),
x2 = rnorm(n)
)
fit <- fit_observational_forest(df, "y", "w", c("x1", "x2"))
head(as.data.frame(fit))
} # }