Eric Fail
Eric Fail

Reputation: 7928

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.

Can anyone help me extract the factors from the fa.poly object (and look at the correlation)?

Please see caracal's example for the working example.

Upvotes: 0

Views: 1227

Answers (1)

Seth
Seth

Reputation: 4795

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. I recommend using str() to inspect the structure of 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. 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

Upvotes: 2

Related Questions