impute_knn: K-nearest neighbor (KNN) imputation

Description Usage Arguments Value References See Also Examples

Description

Apply k-nearest neighbor (KNN) imputation to a matrix or poplin object. This is an interface to the kNN function from the VIM package. Since it is based on Gower's distance, Standardization of input data before imputation would not affect the result.

Usage

1
2
3
4
5
## S4 method for signature 'matrix'
impute_knn(x, by = c("feature", "sample"), ...)

## S4 method for signature 'poplin'
impute_knn(x, xin, xout, by = c("feature", "sample"), ...)

Arguments

x

A matrix or poplin object.

by

Character controlling whether the imputation is performed by k-nearest features or by k-nearest samples. Either "feature" or "sample".

...

Additional arguments passed to kNN.

xin

Character specifying the name of data to retrieve from x when x is a poplin object.

xout

Character specifying the name of data to store in x when x is a poplin object.

Value

A matrix or poplin object of the same dimension as x containing the imputed intensities.

References

Alexander Kowarik, Matthias Templ (2016). Imputation with the R Package VIM. Journal of Statistical Software, 74(7), 1-16. doi:10.18637/jss.v074.i07

Gower, J. C. (1971). A General Coefficient of Similarity and Some of Its Properties. Biometrics, 27(4), 857–871. https://doi.org/10.2307/2528823

See Also

Other imputation methods: impute_pca(), impute_randomforest(), impute_univariate(), poplin_impute()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
data(faahko_poplin)

if (requireNamespace("VIM", quietly = TRUE)) {
  ## poplin object
  impute_knn(faahko_poplin, xin = "raw", xout = "knn")

  ## matrix
  m <- poplin_raw(faahko_poplin, "raw")
  impute_knn(m)
}

jaehyunjoo/poplin documentation built on Jan. 8, 2022, 1:13 a.m.