
Estimate per-unit Conditional Average Treatment Effects (CATE)
Source:R/causal.R
morie_estimate_cate.RdThe T-learner fits separate outcome models on treated and control units, then predicts the counterfactual for each unit: \(\widehat{CATE}_i = \hat{\mu}_1(X_i) - \hat{\mu}_0(X_i)\).
Arguments
- data
A vector; indexed elementwise.
- treatment
Passed to
morie_estimate_propensity_scores.- outcome
See Usage.
- covariates
Passed to
morie_estimate_propensity_scores.- propensity_col
Optional; may be
NULL. Passed tois.null.- outcome_model
Family for the outcome model:
"auto"(logistic for a 0/1 outcome, linear otherwise),"linear"or"logistic".- meta_learner
One of
"t_learner"(default),"s_learner","x_learner"(Kuenzel et al. 2019 – two-stage with propensity-weighted combination; strong under arm imbalance), or"dr_learner"(Kennedy 2023 – cross-fit AIPW pseudo-outcome regressed with the native forest; doubly robust). All four are native;outcome_modelapplies to the T/S-learners only.
Details
The S-learner fits one model with treatment as a feature.
For random-forest CATE estimation prefer grf::causal_forest
(richer heterogeneity, honest sample splitting).
Examples
set.seed(1)
morie_estimate_cate(
data = data.frame(
t = stats::rbinom(100, 1, 0.4),
y = stats::rbinom(100, 1, 0.3), x1 = stats::rnorm(100),
x2 = stats::rnorm(100)
), treatment = "t", outcome = "y",
covariates = c("x1", "x2")
)
#> [1] 0.024465332 0.039356269 -0.040246877 0.117055146 0.111672149
#> [6] 0.162579814 0.132324461 0.153387263 0.126130614 0.221687262
#> [11] 0.042330327 0.037914880 0.230386067 0.081385490 0.041083866
#> [16] 0.007127270 0.074669018 0.109843821 0.113769950 0.078260489
#> [21] 0.106144561 0.209144017 0.094614811 0.087982177 0.122194096
#> [26] 0.093948665 0.096886758 0.142669661 0.026228031 0.055154705
#> [31] 0.130448792 0.137599893 0.159952058 -0.059160971 0.120918303
#> [36] -0.038353437 0.047222047 0.085900174 -0.001304765 0.087434886
#> [41] -0.098235321 0.160103194 -0.060315776 0.081240777 -0.043927473
#> [46] 0.093747288 0.292275959 0.102285354 -0.014286989 -0.084867519
#> [51] 0.126872808 0.076968214 0.066834626 0.019537909 -0.060651204
#> [56] -0.039819205 0.259763195 0.018920114 -0.040937296 0.269294722
#> [61] 0.097416770 0.084449855 0.193941856 0.140738997 -0.019289199
#> [66] 0.275365028 0.084125581 0.007912745 0.090712434 0.141748531
#> [71] 0.301945115 0.088230399 0.160536609 -0.003174590 0.057893709
#> [76] 0.051360169 0.237445731 0.248202738 0.225770837 0.166657852
#> [81] -0.028382634 0.191567314 0.067050019 -0.012141101 0.157035910
#> [86] 0.111887646 0.242167925 -0.006161392 0.040217899 -0.022109940
#> [91] 0.089840862 0.114638264 0.020292394 0.212288985 -0.072555701
#> [96] -0.003585252 0.192139157 -0.028253494 0.129795491 0.069249681