Computes the R-Loss (Nie & Wager, 2021), also known as
\(\tau\text{-risk}_R\), of a vector of CATE predictions:
$$R\text{-}Loss = \frac{1}{n} \sum_i \left[ (Y^{(i)} -
\hat m(X^{(i)})) - (T^{(i)} - \hat e(X^{(i)})) \,
\hat\tau(X^{(i)}) \right]^2$$
Unlike pehe(), the R-Loss does not require the true treatment effects,
so it can be computed on real observational data. This makes it suitable
for hyperparameter tuning and model selection of causal estimators:
lower values indicate better CATE models.
r_loss(nuisance, tau_pred)An "rloss_nuisance" object created with
rloss_nuisance(), holding the outcome and treatment residuals.
Numeric vector of CATE predictions for the same rows that
nuisance was computed on.
A single non-negative number (lower is better).
Nie, X., & Wager, S. (2021). Quasi-oracle estimation of heterogeneous treatment effects. Biometrika, 108(2), 299-319.
Machlanski, D., Samothrakis, S., & Clarke, P. (2023). Hyperparameter tuning and model evaluation in causal effect estimation. arXiv preprint arXiv:2303.01412.
# \donttest{
library(mlr3)
data(synth_train)
set.seed(1)
nuis <- rloss_nuisance(synth_train, outcome = "y", treatment = "t",
outcome_learner = lrn("regr.rpart"),
ps_learner = lrn("classif.rpart"))
# compare two candidate CATE models by their R-Loss
m_s <- s_learner(synth_train, outcome = "y", treatment = "t",
learner = lrn("regr.rpart"))
m_t <- t_learner(synth_train, outcome = "y", treatment = "t",
learner = lrn("regr.rpart"))
r_loss(nuis, predict(m_s, synth_train))
#> [1] 4.787972
r_loss(nuis, predict(m_t, synth_train))
#> [1] 4.856491
# }