3
$\begingroup$

I am using girth package which uses polychoric correlation and then applies factor analysis. I am using the example code given on above webpage under the subheading "Polychoric Correlation Estimation":

import girth.synthetic as gsyn
import girth.factoranalysis as gfa
import girth.common as gcm

discrimination = np.random.uniform(-2, 2, (20, 2))
thetas = np.random.randn(2, 1000)
difficulty = np.linspace(-1.5, 1, 20)

syn_data = gsyn.create_synthetic_irt_dichotomous(difficulty, discrimination, thetas)

polychoric_corr = gcm.polychoric_correlation(syn_data, start_val=0, stop_val=1)

results_fa = gfa.maximum_likelihood_factor_analysis(polychoric_corr, 2)

The data (20 columns and 1000 rows) is as follows:

     0   1   2   3   4   5   6   7   8   9   10  11  12  13  14  15  16  17  18  19
0     0   0   0   0   0   0   1   0   1   1   1   1   0   0   1   0   1   1   0   1
1     0   0   0   0   1   1   1   0   0   1   0   1   1   0   1   0   1   0   1   1
2     0   1   1   0   0   0   0   0   0   1   0   1   0   1   1   0   1   1   1   1
3     0   0   1   0   1   0   0   1   0   1   0   1   0   1   1   1   1   1   1   0
4     0   0   0   1   0   1   1   0   0   1   0   0   1   1   1   0   1   1   1   0
..   ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..  ..
995   1   1   0   0   0   1   1   0   1   0   1   0   1   0   0   1   0   0   1   0
996   0   1   1   1   0   0   0   1   0   1   0   1   1   1   1   0   0   1   1   1
997   1   0   0   1   1   1   1   0   1   0   0   0   0   1   0   1   1   1   0   1
998   0   0   1   0   0   0   0   0   0   1   0   0   1   0   1   1   0   1   1   1
999   0   0   1   1   1   0   1   0   0   0   1   0   0   0   0   0   0   1   1   1

The correlation matrix created is as follows:

          0         1         2         3         4         5         6   ...        13        14        15        16        17        18        19
0   1.000000 -0.372014 -0.242639 -0.450080  0.130449  0.453910  0.016924  ... -0.340188 -0.507171  0.482642 -0.018359 -0.285936 -0.422905  0.226303
1  -0.372014  1.000000  0.149975  0.333496 -0.195981 -0.301749  0.010126  ...  0.248877  0.353242 -0.360966 -0.032249  0.300746  0.250678 -0.176474
2  -0.242639  0.149975  1.000000  0.020036 -0.187157 -0.149063 -0.502865  ... -0.129884  0.294766  0.026245 -0.240363  0.511740  0.374489 -0.117930
3  -0.450080  0.333496  0.020036  1.000000 -0.043634 -0.372508  0.201392  ...  0.328995  0.395505 -0.534622  0.075794  0.159446  0.353241 -0.218804
4   0.130449 -0.195981 -0.187157 -0.043634  1.000000  0.171968  0.192930  ...  0.123934 -0.156043 -0.011919  0.139299 -0.245182 -0.232658  0.080830
5   0.453910 -0.301749 -0.149063 -0.372508  0.171968  1.000000  0.022395  ... -0.276296 -0.418714  0.473535 -0.014285 -0.327602 -0.396633  0.226920
6   0.016924  0.010126 -0.502865  0.201392  0.192930  0.022395  1.000000  ...  0.344361 -0.125337 -0.234694  0.301752 -0.356692 -0.280085 -0.069264
7  -0.037914  0.011994  0.507751 -0.162141 -0.275842 -0.081360 -0.574436  ... -0.311638  0.158223  0.177512 -0.366945  0.529308  0.364736 -0.033857
8   0.562803 -0.378088 -0.071710 -0.498235  0.053983  0.418691 -0.184258  ... -0.443017 -0.400253  0.601103 -0.105491 -0.121025 -0.337324  0.243227
9  -0.529324  0.384604  0.154708  0.516636 -0.123017 -0.397763  0.155550  ...  0.321337  0.401681 -0.478831  0.009805  0.321941  0.389378 -0.307586
10  0.361794 -0.220212  0.048604 -0.334888  0.000692  0.273246 -0.304177  ... -0.394676 -0.211652  0.400769 -0.186524 -0.049662 -0.181061  0.131394
11 -0.518512  0.239324  0.148274  0.309680 -0.025221 -0.344541  0.025191  ...  0.282115  0.429718 -0.422606 -0.010329  0.232012  0.388386 -0.213912
12  0.024234  0.021528  0.358700 -0.120740 -0.177754 -0.043941 -0.356709  ... -0.237652  0.057160  0.188560 -0.237153  0.263305  0.191856  0.007850
13 -0.340188  0.248877 -0.129884  0.328995  0.123934 -0.276296  0.344361  ...  1.000000  0.210238 -0.519403  0.170950 -0.051980  0.103658 -0.209891
14 -0.507171  0.353242  0.294766  0.395505 -0.156043 -0.418714 -0.125337  ...  0.210238  1.000000 -0.429463 -0.028562  0.372955  0.461054 -0.194371
15  0.482642 -0.360966  0.026245 -0.534622 -0.011919  0.473535 -0.234694  ... -0.519403 -0.429463  1.000000 -0.071710 -0.240631 -0.385008  0.242634
16 -0.018359 -0.032249 -0.240363  0.075794  0.139299 -0.014285  0.301752  ...  0.170950 -0.028562 -0.071710  1.000000 -0.207235 -0.197238 -0.070399
17 -0.285936  0.300746  0.511740  0.159446 -0.245182 -0.327602 -0.356692  ... -0.051980  0.372955 -0.240631 -0.207235  1.000000  0.459764 -0.125293
18 -0.422905  0.250678  0.374489  0.353241 -0.232658 -0.396633 -0.280085  ...  0.103658  0.461054 -0.385008 -0.197238  0.459764  1.000000 -0.145590
19  0.226303 -0.176474 -0.117930 -0.218804  0.080830  0.226920 -0.069264  ... -0.209891 -0.194371  0.242634 -0.070399 -0.125293 -0.145590  1.000000

