Summed up, running an EFA with statsmodels follows the same fit-then-inspect workflow as the other models in this book. Please read through the documentation for a detailed overview.
from statsmodels.multivariate.factor import Factor
fa = Factor(endog=data, # a DataFrame of observed variables
n_factor=3, # the number of factors to extract
method="ml", # "ml" (maximum likelihood) or "pa" (principal axis)
corr=None, # pass a correlation matrix here instead of raw data
smc=True).fit() # squared multiple correlations as initial communalities
fa.rotate("oblimin") # rotate in placeThe most important options are:
n_factor: the number of factorsmethod: the fitting method,"ml"for maximum likelihood or"pa"for principal axiscorr: set this if you already have a correlation matrix rather than raw datarotate(method): the rotation applied after fitting. Orthogonal options includevarimaxandquartimax; oblique options includeoblimin,quartiminandpromax
We can then extract the estimates such as eigenvalues, loadings, and communalities:
import numpy as np
eigenvalues = np.sort(np.linalg.eigvalsh(data.corr()))[::-1] # for the Kaiser criterion
loadings = np.real_if_close(fa.loadings) # item x factor matrix
communalities = 1 - fa.uniqueness # variance explained per item
print(fa.summary()) # a formatted overview of loadings and uniquenesses