Find the nearest neighbor indices for the treated and untreated for a supplied data.frame Uses the knn.index.dist function from the KernelKnn package Currently only applicable to a binary treatment coded as (1/0) In the returned matrices, the rows are indexed by NN, and the columns are the DF observations

knn_index_mat(
  DF,
  W,
  k = floor(sqrt(nrow(DF))),
  DF_test = NULL,
  distance_metric = "euclidean",
  standardize = TRUE,
  keep_dist = FALSE,
  threads = 1L,
  cov_DF = NULL
)

Arguments

DF

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

W

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

k

A integer for the max k value for the of kNN. Defaults to floor(sqrt(nrow(DF))) (integer)

DF_test

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

distance_metric

String supplying the method (character)

standardize

A boolean flag for whether to standardize the features (logical)

keep_dist

A boolean flag for keeping generated distance matrices (logical)

threads

A integer determining the number of threads used - uses openMP (integer)

cov_DF

A custom supplied covariance matrix for the mahalanobis distance metric (data.frame)

Value

A list containing the index (and distance) matrices (list)