繁体   English   中英

如何使用 factanal() 函数获取 R 中的结构矩阵?

[英]How to get the structure matrix in R using the factanal() function?

这是我在这个论坛上的第一篇文章。 我是 R 和因子分析的新手,我想我有一个非常简单的问题。 我正在关注 Andy Field 的“Discovering Statistics Using R”一书(2012 年)以获得一般指导。 Field 建议在使用倾斜旋转进行因子分析时同时提供模式和结构矩阵。

虽然模式矩阵只是载荷表,但我在使用factanal()函数获取 R 中的结构矩阵时遇到了更多困难。

为了使用principal()函数获取 PCA 的结构矩阵,Field 提供了以下公式: fit$loadings %*% fit$Phi ,它将因子加载矩阵乘以因子相关矩阵。 尽管factanal()确实将因子相关性存储在某处——因为它在一般输出的一部分(负载下)中提供它们——但我在输出中找不到名为“Phi”、“因子相关性”或等效物的对象拟合模型(在 R Studio 中)。 因此,我不知道在 Field 的公式中放入什么术语来替换 Phi 以获得结构矩阵。

我在这里这里看到,之前, factanal()没有提供因子相关性——但现在它确实在输出中提供了; 我只是不知道访问它的正确术语。 感谢您对此的任何帮助!


编辑:根据这本书,我使用以下公式与四个因子和 PCA 的倾斜旋转:

pc4 <- principal(raqData, nfactors = 4, rotate = "oblimin").

在这种情况下,当我在 R Studio 中双击对象“pc4”时,有一个名为“Phi”的对象,我可以pc4$loadings %*% pc4$Phi使用pc4$loadings %*% pc4$Phi获取结构矩阵。

接下来,我尝试使用 EFA,而不是 PCA,再次使用四个因子和倾斜旋转 (promax)。 这一步有效,我可以得到因子相关性(为了简洁起见,减少一些输出):

> fit <- factanal(mydata, 4, rotation="promax")
> fit
Call...
Uniquenesses...
Loadings...
SS loadings...
Factor Correlations:
        Factor1 Factor2 Factor3 Factor4
Factor1   1.000  -0.874   0.632   0.571
Factor2  -0.874   1.000  -0.118  -0.438
Factor3   0.632  -0.118   1.000   0.356
Factor4   0.571  -0.438   0.356   1.000
Test of the hypothesis that 4 factors are sufficient...

接下来,我尝试结构矩阵公式并得到以下错误:

> fit$loadings %*% fit$Phi
Error in fit$loadings %*% fit$Phi : 
  requires numeric/complex matrix/vector arguments

但是,当我检查与所获得的“适合”的对象factanal()不存在所谓的“披”对象(因为有对principal()不知道如何解释上述任何错误。我已经看到了这个错误讨论在这里这里,但我不清楚如何在这里解决它。

虽然这是一篇旧帖子,但为了帮助其他人,实际输出中的两个组件负载和 psi(不是 phi)是 fit$loadings 和 fit$uniqueness。 您可以通过编写 fit$loadings[,1:q] 来访问负载矩阵,其中 q 是您使用的因子。 例如 - 我在 R 工作室中的 Harman23.cor 数据上运行了 factanal。 并检查负载以低于输出。

> Harman23.FA <- factanal(factors = 3, covmat = Harman23.cor)
> Harman23.FA$loadings

Loadings:
               Factor1 Factor2 Factor3
height          0.886   0.267  -0.130 
arm.span        0.937   0.195   0.280 
forearm         0.874   0.188         
lower.leg       0.877   0.230  -0.145 
weight          0.242   0.916  -0.106 
bitro.diameter  0.193   0.777         
chest.girth     0.137   0.755         
chest.width     0.261   0.646   0.159 

               Factor1 Factor2 Factor3
SS loadings      3.379   2.628   0.162
Proportion Var   0.422   0.329   0.020
Cumulative Var   0.422   0.751   0.771

显然 $loadings 没有返回矩阵。 相反,您可以使用这个:

> as.matrix(Harman23.FA$loadings[,1:3])
                 Factor1   Factor2      Factor3
height         0.8859687 0.2666293 -0.130079754
arm.span       0.9371891 0.1951310  0.280364451
forearm        0.8741374 0.1876181  0.089154498
lower.leg      0.8768750 0.2303982 -0.144815728
weight         0.2422827 0.9164637 -0.106482093
bitro.diameter 0.1925419 0.7766283 -0.020581101
chest.girth    0.1368022 0.7554074  0.003677235
chest.width    0.2605798 0.6458413  0.159110501

请注意,此处使用的因子是 3,因此在访问加载时我们提到了 1:3 列。 同样,对于使用因子 q 运行 factanal,您应该提及 Harman23.FA$loadings[,1:q]。

另请注意,作为唯一性矩阵的 psi 是对角矩阵。 所以你应该像这样访问它

> psihat <- diag(Harman23.FA$uniquenesses)
> psihat
          [,1]  [,2]     [,3]      [,4]       [,5]      [,6]      [,7]      [,8]
[1,] 0.1270475 0.000 0.000000 0.0000000 0.00000000 0.0000000 0.0000000 0.0000000
[2,] 0.0000000 0.005 0.000000 0.0000000 0.00000000 0.0000000 0.0000000 0.0000000
[3,] 0.0000000 0.000 0.192735 0.0000000 0.00000000 0.0000000 0.0000000 0.0000000
[4,] 0.0000000 0.000 0.000000 0.1570353 0.00000000 0.0000000 0.0000000 0.0000000
[5,] 0.0000000 0.000 0.000000 0.0000000 0.09005497 0.0000000 0.0000000 0.0000000
[6,] 0.0000000 0.000 0.000000 0.0000000 0.00000000 0.3593523 0.0000000 0.0000000
[7,] 0.0000000 0.000 0.000000 0.0000000 0.00000000 0.0000000 0.4106308 0.0000000
[8,] 0.0000000 0.000 0.000000 0.0000000 0.00000000 0.0000000 0.0000000 0.4896708

否则你的矩阵乘法 fit$loadings %*% fit$Phi 将是非共形的

暂无
暂无

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

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