Marine Jeanjean
Marine Jeanjean

Reputation: 1

Extract eigenvalues from gm.prcomp

I am used to using plottangentspace from geomorph package. This function has been replaced by gm.prcomp, but I am not able to extract eigenvalues, even if I used the function summary, or summary.gm.prcomp. If I used summary, I have statistical summary (mean...), and I can't use summary.gm.prcomp (R doesn't find the function) How can I do to extract my eigenvalues?

Thank you for your help!

Marine

Upvotes: 0

Views: 574

Answers (1)

AlexTinius
AlexTinius

Reputation: 11

The function 'gm.prcomp' reports the singular value decomposition of the VCV matrix, and you can reconstruct Eigenvalues from there, as the sum singular value decomposition is equivalent to the total variance in the data.

Say 'ProcFit$coords' is our Procrustes-fitted data, then

PCA<-gm.prcomp(ProcFit$coords) # calculates the PCA
PCA$d[1]/sum(PCA$d) # provides the Eigenvalue for the first principal component.

You can also see the resemblance to Eigenvalues, if you

plot(PCA$d)

Or, for example, if you want to build a data frame from all PCs that accumulatively explain at least 80% of the variation:

PCframe <- function(PCA, CutOff=80) { # default cutoff of 80%
EigenSum<-k<-0
repeat {
k<-k+1
EigenSum<-EigenSum+PCA$d[k]/sum(PCA$d)
if(EigenSum>=CutOff/100) {
break}}
PCAframe<-data.frame(PCA$x[,1:k])
return(PCAframe)}

Upvotes: 0

Related Questions