| predict.factorial | R Documentation |
Projects new observations into the factorial space computed by CA,
MCA or PCA – the same operation that is applied to the
observations the analysis was fitted on: centering (and, for PCA with
scale.unit = TRUE, scaling) with the parameters of the training data, then
projection on the axes already computed. The axes are not recomputed and the new
observations have no influence on them: they are supplementary individuals.
## S3 method for class 'factorial'
predict(object, test, ...)
object |
The factorial analysis (object of class |
test |
The new observations, a |
... |
Other parameters. |
The projection is obtained by handing the new rows back to FactoMineR as supplementary
individuals of the original analysis, so the coordinates are exactly the ones
PCA (rbind (train, test), ind.sup = ...) would give. The active analysis is refitted
in the process, which is unnoticeable on the sizes this package is meant for.
Supplementary variables (quanti.sup, quali.sup) play no part in the axes, so
test does not have to carry them: any column of the training data that is missing from
test is filled in (with the training mean, or the first level) purely so that the two
can be stacked.
The coordinates of the new observations on the factorial axes (a matrix,
one row per observation and one column per axis).
PCA, CA, MCA,
factorial-class, predict.cda
require (datasets)
data (iris)
d = splitdata (iris, 5)
pca = PCA (d$train.x)
# The coordinates of unseen observations on the axes of the training analysis
head (predict (pca, d$test.x))
# An observation of the training set projects onto the coordinates the analysis gave it
pca$ind$coord [1, ]
predict (pca, d$train.x [1, ])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.