help opl_dt_c

Title

opl_dt_c -- Decision-tree policy learning at specific splitting variables and threshold values

Syntax

opl_dt_c ,
xlist(var1 var2)
cate(varname)
c1(number)
c2(number)
c3(number)
x1(varname)
x2(varname)
x3(varname)
[
depvar(name)
graph
]

Description

opl_dt_c is a command implementing ex-ante treatment assignment using as policy
class a 2-layer fixed-depth decision-tree at specific splitting variables and threshold values.

Options

options

xlist(var1 var2) defines the two variables the policymaker decide to use for selecting policy beneficiaries

cate(varname) puts into varname a variable already present in the dataset containing the conditional average treatment effect (CATE). This variable can be generated using the command make_cate

c1(number) puts into number the value of the threshold value c1 for the first splitting variable. This number must be chosen between 0 and 1

c2(number) puts into number the value of the threshold value c2 for the second splitting variable. This number must be chosen between 0 and 1

c3(number) puts into number the value of the threshold value c3 for the third splitting variable. This number must be chosen between 0 and 1

x1(varname) puts into varname the name of the first splitting variable

x2(varname) puts into varname the name of the second splitting variable

x3(varname) puts into varname the name of the third splitting variable

depvar(name) assigns the specified name to the dependent variable for display in the results table. While this option does not impact computations, it ensures a meaningful label for the dependent variable in the results table.

graph visualizes treated and untreated within the var1 and var2 quadrant

Returns

Scalars
e(c1) threshold level of the first variable used for splitting

e(c2) threshold level of the second variable used for splitting

e(c3) threshold level of the third variable used for splitting

e(W_unconstr) value of the unconstrained welfare at threshold values c1 for the first splitting variable, c2 for the second splitting variable, and c3 for the third splitting variable

e(W_constr) value of the constrained welfare at threshold values c1 for the first splitting variable, c2 for the second splitting variable, and c3 for the third splitting variable

e(perc_treat) percentage of beneficiaries to treat

Macros
e(x1) first splitting variable

e(x2) second splitting variable

e(x3) third splitting variable

Variables
_units_to_be_treated flag variable indicating the policy beneficiaries at parameters' values c1, c2, and c3

Remarks

Remark 1. Please, consider to keep updated with future versions of this command.

Example

Example: Decision-tree policy learning at specific splitting variables and threshold values

Load initial dataset

sysuse JTRAIN2, clear

Split the original data into a "old" (training) and "new" (testing) dataset

get_train_test, dataname(jtrain) split(0.60 0.40) split_var(svar) rseed(101)

Use the "old" dataset (i.e. policy) for training

use jtrain_train , clear

Set the outcome

global y "re78"

Set the features

global x "re74 re75 age agesq nodegree"

Set the treatment variable

global w "train"

Set the selection variables

global z "age mostrn"

Run "make_cate" and generate training (old policy) and testing (new policy) CATE predictions

make_cate $y $x , treatment($w) model("linear") new_cate("my_cate_new") train_cate("my_cate_train") new_data("jtrain_test")

Generate a global macro containing the name of the variable "cate_new"

global T `e(cate_new)'

Select only the "new data"

keep if _train_new_index=="new"

Drop "my_cate_train" as in the new dataset treatment assignment and outcome performance are unknown

drop my_cate_train $w $y

Run "opl_dt" to find the optimal decision-tree splitting variables and thresholds

opl_dt , xlist($z) cate($T)

Save the optimal splitting variables into three global macros

global x1_opt `e(best_x1)'

global x2_opt `e(best_x2)'

global x3_opt `e(best_x3)'

Save the optimal splitting thresholds into three global macros

global c1_opt=e(best_c1)

global c2_opt=e(best_c2)

global c3_opt=e(best_c3)

Run "opl_dt_c" at optimal splitting variables and corresponding thresholds and generate the graph

opl_dt_c , xlist($z) cate($T) c1($c1_opt) c2($c2_opt) c3($c3_opt) x1($x1_opt) x2($x2_opt) x3($x3_opt) graph depvar("re78")

Tabulate the variable "_units_to_be_treated"

tab _units_to_be_treated , mis

References

Athey, S., and Wager S. 2021. Policy Learning with Observational Data, Econometrica, 89, 1, 133–161.

Cerulli, G. 2021. Improving econometric prediction by machine learning, Applied Economics Letters, 28, 16, 1419-1425.

Cerulli, G. 2022. Optimal treatment assignment of a threshold-based policy: empirical protocol and related issues, Applied Economics Letters, 30, 8, 1010-1017.

Cerulli, G. 2023. Fundamentals of Supervised Machine Learning: With Applications in Python, R, and Stata, Springer.

Cerulli, G. 2024. Optimal Policy Learning using Stata. Zenodo. DOI: https://doi.org/10.5281/zenodo.10822240.

Gareth, J., Witten, D., Hastie, D.T., Tibshirani, R. 2013. An Introduction to Statistical Learning: with Applications in R. New York, Springer.

Kitagawa, T., and A. Tetenov. 2018. Who Should Be Treated? Empirical Welfare Maximization Methods for Treatment Choice, Econometrica, 86, 2, 591–616.

Acknowledgment

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.

Author

Giovanni Cerulli

IRCrES-CNR

Research Institute for Sustainable Economic Growth, National Research Council of Italy

E-mail: giovanni.cerulli@ircres.cnr.it

Also see

Online: make_cate, opl_tb, opl_dt, opl_dt_c, opl_dt, opl_dt_c