简体   繁体   English

R中的“手动”因素分析

[英]“Manual” Factor Analysis in R

I am trying to follow along the Factor Analysis chapter in "Using Multivariate Statistics", by Tabachnick and Fidell. 我试图遵循Tabachnick和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. 相关矩阵和特征值(2.02、1.94、0.04和0.00)与书中的相对应。 The first two eigenvectors I have are (.352, -0.251, -0.626, -0.647) and (.514, -.664, .322, .280). 我具有的前两个特征向量是(.352,-0.251,-0.626,-0.647)和(.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). 但是,该书随后继续说,仅保留了前两个特征值,并且“重新进行因子分析”会导致以下两个特征值*:2.00、1.91和特征向量(-2,83、0.177、0.568, 0.675)和(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*. 我无法计算出这些特征向量...如果运行psych::fa(cor.ski, nfactors=2, fm="pa") ,则SS加载对应于新的特征值*。

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! 我通过记住R是一种可见的语言来解决这个问题! 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"; 通过查看psych::fac的定义,我看到作者实际上已经进行了7次因子分析迭代,而不是mereley“获取了前两个特征向量并重新运行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 从相关矩阵(r)开始并假设使用了k个因子

  • Get eigenvalues (L) and eigenvectors (V) of correlation matrix r 获取相关矩阵r的特征值(L)和特征向量(V)
  • Calculate C = sum(diag(R)) 计算C = sum(diag(R))
  • Calculate the loadings, A = V[,1:k] * Sqrt{L[1:k]} (eqn 13.6 of text) 计算载荷,A = V [,1:k] * Sqrt {L [1:k]}(文本的等式13.6)
  • set R* = AA' (eqn 13.5 of text, R=AA') 设置R * = AA'(文本的13.5,R = AA')
  • set C* = sum(diag(R*)) 设置C * = sum(diag(R *))
  • Update diag(R) = diag(R*) 更新diag(R)= diag(R *)
  • Repeat above steps until max iterations reached, or until e = abs(CC*) is smaller than some threshold 重复上述步骤,直到达到最大迭代次数,或直到e = abs(CC *)小于某个阈值

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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