Skip to contents

Each tree splits on one half of a subsample by maximising the squared difference in child treatment effects, then re-estimates its leaf values on the untouched half. That honesty split is what makes the leaf effects approximately unbiased. Out-of-bag predictions average only the trees that never saw the row and are the ones to feed any downstream heterogeneity test.

Usage

morie_causal_forest(
  y,
  d,
  x,
  n_trees = 200L,
  min_leaf = 10L,
  max_depth = 6L,
  mtry = NULL,
  subsample = 0.5,
  imbalance_penalty = 0,
  seed = 0L
)

Arguments

y

Outcome.

d

Binary 0/1 treatment.

x

Covariate matrix (or vector).

n_trees

Number of trees.

min_leaf

Minimum units of each arm per leaf.

max_depth

Maximum tree depth.

mtry

Features tried per split; default ceiling(sqrt(p)).

subsample

Fraction of rows drawn per tree.

imbalance_penalty

GRF's split-imbalance regularizer, subtracted as penalty * (1/n_L + 1/n_R). Zero recovers the plain Athey-Imbens criterion. It carries the units of the criterion itself, so it is not scale-free.

seed

RNG seed.

Value

List with cate, cate_oob, ate, cate_sd, n_trees, n, and forest (usable with morie_causal_forest_predict()).

Details

Mirrors morie.fn.crfath.causal_forest_wager_athey and the shared morie.fn._cforest.CausalForest core.

References

Wager S, Athey S (2018). Estimation and inference of heterogeneous treatment effects using random forests. JASA 113(523), 1228-1242.

Athey S, Imbens G (2016). Recursive partitioning for heterogeneous causal effects. PNAS 113(27), 7353-7360.

Examples

if (requireNamespace("ranger", quietly = TRUE)) {
  set.seed(1)
  n <- 120
  X <- matrix(rnorm(n * 2), n, 2)
  d <- rbinom(n, 1, 0.5)
  y <- 1 + X[, 1] + d * (0.5 + X[, 2]) + rnorm(n, 0, 0.3)
  fit <- morie_causal_forest(y, d, X, n_trees = 30L, min_leaf = 10L)
  mean(fit$cate)
}
#> [1] 0.1444736