View source: R/predict.PCAmix.R
predict.PCAmix | R Documentation |
This function performs the scores of new observations on the principal components of PCAmix. If the components have been rotated, this function performs the scores of the new observations on the rotated principal components. In other words, this function is projecting the new observations onto the principal components of PCAmix (or PCArot) obtained previoulsy on a separated dataset. Note that the new observations must be described with the same variables than those used in PCAmix (or PCArot).
## S3 method for class 'PCAmix' predict(object, X.quanti = NULL, X.quali = NULL, ...)
object |
an object of class PCAmix obtained with the function
|
X.quanti |
a numeric data matrix or an object that can be coerced to such a matrix (such as a numeric vector or a data frame with all numeric columns). |
X.quali |
a categorical matrix of data, or an object that can be coerced to such a matrix (such as a character vector, a factor or a data frame with all factor columns). |
... |
urther arguments passed to or from other methods. They are ignored in this function. |
Returns the matrix of the scores of the new observations on the principal components or on the rotated principal components of PCAmix.
Marie Chavent marie.chavent@u-bordeaux.fr, Amaury Labenne.
Chavent M., Kuentz-Simonet V., Labenne A., Saracco J., Multivariate analysis of mixed data: The PCAmixdata R package, arXiv:1411.4911 [stat.CO].
PCAmix
,PCArot
# quantitative data data(decathlon) n <- nrow(decathlon) train <- sample(1:n,20) pca <- PCAmix(decathlon[train,1:10], graph=FALSE) predict(pca, decathlon[-train,1:10]) rot <- PCArot(pca,dim=4) predict(rot,decathlon[-train,1:10]) # qualitative data data(flower) n <- nrow(flower) train <- sample(1:n,10) mca <- PCAmix(X.quali=flower[train,1:3], rename.level=TRUE, graph=FALSE) predict(mca, X.quali=flower[-train,1:3]) # quantitative and qualitative data data(wine) X.quanti <- splitmix(wine)$X.quanti X.quali <- splitmix(wine)$X.quali n <- nrow(wine) train <- sample(1:n, 10) pca <-PCAmix(X.quanti[train,1:10], X.quali[train,], ndim=4) pred <- predict(pca, X.quanti[-train,1:10], X.quali[-train,]) plot(pca,axes=c(1,2)) points(pred[,c(1,2)],col=2,pch=16) text(pred[,c(1,2)], labels = rownames(X.quanti[-train,1:27]), col=2,pos=3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.