In separate K value case, supply a vector of two elements to the K parameter. The first element of vector will be K for untreated nearest neighbors, and the second elements will be the K for treated nearest neighbors. Supply a single value for K otherwise.

causalknn_treatment_effect(
  W,
  Y,
  key,
  K,
  knn_index_list,
  key_test = NULL,
  return_outcomes = FALSE,
  bootstrap_keys = NULL,
  bootstrap_keys_test = NULL
)

Arguments

W

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

Y

A vector of the outcome values in the training set (numeric)

key

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

K

Value(s) for K (integer)

knn_index_list

A list of the KNN index matrices provided by the knn_index_mat function (list)

key_test

A vector of the indices of the test set (Defaults to NULL) (integer)

return_outcomes

Whether to return predicted potential (treated/untreated) outcomes (logical)

bootstrap_keys

A vector of the bootstrapped keys for the training set (default to NULL for no bootstrap case) (integer)

bootstrap_keys_test

A vector of the bootstrapped keys for the test set (default to NULL for no bootstrap case) (integer)

Value

A data.frame of the predicted treatment effect, treatment outcome, and untreated outcome by key (data.frame)

Details

Supply a key_test if looking to estimate treatment effects for the validation set. Otherwise, the default value of NULL will instruct the function to estimate treatment effects for the training set.

Allows for bootstrapped case - see the bootstrap vignette.