We can estimate ITR with various machine learning algorithms and then
compare the performance of each model. The package includes all ML
algorithms in the caret package and 2 additional algorithms
(causal
forest and bartCause).
The package also allows estimate heterogeneous treatment effects on
the individual and group-level. On the individual-level, the summary
statistics and the AUPEC plot show whether assigning individualized
treatment rules may outperform complete random experiment. On the
group-level, we specify the number of groups through ngates
and estimating heterogeneous treatment effects across groups.
library(evalITR)
#> Loading required package: MASS
#>
#> Attaching package: 'MASS'
#> The following object is masked from 'package:dplyr':
#>
#> select
#> Loading required package: Matrix
#> Loading required package: quadprog
# specify the trainControl method
fitControl <- caret::trainControl(
method = "repeatedcv",
number = 2,
repeats = 2)
# estimate ITR
set.seed(2021)
fit_cv <- estimate_itr(
treatment = "treatment",
form = user_formula,
data = star_data,
trControl = fitControl,
algorithms = c(
"causal_forest",
# "bartc",
# "rlasso", # from rlearner
# "ulasso", # from rlearner
"lasso" # from caret package
# "rf" # from caret package
), # from caret package
budget = 0.2,
n_folds = 2)
#> Evaluate ITR with cross-validation ...
#> Loading required package: ggplot2
#> Loading required package: lattice
#> Warning: model fit failed for Fold1.Rep1: fraction=0.9 Error in elasticnet::enet(as.matrix(x), y, lambda = 0, ...) :
#> Some of the columns of x have zero variance
#> Warning: model fit failed for Fold1.Rep2: fraction=0.9 Error in elasticnet::enet(as.matrix(x), y, lambda = 0, ...) :
#> Some of the columns of x have zero variance
#> Warning in nominalTrainWorkflow(x = x, y = y, wts = weights, info = trainInfo,
#> : There were missing values in resampled performance measures.
# evaluate ITR
est_cv <- evaluate_itr(fit_cv)
# summarize estimates
summary(est_cv)
#> -- PAPE ------------------------------------------------------------------------
#> estimate std.deviation algorithm statistic p.value
#> 1 2.0 1.7 causal_forest 1.2 0.24
#> 2 1.2 1.0 lasso 1.1 0.26
#>
#> -- PAPEp -----------------------------------------------------------------------
#> estimate std.deviation algorithm statistic p.value
#> 1 1.03 0.67 causal_forest 1.54 0.12
#> 2 -0.22 0.80 lasso -0.27 0.79
#>
#> -- PAPDp -----------------------------------------------------------------------
#> estimate std.deviation algorithm statistic p.value
#> 1 1.2 1 causal_forest x lasso 1.2 0.21
#>
#> -- AUPEC -----------------------------------------------------------------------
#> estimate std.deviation algorithm statistic p.value
#> 1 1.50 1.1 causal_forest 1.42 0.15
#> 2 0.52 1.2 lasso 0.43 0.67
#>
#> -- GATE ------------------------------------------------------------------------
#> estimate std.deviation algorithm group statistic p.value upper lower
#> 1 -86.79 77 causal_forest 1 -1.130 0.26 64 -237
#> 2 -13.26 70 causal_forest 2 -0.190 0.85 123 -150
#> 3 88.87 73 causal_forest 3 1.218 0.22 232 -54
#> 4 -0.38 76 causal_forest 4 -0.005 1.00 149 -150
#> 5 29.94 59 causal_forest 5 0.507 0.61 146 -86
#> 6 26.51 61 lasso 1 0.437 0.66 145 -92
#> 7 -59.60 136 lasso 2 -0.439 0.66 206 -325
#> 8 79.76 74 lasso 3 1.083 0.28 224 -65
#> 9 -3.96 75 lasso 4 -0.052 0.96 144 -152
#> 10 -24.33 74 lasso 5 -0.328 0.74 121 -170We plot the estimated Area Under the Prescriptive Effect Curve for the writing score across different ML algorithms.
# plot the AUPEC with different ML algorithms
plot(est_cv)