Description Usage Arguments Value Author(s) See Also Examples
View source: R/impute.nipals.R
This function uses nipals
function to decompose
X
into a set of components (t
), (pseudo-) singular-values
(eig
), and feature loadings (p
). The original matrix is then
approximated/reconstituted using the following equation:
\hat{X} = t * diag(eig) * t(p)
The missing values from X
are then approximated from this matrix. It
is best to ensure enough number of components are used in order to best
impute the missing values.
1 | impute.nipals(X, ncomp, ...)
|
X |
A numeric matrix containing missing values |
ncomp |
Positive integer, the number of components to derive from
|
... |
Optional arguments passed to |
A numeric matrix with missing values imputed.
Al J Abadi
1 2 3 4 5 6 7 8 9 10 11 | data("nutrimouse")
X <- data.matrix(nutrimouse$lipid)
## add missing values to X to impute and compare to actual values
set.seed(42)
na.ind <- sample(seq_along(X), size = 10)
true.values <- X[na.ind]
X[na.ind] <- NA
X.impute <- impute.nipals(X = X, ncomp = 5)
## compare
round(X.impute[na.ind], 2)
true.values
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.