@@ -29,22 +29,26 @@ Exploratory factor analysis (EFA) is a statistical technique used to
2929identify latent relationships among sets of observed variables in a
3030dataset. In particular, EFA seeks to model a large set of observed
3131variables as linear combinations of some smaller set of unobserved,
32- latent factors.
32+ latent factors. The matrix of weights, or factor loadings, generated
33+ from an EFA model describes the underlying relationships between each
34+ variable and the latent factors.
3335
34- The matrix of weights, or factor loadings, generated from an EFA model
35- describes the underlying relationships between each variable and the
36- latent factors. Typically, a number of factors (K) is selected such that
37- it is substantially smaller than the number of variables. The factor
38- analysis model can be estimated using a variety of standard estimation
39- methods, including but not limited to OLS, minres, or MLE.
36+ Confirmatory factor analysis (CFA), a closely associated technique, is
37+ used to test an a priori hypothesis about latent relationships among sets
38+ of observed variables. In CFA, the researcher specifies the expected pattern
39+ of factor loadings, and other possible constraints on the model.
40+
41+ Typically, a number of factors (K) in an EFA or CFA model is selected
42+ such that it is substantially smaller than the number of variables. The
43+ factor analysis model can be estimated using a variety of standard
44+ estimation methods, including but not limited to OLS, minres, or MLE.
4045
4146Factor loadings are similar to standardized regression coefficients, and
4247variables with higher loadings on a particular factor can be interpreted
43- as explaining a larger proportion of the variation in that factor. In
44- many cases, factor loading matrices are rotated after the factor
45- analysis model is estimated in order to produce a simpler, more
46- interpretable structure to identify which variables are loading on a
47- particular factor.
48+ as explaining a larger proportion of the variation in that factor. In the
49+ case of EFA, factor loading matrices are usually rotated after the factor
50+ analysis model is estimated in order to produce a simpler, more interpretable
51+ structure to identify which variables are loading on a particular factor.
4852
4953Two common types of rotations are:
5054
@@ -56,11 +60,12 @@ Two common types of rotations are:
5660 upon the varimax rotation, but ultimately allows factors to become
5761 correlated.
5862
59- This package includes a stand-alone Python module with a ``FactorAnalyzer ``
60- class. The class includes an ``analyze() `` method that allows users to perform
61- factor analysis using either minres or MLE, with optional rotations on the factor
62- loading matrices. The package also offers a stand-alone ``Rotator `` class to
63- perform common rotations on an unrotated loading matrix.
63+ This package includes a ``factor_analyzer `` module with a stand-alone
64+ ``FactorAnalyzer``class. The class includes an ``analyze() `` method that
65+ allows users to perform factor analysis using either minres or MLE, with
66+ optional rotations on the factor loading matrices. The package also offers
67+ a stand-alone ``Rotator `` class to perform common rotations on an unrotated
68+ loading matrix.
6469
6570The following rotations options are available in both ``FactorAnalyzer ``
6671and ``Rotator ``:
@@ -73,8 +78,17 @@ and ``Rotator``:
7378 (f) quartimax (orthogonal rotation)
7479 (g) equamax (orthogonal rotation)
7580
76- Example
77- -------
81+ In adddition, the package includes a ``confirmatory_factor_analyzer ``
82+ module with a stand-alone ``ConfirmatoryFactorAnalyzer `` class. The
83+ class includes an ``analyze() `` method that allows users to perform
84+ confirmatory factor analysis using MLE. Performing CFA requires users
85+ to specify a model with the expected factor loading relationships and
86+ other constraints.
87+
88+ Examples
89+ --------
90+
91+ Exploratory factor analysis example.
7892
7993.. code :: python
8094
@@ -123,6 +137,67 @@ Example
123137 Proportion Var 0.351019 0.128371 0.073739
124138 Cumulative Var 0.351019 0.479390 0.553129
125139
140+ Confirmatory factor analysis example.
141+
142+ .. code :: python
143+
144+ In [1 ]: import pandas as pd
145+
146+ In [2 ]: from factor_analyzer import ConfirmatoryFactorAnalyzer
147+
148+ In [3 ]: data = pd.read_csv(' tests/data/test12.csv' )
149+
150+ In [4 ]: model = {' loadings' : {" Verbal" : [" english" , " vocab" , " socsci" ],
151+ ... : " Quant" : [" socsci" , " math" , " natsci" ]}}
152+
153+ In [6 ]: cfa.analyze(data, model, fix_first = False )
154+
155+ In [5 ]: cfa = ConfirmatoryFactorAnalyzer()
156+
157+ In [7 ]: cfa.loadings
158+ Out[7 ]:
159+ Verbal Quant
160+ english 3.532436 0.000000
161+ vocab 4.221969 0.000000
162+ socsci 3.281362 1.099739
163+ math 0.000000 4.888016
164+ natsci 0.000000 4.850257
165+
166+ In [8 ]: cfa.factor_covs
167+ Out[8 ]:
168+ Verbal Quant
169+ Verbal 1.000000 0.833013
170+ Quant 0.833013 1.000000
171+
172+ In [9 ]: cfa.error_vars
173+ Out[9 ]:
174+ evars
175+ english 9.249541
176+ vocab 5.044325
177+ socsci 5.782677
178+ math 15.519003
179+ natsci 9.406164
180+
181+ In [10 ]: loadings_se, error_vars_se = cfa.get_standard_errors()
182+
183+ In [11 ]: loadings_se
184+ Out[11 ]:
185+ Verbal Quant
186+ english 0.100785 0.000000
187+ vocab 0.098195 0.000000
188+ socsci 0.217784 0.216251
189+ math 0.000000 0.138298
190+ natsci 0.000000 0.123820
191+
192+ In [12 ]: error_vars_se
193+ Out[12 ]:
194+ error_vars
195+ english 0.385040
196+ vocab 0.353237
197+ socsci 0.307728
198+ math 0.742082
199+ natsci 0.600859
200+
126201 Requirements
127202------------
128203
0 commit comments