4

I am performing Confirmatory factor analysis in python using the factor_analyzer module.

I have searched hi and low for a way to generate the model diagnostics such as the Root Mean Square Error of Approximation, the chi square, the CFI and Tucker-Lewis index. I'm not particularly mathematically inclined and relatively new to python but I have been able to muddle through for the most part.

I understand that the factor_analyzer module produces a lot of different objects that allow would, in-theory, allow me to carry out additional calculations and I have found this document which provides me with most of the formula I need. However, I do not know what to take (or calculate) to get the model diagnostics I need.

The CFA code is


model_dict = {"F1": factor_1,
              "F2": factor_2}# I have made these lists previously

model_spec = ModelSpecificationParser.parse_model_specification_from_dict(df[influence_scale],
                                                                           model_dict)
cfa = ConfirmatoryFactorAnalyzer(model_spec, disp=False)

cfa.fit(df[influence_scale].values)

cfa_loadings = pd.DataFrame(cfa.loadings_)

I have gotten no errors and the code works fine giving me clean loadings as I would have expected on each factor, however I'm really stuck on getting the additional stats I need.

If anyone can help me out I'd really really appreciate it.

KevOMalley743
  • 551
  • 3
  • 20
  • 1
    I also cannot locate any documentation on this. I would like to compute CMIN, CFI, SRMR, RMSEA, etc. like in MPlus or AMOS. – Rob Jun 21 '20 at 00:54
  • 1
    Have you thought about [raising an issue on this](https://github.com/EducationalTestingService/factor_analyzer/blob/main/doc/factor_analyzer.rst)? I think this would be a very useful addition to the factor_analyzer package. – Johannes Wiesner Nov 13 '20 at 17:42
  • I have thought of it but honestly I'm not sure how to do it. I'm pretty new to the world of packages. – KevOMalley743 Nov 16 '20 at 10:09
  • 1
    I raised an issue for you on the [Github Page](https://github.com/EducationalTestingService/factor_analyzer/issues/70) – Johannes Wiesner Nov 19 '20 at 11:27

1 Answers1

1

You can calculate the chisquare using scipy.stats:

X, p = stats.chisquare(cfa_loadings)

However, I'm also stuck on the other GFI indices.