# NOT RUN {
# Multi-action treatment effect estimation
n <- 250
p <- 10
X <- matrix(rnorm(n * p), n, p)
W <- sample(c("A", "B", "C"), n, replace = TRUE)
Y <- X[, 1] + X[, 2] * (W == "B") + X[, 3] * (W == "C") + runif(n)
multi.forest <- multi_causal_forest(X = X, Y = Y, W = W)
# tau.hats
predict(multi.forest)$predictions
# Policy learning
Gamma.matrix <- double_robust_scores(multi.forest)
train <- sample(1:n, 200)
opt.tree <- policy_tree(X[train, ], Gamma.matrix[train, ], depth = 2)
opt.tree
# Predict treatment on held out data
predict(opt.tree, X[-train, ])
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab