Within-class Principal Component Analysis
wcPCA(X, class, scale.unit = TRUE, ncp = 5, ind.sup = NULL, quanti.sup = NULL, quali.sup = NULL, row.w = NULL, col.w = NULL, graph = FALSE, axes = c(1, 2))
a data frame with n rows (individuals) and p columns (numeric variables)
factor specifying the class
a boolean, if TRUE (default) then data are scaled to unit variance
number of dimensions kept in the results (by default 5)
a vector indicating the indexes of the supplementary individuals
a vector indicating the indexes of the quantitative supplementary variables
a vector indicating the indexes of the categorical supplementary variables
an optional row weights (by default, a vector of 1 for uniform row weights); the weights are given only for the active individuals
an optional column weights (by default, uniform column weights); the weights are given only for the active variables
boolean, if TRUE a graph is displayed. Default is FALSE.
a length 2 vector specifying the components to plot
Within-class Principal Component Analysis is a PCA where the active variables are centered on the mean of their class instead of the overall mean.
It is a "conditional" PCA and can be seen as a special case of PCA with orthogonal instrumental variables, with only one (categorical) instrumental variable.
An object of class
FactoMineR package, with an additional item :
the within-class inertia percentage
The code is adapted from
PCA function from
Escofier B., 1990, Analyse des correspondances multiples conditionnelle, La revue de Modulad, 5, 13-28.
Lebart L., Morineau A. et Warwick K., 1984, Multivariate Descriptive Statistical Analysis, John Wiley and sons, New-York.)