简体   繁体   English

提取心理包的fa.poly函数中因子的相关矩阵

[英]extract the correlation matrix for the factors in the psych package's fa.poly function

I'm working from caracal's great example conducting a factor analysis on dichotomous data and I'm now struggling to extract the factors from the object produced by the psych package's fa.poly function. 我从工作狞的很好的例子进行关于二分类数据的因素分析,现在我挣扎着从所生产的对象中提取的因素psych包的fa.poly功能。

Can anyone help me extract the factors from the fa.poly object (and look at the correlation)? 谁能帮助我从fa.poly对象中提取因子(并查看相关性)?

Please see caracal's example for the working example. 请参阅caracal的工作示例示例。

In this example you create an object with: 在此示例中,您将创建一个对象:

faPCdirect <- fa.poly(XdiNum, nfactors=2, rotate="varimax")    # polychoric FA

so somewhere in faPCdirect there is what you want. 所以在faPCdirect的某个地方有你想要的东西。 I recommend using str() to inspect the structure of faPCdirect 我建议使用str()来检查faPCdirect的结构

> str(faPCdirect)

List of 5
 $ fa   :List of 34
  ..$ residual    : num [1:6, 1:6] 4.79e-01 7.78e-02 -2.97e-0...
  .. ..- attr(*, "dimnames")=List of 2
  .. .. ..$ : chr [1:6] "X1" "X2" "X3" "X4" ...
  .. .. ..$ : chr [1:6] "X1" "X2" "X3" "X4" ...
  ..$ dof         : num 4
  ..$ fit      
      ...skip stuff....
  ..$ BIC         : num 4.11
  ..$ r.scores    : num [1:2, 1:2] 1 0.0508 0.0508 1
  .. ..- attr(*, "dimnames")=List of 2
  .. .. ..$ : chr [1:2] "MR2" "MR1"
  .. .. ..$ : chr [1:2] "MR2" "MR1"
  ..$ R2          : Named num [1:2] 0.709 0.989
  .. ..- attr(*, "names")= chr [1:2] "MR2" "MR1"
  ..$ valid       : num [1:2] 0.819 0.987
  ..$ score.cor   : num [1:2, 1:2] 1 0.212 0.212 1

So this says that this object is a list of five, with the first element called fa and that contains an element called score.cor that is a 2x2 matrix. 所以这说明这个对象是一个五个列表,第一个元素叫做fa ,它包含一个名为score.cor的元素,它是一个2x2矩阵。 I think what you want is the off diagonal. 我想你想要的是偏离对角线。

> faPCdirect$fa$score.cor
          [,1]      [,2]
[1,] 1.0000000 0.2117457
[2,] 0.2117457 1.0000000

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

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