
Causal forest with an isotonic monotonicity constraint on the CATE
Source:R/causal_forest_honest.R
morie_monotone_causal_forest.RdWhen theory says the effect can only move one way in a covariate, the
unconstrained forest's wiggles are noise. The fitted CATE is projected
onto the monotone functions of that covariate by pool-adjacent-
violators, the exact L2 isotonic projection. Mirrors morie.fn.htgcrf.
Usage
morie_monotone_causal_forest(
y,
d,
x,
monotone_feature = NULL,
direction = 1L,
n_trees = 200L,
min_leaf = 10L,
seed = 0L
)Arguments
- y, d, x
As in
morie_causal_forest().- monotone_feature
Column index the effect must be monotone in;
NULLreturns the unconstrained forest.- direction
1 for nondecreasing, -1 for nonincreasing.
- n_trees, min_leaf, seed
Forest hyperparameters.
Value
List with cate, cate_raw, monotone_feature, direction,
violations_before, violations_after, n.
References
Robertson T, Wright FT, Dykstra RL (1988). Order Restricted Statistical Inference. Wiley.
Examples
set.seed(4)
n <- 120
X <- matrix(rnorm(n * 2), n, 2)
d <- rbinom(n, 1, 0.5)
y <- 1 + X[, 1] + d * (0.5 + 0.5 * X[, 1]) + rnorm(n, 0, 0.3)
r <- morie_monotone_causal_forest(y, d, X, monotone_feature = 1L,
n_trees = 20L)
str(r, max.level = 1)
#> List of 7
#> $ cate : num [1:120] 0.504 0.504 0.504 0.504 0.504 ...
#> $ cate_raw : num [1:120] 0.504 0.504 0.504 0.504 0.504 ...
#> $ monotone_feature : int 1
#> $ direction : int 1
#> $ violations_before: int 0
#> $ violations_after : int 0
#> $ n : int 120