| predict-methods | R Documentation |
Predict data using PCA model
## S3 method for class 'pcaRes'
predict(object, newdata, pcs = nP(object), pre = TRUE,
post = TRUE, ...)
## S4 method for signature 'pcaRes'
predict(object, newdata, pcs = nP(object),
pre = TRUE, post = TRUE, ...)
object |
|
newdata |
|
pcs |
|
pre |
pre-process |
post |
unpre-process the final data (add the center back etc) |
... |
Not passed on anywhere, included for S3 consistency. |
This function extracts the predict values from a pcaRes object for
the PCA methods SVD, Nipals, PPCA and BPCA. Newdata is first
centered if the PCA model was and then scores (T) and data
(X) is 'predicted' according to :
\hat{T}=X_{new}P
\hat{X}_{new}=\hat{T}P'. Missing values are
set to zero before matrix multiplication to achieve NIPALS like
treatment of missing values.
A list with the following components:
scores |
The predicted scores |
x |
The predicted data |
Henning Redestig
data(iris)
hidden <- sample(nrow(iris), 50)
pcIr <- pca(iris[-hidden,1:4])
pcFull <- pca(iris[,1:4])
irisHat <- predict(pcIr, iris[hidden,1:4])
cor(irisHat$scores[,1], scores(pcFull)[hidden,1])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.