The function whitens a data matrix using the singular value decomposition.
WhitenSVD(x, tol = 1e-06)
A numeric data frame or data matrix with at least two rows.
Tolerance value to decide the rank of the data. See details for
further information. If set to
The function whitens the data so that the result has mean zero and identity
covariance matrix using the function
svd. The data can have
here less observations than variables and svd will determine the rank of the
data automatically as the number of singular values larger than the largest
singular value times
tol=NULL the rank is set to the
number of singular values, which is not advised when one or more singular
values are close to zero.
The output contains among others as attributes the singular values and the matrix needed to backtransform the whitened data to its original space.
The whitened data.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
# more observations than variables X <- matrix(rnorm(200),ncol=4) A <- WhitenSVD(X) round(colMeans(A),4) round(cov(A),4) # how to backtransform summary(sweep(A %*% (attr(A,"backtransform")), 2, attr(A,"center"), "+") - X) # fewer observations than variables Y <- cbind(rexp(4),runif(4),rnorm(4), runif(4), rnorm(4), rt(4,4)) B <- WhitenSVD(Y) round(colMeans(B),4) round(cov(B),4) # how to backtransform summary(sweep(B %*% (attr(B,"backtransform")), 2, attr(B,"center"), "+") - Y)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.