# NOT RUN {
# Find the optimal tuning parameters.
n <- 50
p <- 10
X <- matrix(rnorm(n * p), n, p)
W <- rbinom(n, 1, 0.5)
Y <- pmax(X[, 1], 0) * W + X[, 2] + pmin(X[, 3], 0) + rnorm(n)
forest <- causal_forest(X, Y, W)
tuned.lambda <- tune_ll_causal_forest(forest)
# Use this parameter to predict from a local linear causal forest.
predictions <- predict(forest, linear.correction.variables = 1:p,
ll.lambda = tuned.lambda$lambda.min)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab