knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(OPL)
Predicting conditional average treatment effect (CATE) on a new policy based on the training over an old policy
make_cate is a function generating conditional average treatment effect (CATE) for both a training dataset and a testing (or new) dataset related to a binary (treated vs. untreated) policy program. It provides the main input for running opl_tb (optimal policy learning of a threshold-based policy), opl_tb_c (optimal policy learning of a threshold-based policy at specific thresholds), opl_lc (optimal policy learning of a linear-combination policy), opl_lc_c (optimal policy learning of a linear-combination policy at specific parameters), opl_dt (optimal policy learning of a decision-tree policy), opl_dt_c (optimal policy learning of a decision-tree policy at specific thresholds and selection variables). Based on Kitagawa and Tetenov (2018), the main econometrics supported by these commands can be found in Cerulli (2022).
make_cate(model, train_data, test_data, w, x, y, family = gaussian(), ntree = 100, mtry = 2)
An object containing the estimated causal treatment effect results, including: - Average Treatment Effect (ATE) - Average Treatment Effect on Treated (ATET) - Average Treatment Effect on Non-Treated (ATENT)
set.seed(42) train_data <- data.frame( y = rnorm(100), # Outcome x1 = rnorm(100), # Covariate x2 = rnorm(100), w = sample(0:1, 100, replace = TRUE) # Trattamento ) test_data <- data.frame( y = rnorm(100), # Outcome x1 = rnorm(100), # Covariate x2 = rnorm(100), w = sample(0:1, 100, replace = TRUE) # Trattamento ) x <- c("x1", "x2") # le covariate y <- "y" # la variabile dipendente w <- "w" # la variabile di trattamento family <- "gaussian" # Famiglia per glm ntree <- 100 # Numero di alberi per random forest mtry <- 2 # Numero di variabili da considerare in ogni split result <- make_cate(model = "glm", train_data = train_data, test_data = test_data, w = w, x = x, y = y)
The following results are output for both the old (training) and new (test) policy:
Number of obs = [n] Estimator = regression adjustment Outcome model = linear DIM = [DIM_value] ATE = [ATE_value] ATET = [ATET_value] ATENT = [ATENT_value]
Number of obs = [n] Estimator = regression adjustment Outcome model = linear DIM = [DIM_value] ATE = [ATE_value] ATET = [ATET_value] ATENT = [ATENT_value]
The make_cate function is a powerful tool for estimating the causal treatment effect of a policy using either GLM or Random Forest models. It provides insights into the treatment effects both for the old and new policies, making it a useful method for causal inference in policy analysis.
The development of this software was supported by FOSSR (Fostering Open Science in Social Science Research), a project funded by the European Union - NextGenerationEU under the NPRR Grant agreement n. MURIR0000008.
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.