Repository navigation
DOC: Clarify/fix docs on GLM scale estimation for negative binomial - #5277
Conversation
Codecov Report
@@ Coverage Diff @@
## master #5277 +/- ##
==========================================
+ Coverage 81.71% 81.71% +<.01%
==========================================
Files 569 569
Lines 89699 89699
Branches 10028 10028
==========================================
+ Hits 73294 73295 +1
Misses 14132 14132
+ Partials 2273 2272 -1
Continue to review full report at Codecov.
|
|
#2888 |
|
It's strange that the docs say this:
The default scale for Binomial and Poisson families is 1. The default for
the other families is Pearson's Chi-Square estimate.
but the relevant piece of code includes negative binomial together with
binomial and poisson:
https://github.com/statsmodels/statsmodels/blob/e1d1156a0a87f1baee5df4e6cb354b176924890e/statsmodels/genmod/generalized_linear_model.py#L780
Also, although R reports what appears to be a chi-square estimated scale
(dispersion) factor in the printed summary, it doesn't seem to register in
the fitted model itself (summary(m)$dispersion is 1), and the standard
errors seem to ignore the fitted dispersion.
…On Sat, Sep 29, 2018 at 8:51 PM Josef Perktold ***@***.***> wrote:
#2888 <#2888>
GLM NegativeBinomial uses Pearson chi2 as scale, same as R
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#5277 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACiww1LMqBVrj83ixAW7Bz2kZ2Gs2Dmtks5ugBWTgaJpZM4XAusE>
.
|
|
a quick check using pdb on a test_glm.py example, looks like pearson scale is used for I don't have a notebook with an example at the moment, but will look into this again. |
|
In the code for hessian, if scale=None, then estimate_scale is used (Pdb) self.res1.model.scaletype (Pdb) self.res1.model.family |
|
my mistake The test case uses and explicitly asks for pearson scale |
|
This means we have a full test case against R and Stata that |
|
another check: if I change to default |
|
There might have been a change in the default in the glm scale refactoring There is also some special casing of NegativeBinomial in the unit tests for llf, so it's not clear to me now what's tested. It looks like Stata uses scale=1 for llf even in the dispersion case. |
|
added NegativeBinomial to the list of families with scale=1. |
|
So this PR looks good and adjusts the docstrings to the new default. |
Scale parameter for negative binomial in GLM fitting is fixed at 1.