The problem you encountered is because you have specified all of your variables as supplementary variables when you call PCA()
.
To illustrate with an example we can use the built in dataset USJudgeRatings
.
head(USJudgeRatings)
CONT INTG DMNR DILG CFMG DECI PREP FAMI ORAL WRIT PHYS RTEN
AARONSON,L.H. 5.7 7.9 7.7 7.3 7.1 7.4 7.1 7.1 7.1 7.0 8.3 7.8
ALEXANDER,J.M. 6.8 8.9 8.8 8.5 7.8 8.1 8.0 8.0 7.8 7.9 8.5 8.7
ARMENTANO,A.J. 7.2 8.1 7.8 7.8 7.5 7.6 7.5 7.5 7.3 7.4 7.9 7.8
BERDON,R.I. 6.8 8.8 8.5 8.8 8.3 8.5 8.7 8.7 8.4 8.5 8.8 8.7
BRACKEN,J.J. 7.3 6.4 4.3 6.5 6.0 6.2 5.7 5.7 5.1 5.3 5.5 4.8
BURNS,E.B. 6.2 8.8 8.7 8.5 7.9 8.0 8.1 8.0 8.0 8.0 8.6 8.6
In this data there are 43 judges who were ranked on 11 qualities by lawyers (columns 2:12). Column 1 is the number of contacts the lawyers had with the judge.
The PCA won't work if you specify that all variables are supplementary.
library(FactoMineR)
result <- PCA(USJudgeRatings, ncp = 3, quanti.sup = 1:12)
# Error in eigen(t(X) %*% X, symmetric = TRUE) : 0 x 0 matrix
We have to give the PCA some variables to work with. Instead, we let our 11 variables go into the PCA and specify only the number of contacts the lawyers had with the judges as a quantitative supplementary variable:
result <- PCA(USJudgeRatings, ncp = 3, quanti.sup = 1)
This runs and you can then view the results with summary.PCA(result)
.
hcpc <- hcpc(pca, nb.clust = 0, conso = 0, min=3,max=10) Error in hcpc(pca, nb.clust = 0, conso = 0, min=3,max=10) : object 'res.consol' not found
@LJW do you know why's that? – Diego Aguado