The opl_tb_c
function implements ex-ante treatment
assignment using as policy class a threshold-based (or quadrant)
approach at specific threshold values c1 and c2 for respectively the
selection variables var1 and var2.
opl_tb_c(make_cate_result, z, w, c1 = NA, c2 = NA)
make_cate_result
: A data frame containing input data,
including a column named my_cate
, representing conditional
average treatment effects (CATE).z
: A character vector of length 2 specifying the column
names of the two selection variables.w
: A character string indicating the column name for
treatment assignment (binary variable).c1
: User-defined or function-optimized threshold for
the first selection variable (between 0 and 1).c2
: User-defined or function-optimized threshold for
the second selection variable (between 0 and 1).The function returns the input data frame augmented with: -
z[1]_std
: Standardized first selection variable. -
z[2]_std
: Standardized second selection variable. -
units_to_be_treated
: Binary indicator for treatment
assignment.
Additionally, the function: - Prints a summary of key results, including threshold values, constrained and unconstrained welfare, and treatment proportions. - Displays a scatter plot visualizing the policy assignment.
The function follows these steps: 1. Standardizes the selection variables to a [0,1] range. 2. Identifies the optimal thresholds using grid search to maximize constrained welfare. 3. Computes and reports key statistics, including average welfare and percentage of treated units.
# Load example data
set.seed(123)
data_example <- data.frame(
my_cate = runif(100, -1, 1),
var1 = runif(100, 0, 1),
var2 = runif(100, 0, 1),
treatment = sample(0:1, 100, replace = TRUE)
)
# Run threshold-based policy learning
result <- opl_tb_c(
make_cate_result = data_example,
z = c("var1", "var2"),
w = "treatment"
)
This vignette provides an overview of the opl_tb_c
function and demonstrates its usage for threshold-based policy learning.
For further details, consult the package documentation.