prcompRecon | R Documentation |
This function reconstructs the original field from an EOF object of the
function prcomp
.
prcompRecon(pca, pcs = NULL)
pca |
An object resulting from the function |
pcs |
The principal components ("PCs") to use in the reconstruction
(defaults to the full set of PCs: |
# prcomp
P <- prcomp(iris[,1:4])
# Full reconstruction
R <- prcompRecon(P)
plot(as.matrix(iris[,1:4]), R, xlab="original data", ylab="reconstructed data")
abline(0, 1, col=2)
# Partial reconstruction
RMSE <- NaN*seq(P$sdev)
for(i in seq(RMSE)){
Ri <- prcompRecon(P, pcs=seq(i))
RMSE[i] <- sqrt(mean((as.matrix(iris[,1:4]) - Ri)^2))
}
plot(RMSE, t="o", xlab="Number of pcs")
abline(h=0, lty=2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.