Skip to content

ENH: add wls_method option, mle_settings to GLM fit IRLS - #4021

Merged
josef-pkt merged 2 commits into
statsmodels:masterfrom
josef-pkt:glm_irls_method
Oct 26, 2017
Merged

josef-pkt merged 2 commits into
statsmodels:masterfrom
josef-pkt:glm_irls_method

Conversation

@josef-pkt

Copy link
Copy Markdown
Member

closes #4001
add wls_method fit option
adds mle_settings to results in fit_irls see comments in #2401

(started out to investigate differences across linear algebra functions, but should be good to merge)

extra keyword introduced for testing
attach_wls to attach the final WLS results to the GLMResults instance.
not included in docstring
(used in unit tests, and will be useful for future development, e.g. for diagnostics.
It is doubtful whether this will be in the final API, e.g. WLS results are not available with fit_gradient.)

@coveralls

coveralls commented Oct 11, 2017 •

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.009%) to 81.65% when pulling 6b631df on josef-pkt:glm_irls_method into 326ae0c on statsmodels:master.

@codecov-io

codecov-io commented Oct 11, 2017 •

Copy link
Copy Markdown

Codecov Report

Merging #4021 into master will increase coverage by 0.03%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4021      +/-   ##
==========================================
+ Coverage   79.23%   79.27%   +0.03%     
==========================================
  Files         543      544       +1     
  Lines       81351    81448      +97     
  Branches     9226     9235       +9     
==========================================
+ Hits        64460    64565     +105     
+ Misses      14800    14787      -13     
- Partials     2091     2096       +5
Impacted Files Coverage Δ
statsmodels/genmod/tests/test_glm.py 98.71% <100%> (+0.02%) ⬆️
statsmodels/genmod/generalized_linear_model.py 88.93% <100%> (+0.23%) ⬆️
statsmodels/tsa/vector_ar/vecm.py 93.62% <0%> (-0.25%) ⬇️
statsmodels/stats/tests/test_lilliefors.py 100% <0%> (ø)
statsmodels/stats/_lilliefors.py 83.14% <0%> (+8.63%) ⬆️
statsmodels/regression/_tools.py 100% <0%> (+10.71%) ⬆️
statsmodels/stats/tabledist.py 40.78% <0%> (+11.84%) ⬆️

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 f186fec...94fd288. Read the comment docs.

@josef-pkt

Copy link
Copy Markdown
Member Author

I thought I had merged this already.
looks fine to me

@bashtage bashtage left a comment

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.

Some doc fixes would help, looks right.

options are 'lstsq', 'pinv' and 'qr'
specifies which linear algebra function to use for the irls
optimization. Default is `lstsq` which uses the same underlying
svd based approach as 'pinv', but is faster during iterations.

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.

For end users, could you explain why one would use one of the others.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I added two sentences but no full explanation.
(AFAIK, we don't have any notes anywhere on the choice of linalg functions)

Fits a generalized linear model for a given family using
iteratively reweighted least squares (IRLS).
"""
attach_wls = kwargs.pop('attach_wls', False)

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.

Is this kwarg documented anywhere?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

No, only in the description of this PR. It's currently a private backdoor, until we have a use for it outside of unit tests.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I added it to the Notes section, mentioning it's internal

@josef-pkt

Copy link
Copy Markdown
Member Author

rebased and some addition to docstrings

should be ready to merge, when green

@coveralls

coveralls commented Oct 25, 2017 •

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.04%) to 81.844% when pulling 94fd288 on josef-pkt:glm_irls_method into f186fec on statsmodels:master.

@josef-pkt

Copy link
Copy Markdown
Member Author

All green, after waiting in the test queue for hours.

merging

@josef-pkt
josef-pkt merged commit bf593d6 into statsmodels:master Oct 26, 2017
@josef-pkt josef-pkt added this to the 0.9 milestone Apr 15, 2018
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.

ENH/BUG: GLM fit_irls does not have a method option

4 participants