Skip to content

Commit 73641ea

Browse files
author
jbiggsets
committed
update to how we handle factor covariance matrix
1 parent 8cd1aa2 commit 73641ea

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

factor_analyzer/confirmatory_factor_analyzer.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -860,15 +860,10 @@ def analyze(self,
860860
# boundaries to (None, None) for everything except factor covariances;
861861
# at some point in the future, we may update this to place limits
862862
# on the loading matrix boundaries, too, but the case in R and SAS
863-
if bounds is None:
864-
bounds = [(None, None) for _ in range(loading_init.size +
865-
error_vars_init.shape[0] +
866-
factor_vars_init.shape[0] +
867-
factor_covs_init.shape[0])]
868-
869-
error_msg = ('The length of `bounds` must equal the length of your '
863+
if bounds is not None:
864+
error_msg = ('The length of `bounds` must equal the length of your '
870865
'input array `x0`: {} != {}.'.format(len(bounds), len(x0)))
871-
assert len(bounds) == len(x0), error_msg
866+
assert len(bounds) == len(x0), error_msg
872867

873868
# fit the actual model using L-BFGS algorithm;
874869
# the constraints are set inside the objective function,
@@ -896,6 +891,8 @@ def analyze(self,
896891
factor_vars_final = factor_vars if is_factor_vars_fixed else factor_vars_res
897892
factor_covs_final = merge_variance_covariance(factor_vars_final, factor_covs_final)
898893

894+
# if we aren't fixing the first variable to 1, then we need to make sure
895+
# to convert the covariance matrix into a correlation matrix
899896
if not fix_first:
900897
factor_covs_final = covariance_to_correlation(factor_covs_final)
901898

0 commit comments

Comments
 (0)