Learn R Programming

PCAmixdata (version 2.1)

predict.PCAmix: Scores of new objects on the principal components of PCAmix or PCArot

Description

This function calculates the scores of a new set of data on the principal components of PCA. If the components have been rotated, the function gives the scores of the new objects on the rotated PC. The new objects must have the same variables than the learning set.

Usage

## S3 method for class 'PCAmix':
predict(object, X.quanti = NULL, X.quali = NULL,...)

Arguments

object
an object of class PCAmix (output of the function PCAmix or PCArot)
X.quanti
numeric matrix of data for the new objects
X.quali
a categorical matrix of data for the new objects
...
futher arguments pased to or from other methods

Value

  • Returns the matrix of the scores of the new objects of the ndim principal PC or rotated PC.

Examples

Run this code
data(decathlon)
n <- nrow(decathlon)
sub <- sample(1:n,20)
pca<-PCAmix(decathlon[sub,1:10], graph=FALSE)
predict(pca,decathlon[-sub,1:10])
rot <- PCArot(pca,dim=4)
predict(rot,decathlon[-sub,1:10])

Run the code above in your browser using DataLab