Confirmatory Factor Analysis (CFA) for Bifactor Model
The following Python code demonstrates how to perform a confirmatory factor analysis (CFA) for a bifactor model with orthogonal factors using the semopy
library. The model includes two specific latent factors: Optimism and Pessimism, along with a general latent factor, Dispositional. The dataset is expected to be in CSV format with 521 observations.
1 | # Import necessary libraries |
Explanation
- Library: The
semopy
library is used for structural equation modeling in Python. - Data Input: Replace
data.csv
with the path to your CSV file. - Model Syntax: The
descriptor
variable defines the bifactor model, including general and specific factors. Orthogonality constraints are included. - Fit Statistics: Fit indices such as χ², df, CFI, TLI, RMSEA, and SRMR are calculated and printed.
Relevant Research Articles
- Paper: Confirmatory Factor Analysis for Applied Research by Timothy A. Brown
Recommended Books for Mathematical Foundations
Russian
- Быстров В.П. - “Математическая статистика: теория и применение”
- Морозов М.В. - “Основы факторного анализа”
English
- Raykov & Marcoulides - “Introduction to Psychometric Theory”
- Keith F. Widaman - “Factor Analysis in Social Research”