| kNN | R Documentation |
Hotdeck imputation for one variable by the k nearest neighbors method (random imputation or average over the k nearest neighbors)
kNN(data, variable, method = c("random", "mean"), k = 3, nomatch = NULL, flag = FALSE, seed = 1024)
data |
a |
variable |
character: name of variable subject to imputation (only one variable allowed) |
method |
character: |
k |
number of nearest neighbors |
nomatch |
character or character vector of variables that shall not be used for distance calculation (e.g., sampling weight or id-variables) |
flag |
logical, if |
seed |
positive integer: random seed (for method |
The k nearest neighbors are determined by means of the Gower distance (implemented in the package gower).
A data.frame
You must not call this function unless you really know how it works! Also, the function does not check whether the provided arguments are meaningful. It is the user's responsibility to make sure that the arguments are properly specified.
Tobias Schoch