简体   繁体   中英

“Manual” Factor Analysis in R

I am trying to follow along the Factor Analysis chapter in "Using Multivariate Statistics", by Tabachnick and Fidell.

The data, and my steps, are as follows:

# data
dat.ski <- data.frame(skiers = paste0("S", c(1:5), sep=""), cost = c(32, 61, 59, 36, 62), lift=c(64, 37, 40, 62, 46) , depth = c(65, 62, 45, 34, 43), powder = c(67, 65, 43, 35, 40))

# correlation matrix
cor.ski <- cor(dplyr::select(dat.ski, -skiers)) 

# eigenvalues and eigenvectors
eig.ski <- eigen(cor.ski)

The correlation matrix and eigenvalues (2.02, 1.94, 0.04 and 0.00) correspond to that in the book. The first two eigenvectors I have are (.352, -0.251, -0.626, -0.647) and (.514, -.664, .322, .280).

However, the book then continues to say that only the first two eigenvalues are retained and the "factor analysis is re-run" which results in the following two eigenvalues*: 2.00, 1.91 and eigenvectors (-2,83, 0.177, 0.568, 0.675) and (0.651, -0.685, 0.252, 0.207). I can't work out to reproduce these eigenvectors... if I run psych::fa(cor.ski, nfactors=2, fm="pa") , the SS loadings correspond to the new eigenvalues*.

Any help on how to return the eigenvectors as per the text will be greatly appreciated.

Thanks.

I worked this out by remembering that R is a visible language! By looking at the definition of psych::fac , I see that the authors have actually performed 7 iterations of factor analysis, not mereley "taken the first two eigenvectors and rerun FA"; I also finally understand how factor analysis is performed and can tie it in with the subsequent text, which in a nutshell is:

Starting with the correlation matrix (r) and assuming k factors are used

  • Get eigenvalues (L) and eigenvectors (V) of correlation matrix r
  • Calculate C = sum(diag(R))
  • Calculate the loadings, A = V[,1:k] * Sqrt{L[1:k]} (eqn 13.6 of text)
  • set R* = AA' (eqn 13.5 of text, R=AA')
  • set C* = sum(diag(R*))
  • Update diag(R) = diag(R*)
  • Repeat above steps until max iterations reached, or until e = abs(CC*) is smaller than some threshold

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM