Learn R Programming

PCAmixdata (version 2.1)

predict.MFAmix: Scores of new objects on the principal components of MFAmix

Description

This function calculates the scores of a new set of data on the principal components of MFAmix. The new objects must have the same variables than the learning set.

Usage

## S3 method for class 'MFAmix':
predict(object, data, group,name.group,...)

Arguments

object
an object of class MFAmix (output of the function MFAmix)
data
a data frame with n rows and p colums containing all the variables. This data frame will be split into G groups according to the vector group
group
a vector of size p whose values indicate at which group each variable belongs
name.group
a vector of size G which contains names for each group we want to create. Each name must be written as a charactor chain without any spaces and any special characters. Only letters, numbers and "_" allowed.
...
further arguments passed to or from othe methods

Value

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

Examples

Run this code
#MFAmix:
data(INSEE)
class.var<-c(1,1,1,1,1,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,
             5,5,1,1,1,1,6,7,7,7,7,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,8,8,1)
nom.groupes<-c("Log_Services","Population","Emplois","Condit_Famil",
      "Educ","Revenu","Environnement","Secu_et_Soins")
res<-MFAmix(data=INSEE,group=class.var,name.group=nom.groupes,ndim=5,graph=FALSE)

#Predict on the same data, we obtain the same scores
res.pred<-predict(res,data=INSEE,group=class.var,name.group=nom.groupes)
res$ind$coord/res.pred

Run the code above in your browser using DataLab