The results of factor analysis are as follows:

(array([[ 0.0419671 , -0.73520752],
       [-0.03984031,  0.50963606],
       [-0.64915359,  0.24317354],
       [ 0.1862389 ,  0.64211114],
       [ 0.31887008, -0.15306844],
       [ 0.07858975, -0.61287159],
       [ 0.73044949,  0.07450868],
       [-0.80897573,  0.02504498],
       [-0.21818786, -0.73632751],
       [ 0.04928449,  0.70744866],
       [-0.29856161, -0.49485133],
       [-0.02069669,  0.58686592],
       [-0.52482931, -0.04802906],
       [ 0.41904667,  0.48510999],
       [-0.20016447,  0.63688427],
       [-0.2389381 , -0.7398583 ],
       [ 0.41800295,  0.01914967],
       [-0.58684168,  0.42456658],
       [-0.40758167,  0.58997834],
       [-0.01106376, -0.33936853]]), 

  array([3.12844677, 5.14338998]), 

  array([0.45770867, 0.73868383, 0.51946626, 0.55300836, 0.87489192,
       0.61821207, 0.46089202, 0.34493097, 0.41021586, 0.49708743,
       0.66598313, 0.65516004, 0.72224741, 0.58906818, 0.55431261,
       0.39551828, 0.82490682, 0.47536005, 0.48580274, 0.88470659]))

There are 3 arrays in the output. What do these 3 arrays represent? How does one interpret this output? Thanks for your insight.

Edit: It is surprising that there is no answer posted for this.

$\endgroup$

1 Answer 1

2
$\begingroup$

I am not familiar with the girth package, though after some reading I believe I have the answer.

  1. The first array corresponds to a 20 x 2 factor loading matrix $\Lambda$.

  2. The second array corresponds to each of the two factors eigenvalue.

  3. The third array corresponds to diag($\Psi$) which contains each items unexplained variance. This can be confirmed by subtracting each items commonality $h$ from 1.

$\endgroup$
1
  • $\begingroup$ Thanks for your answer. It will be useful if you can also briefly write how are these results to be interpreted? $\endgroup$
    – rnso
    Commented Dec 21, 2023 at 17:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.