
SuperLearner-stacked AIPW on OTIS data (native)
Source:R/otis_causal.R
morie_otis_aipw_superlearner.RdCross-fit AIPW whose nuisances are NNLS-stacked ensembles of
native learners (the same Lawson-Hanson convex stacking as
morie_weight_super): propensity from
{ridge-logistic, quadratic logistic, base rate} and per-arm
outcome regressions from {OLS, cross-validated ridge, mean},
with ranger random forests joining both stacks when installed.
Stacking weights come from inner 3-fold cross-validated
predictions inside every outer training fold, so no fold ever
sees its own outcome.
Usage
morie_otis_aipw_superlearner(
df,
treatment,
outcome,
covariates,
n_folds = 5L,
seed = 123L,
eps = 0.02
)Examples
set.seed(1)
n <- 200
x1 <- rnorm(n); x2 <- rnorm(n)
d <- rbinom(n, 1, plogis(0.5 * x1))
y <- 1 + 2 * d + x1 - 0.5 * x2 + rnorm(n)
df <- data.frame(y, d, x1, x2)
morie_otis_aipw_superlearner(df, treatment = "d", outcome = "y",
covariates = c("x1", "x2"),
n_folds = 3L)
#> $estimator
#> [1] "AIPW-SuperLearner"
#>
#> $ate
#> [1] 1.962339
#>
#> $ate_se
#> [1] 0.1494574
#>
#> $ate_pval
#> [1] 2.223823e-39
#>
#> $ate_ci95
#> [1] 1.669402 2.255275
#>
#> $n
#> [1] 200
#>
#> $n_treated
#> [1] 99
#>
#> $p_treat
#> [1] 0.495
#>
#> $notes
#> $notes[[1]]
#> [1] "cross-fit folds=3"
#>
#> $notes[[2]]
#> [1] "stack: ps={ridge_logit,logit_sq,base_rate,forest} reg={ols,ridge,mean,forest}"
#>
#> $notes[[3]]
#> [1] "Brier=0.246"
#>
#>
#> attr(,"class")
#> [1] "morie_causal_estimate" "list"