The S-learner ("single" learner) estimates the conditional average treatment effect (CATE) with one outcome model that uses the treatment as a predictor. Each unit's outcome is predicted twice, once as treated and once as control, and the difference is the estimated effect.
Arguments
- outcome_model
An unfitted
workflows::workflow()whose predictors include the treatment column. Its model can be a regression (numeric outcome) or a classification with two classes (binary outcome).
Value
An unfitted s_learner object, to be passed to
fit().
Details
Because the treatment is just one predictor, the estimated effects can only
vary across units if the outcome model lets the treatment interact with other
predictors. A linear model needs explicit interaction terms (e.g.,
spend ~ (recency + history) * emailed); tree-based models can find
interactions on their own but may rarely split on the treatment, which pulls
the estimated effects toward zero.
References
Künzel, S. R., Sekhon, J. S., Bickel, P. J., & Yu, B. (2019). Metalearners for estimating heterogeneous treatment effects using machine learning. Proceedings of the National Academy of Sciences, 116(10), 4156-4165. doi:10.1073/pnas.1804597116
Examples
# A small randomized email campaign: the email raises spending more for
# customers who bought recently
set.seed(1)
n <- 200
recency <- sample(1:12, n, replace = TRUE)
emailed <- rbinom(n, size = 1, prob = 0.5)
spend <- 20 - recency + emailed * (10 - 0.75 * recency) + rnorm(n, sd = 5)
emails <- data.frame(recency, emailed, spend)
# The interaction lets the estimated effect vary with recency
wf <- workflows::workflow(spend ~ recency * emailed, parsnip::linear_reg())
fitted <- s_learner(wf) |>
fit(data = emails, treatment = emailed)
predict(fitted, new_data = head(emails))
#> # A tibble: 6 × 1
#> .pred_cate
#> <dbl>
#> 1 4.40
#> 2 7.43
#> 3 5.61
#> 4 9.24
#> 5 8.64
#> 6 5.61
predict(fitted, new_data = head(emails), type = "potential_outcomes")
#> # A tibble: 6 × 2
#> .pred_control .pred_treated
#> <dbl> <dbl>
#> 1 11.0 15.4
#> 2 15.8 23.3
#> 3 12.9 18.5
#> 4 18.8 28.0
#> 5 17.8 26.4
#> 6 12.9 18.5