0

I am trying to extract the principal components for a covariance matrix using PCA in FactoMiner. However, for some reason , I only see n-1 components in the var-->coord variable

library(FactoMineR)
x = matrix(rnorm(10000),nrow = 100,ncol = 100)
y = PCA(x,ncp = 100,graph = FALSE)
dim(y$var$coord)

This leads to an output of 100 99. I am new to this package and hope to get more insights

  • I would suggest inspecting the output of `str(y)` – Marat Talipov Dec 23 '15 at 18:04
  • 1
    The [official docs](http://factominer.free.fr/classical-methods/principal-components-analysis.html) may be helpful. – iled Dec 23 '15 at 18:04
  • I checked the official docs before and in the first pass have not been able to pinpoint the reason. If I do str(y), every variable combination i see has the same dimensions of 100x99 – Nishant Kachawa Dec 23 '15 at 18:16

1 Answers1

1

The maximum number of dimensions in a principal component analysis performed on p variables and n observations is min(p;n-1). You have a matrix of 100x100, so that would be min(100;99) = 1. Try this with a 100x101 matrix and you will be able to extract 100 dimensions:

x = matrix(rnorm(10100),nrow = 101,ncol = 100)
y = PCA(x,ncp = 100,graph = FALSE)
dim(y$var$coord)
[1] 100 100

That said, the whole point of PCA is to reduce your data to a few dimensions, so trying to use them all defeats its purpose.

scoa
  • 19,359
  • 5
  • 65
  • 80
  • Hey thanks for the clarification. I had misunderstood the function.Rather than passing the covariance matrix, I should pass the underlying data. I agree the purpose is to reduce dimensionality but I am using it to do extract the eigenvalues and then modify them to get a more stable representation. Thanks again for the help – Nishant Kachawa Dec 23 '15 at 21:49