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
)

Arguments

DF

A data frame of the features of the training sample (data.frame)

W

A vector of the treatment indicator of the training sample (1/0 coded) (integer)

Y

A vector of the outcome values of the training sample (numeric)

key

A vector of the indices of the training sample (integer)

DF_test

A data frame of the features in the test set (data.frame)

key_test

A vector of the indices of the test sample (integer)

threads

The value of number of threads to use (integer)

knn_index_mat_options

A list of parameters to pass into knn_index_mat (list)

knn_optimal_k_options

A list of parameters to pass into knn_optimal_k (list)

causalknn_treatment_effect_options

A list of parameters to pass into causalknn_treatment_effect (list)

verbose

A boolean flag for verbose output (logical)

Value

A list containing function results (list)

Details

This off-the-shelf implementation does not implement bootstrapping for finding the optimal K value and for the treatment effect projection.