Skip to content

Principal axis factor analysis and rotation - #4161

Merged
josef-pkt merged 28 commits into
statsmodels:masterfrom
yl565:factoranalysis_rotate
Dec 14, 2017
Merged

josef-pkt merged 28 commits into
statsmodels:masterfrom
yl565:factoranalysis_rotate

Conversation

@yl565

@yl565 yl565 commented Dec 12, 2017

Copy link
Copy Markdown
Contributor

Continuation of #3294

@josef-pkt

Copy link
Copy Markdown
Member

rebase looks good from what I can see on github

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.08%) to 81.958% when pulling 411c7c8 on yl565:factoranalysis_rotate into 98f5db9 on statsmodels:master.

1 similar comment
@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.08%) to 81.958% when pulling 411c7c8 on yl565:factoranalysis_rotate into 98f5db9 on statsmodels:master.

Comment thread statsmodels/multivariate/factor.py Outdated
summ.add_dict({'': 'Pre-rotated loadings'})
summ.add_df(loadings_no_rot)
summ.add_dict({'': ''})
if self.rotation is not None:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BUG from renamings
self.rotation -> self.rotation method
also on line 318

summary() needs a smoke test.
If the result is stable and doesn't change on repeated runs, then the full summary string could be tested as equal to a saved summary.

@josef-pkt

Copy link
Copy Markdown
Member

@yl565 Can you add the R commands for producing the reference numbers in the unit tests to the test module?

I'm trying out an example from Steiger (using factanal and fa.promax) http://www.statpower.net/Content/312/Handout/Exploratory%20Factor%20Analysis%20with%20R.pdf
but the loadings after rotation don't match up at two decimals, they are still close except after promax the last factor has flipped sign, all loadings negative.

The results look sensitive to algorithmic details, and it's better to have the record for how the reference numbers were created, and which R function and which options correspond to our solution.

@yl565

yl565 commented Dec 13, 2017

Copy link
Copy Markdown
Contributor Author

I added the R code in docstrings. I have to flip the sign on some of the loading vectors to be able to match the results though.

@josef-pkt

Copy link
Copy Markdown
Member

Can you amend (and force push) the last commit to change the docstring of the unit test function to code comments with #?
nosetest was using the docstring in the unit test results (verbose and failure) instead of the function or method name. I guess pytest is doing something similar. That's why we never use a docstring for any test_xxx functions and methods.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.1%) to 81.982% when pulling 69d6581 on yl565:factoranalysis_rotate into 98f5db9 on statsmodels:master.

1 similar comment
@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.1%) to 81.982% when pulling 69d6581 on yl565:factoranalysis_rotate into 98f5db9 on statsmodels:master.

@codecov-io

codecov-io commented Dec 13, 2017 •

Copy link
Copy Markdown

Codecov Report

Merging #4161 into master will increase coverage by 0.07%.
The diff coverage is 86.93%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4161      +/-   ##
==========================================
+ Coverage    79.3%   79.38%   +0.07%     
==========================================
  Files         546      554       +8     
  Lines       81807    82603     +796     
  Branches     9268     9428     +160     
==========================================
+ Hits        64880    65572     +692     
- Misses      14828    14883      +55     
- Partials     2099     2148      +49
Impacted Files Coverage Δ
...atsmodels/multivariate/factor_rotation/__init__.py 100% <100%> (ø)
...tsmodels/multivariate/factor_rotation/_wrappers.py 73.68% <73.68%> (ø)
statsmodels/multivariate/factor.py 74.11% <74.11%> (ø)
...dels/multivariate/factor_rotation/_gpa_rotation.py 87.34% <87.34%> (ø)
...multivariate/factor_rotation/_analytic_rotation.py 87.5% <87.5%> (ø)
statsmodels/multivariate/plots.py 91.66% <91.66%> (ø)
statsmodels/multivariate/tests/test_factor.py 96.72% <96.72%> (ø)
...ultivariate/factor_rotation/tests/test_rotation.py 98.96% <98.96%> (ø)
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 98f5db9...a130009. Read the comment docs.

@yl565
yl565 force-pushed the factoranalysis_rotate branch from 69d6581 to a130009 Compare December 13, 2017 23:34
@yl565

yl565 commented Dec 13, 2017

Copy link
Copy Markdown
Contributor Author

OK, I amended the last comit

@coveralls

coveralls commented Dec 14, 2017 •

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.1%) to 81.982% when pulling a130009 on yl565:factoranalysis_rotate into 98f5db9 on statsmodels:master.

@josef-pkt

Copy link
Copy Markdown
Member

all green, I merge this but still needs followup (api, rst, check docstring rendering, ...)

It's a good first part of factor analysis and includes rotation.

@yl565 Thank you

@josef-pkt
josef-pkt merged commit b2c1c35 into statsmodels:master Dec 14, 2017
@josef-pkt josef-pkt added this to the 0.9 milestone Dec 14, 2017
@yl565

yl565 commented Dec 14, 2017

Copy link
Copy Markdown
Contributor Author

Thanks @josef-pkt

@josef-pkt josef-pkt mentioned this pull request Apr 9, 2018
@josef-pkt josef-pkt modified the milestone: 0.9 Apr 15, 2018
@josef-pkt josef-pkt mentioned this pull request Dec 13, 2024
2 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants