Wraps the direct Causal KNN regression into one function.
The function sequentially runs knn_index_mat
, knn_optimal_k
, and
causalknn_treatment_effect
functions and returns a list
of treatment results and optimal parameters. Since all of the important parameters are returned,
the user can re-run certain functions easily.
causalKNN_direct(
DF,
W,
Y,
key,
DF_test,
key_test,
threads = 1L,
knn_index_mat_options = list(k = floor(sqrt(nrow(DF)))),
knn_optimal_k_options = list(N_step = ifelse(knn_index_mat_options$k > 300L,
floor(knn_index_mat_options$k/25), 14L), K_step = ifelse(knn_index_mat_options$k >
300L, 25L, floor(knn_index_mat_options$k/14))),
causalknn_treatment_effect_options = list(),
verbose = FALSE
)
A data frame of the features of the training sample (data.frame)
A vector of the treatment indicator of the training sample (1/0 coded) (integer)
A vector of the outcome values of the training sample (numeric)
A vector of the indices of the training sample (integer)
A data frame of the features in the test set (data.frame)
A vector of the indices of the test sample (integer)
The value of number of threads to use (integer)
A list of parameters to pass into knn_index_mat
(list)
A list of parameters to pass into knn_optimal_k
(list)
A list of parameters to pass into causalknn_treatment_effect
(list)
A boolean flag for verbose output (logical)
A list containing function results (list)
This off-the-shelf implementation does not implement bootstrapping for finding the optimal K value and for the treatment effect projection.