Repository navigation
ENH: adding pred_table to GLM, closes #1653 - #6252
tleininger wants to merge 1 commit into
Conversation
|
I think it should raise NotImplementedError with a message that explains why for models where it isn't possible. |
|
The other way to go would be to poke it on to the results if the family is Binomial, although this would keep it out of the docs which is a bad idea. |
|
I think, this only handles the binary case in Binomial. |
|
This could be turned into a standalone function that can be reused by all binary models, or similarly for multinomial models. |
Codecov Report
@@ Coverage Diff @@
## master #6252 +/- ##
==========================================
+ Coverage 84.57% 84.57% +<.01%
==========================================
Files 643 643
Lines 101010 101030 +20
Branches 11077 11078 +1
==========================================
+ Hits 85428 85450 +22
+ Misses 13136 13135 -1
+ Partials 2446 2445 -1
Continue to review full report at Codecov.
|
|
Actually, I think this can be extended to any type of endog by using binning. The implementation already uses histogram which also works with continuous data. We still need a standalone function to reuse it across models, I think this falls under |
|
I had the idea of a standalone function as well but wanted to keep my first contribution a little more contained. Are you okay with leaving the standalone version for another, more extensive issue? I like the histogram idea. I quickly tried the histogram approach and found that On the binomial counts question, that's a good point. What should the desired output be? Currently it will have one entry in the confusion matrix per row of endog (rather than one per trial), which I think is reasonable. You could alternatively base the confusion matrix on trials. |
|
Adding a standalone function is more contained in its impact. (e.g. I have most diagnostic functions as standalone functions, both because of reuse by several models, but mainly because I wasn't sure what the API should be for adding them as model methods) I think the binary pred_table has to raise when ntrials > 1 in binomial. I don't remember the details of bin edges. It will become relevant for integer counts, but shouldn't be a problem for Logit. |
|
Makes sense. I'll move this to diagnostics and see if I can come up with something sensible when ntrials > 1. With a fudge term, I should be able to make this work for any endog. |
This closes #1653, adding
pred_tabletogenmod.generalized_linear_model.GLM. The core functionality is copied from the Discrete case. Here, it only works for Binomial families and otherwise returnsNone. Unit tests, similar to those employed in the discrete case, have also been added.NumPy's guide.
Details
Notes:
needed for doc changes.
then show that it is fixed with the new code.
verify you changes are well formatted by running
flake8is installed. This command is also available on Windowsusing the Windows System for Linux once
flake8is installed in thelocal Linux environment. While passing this test is not required, it is good practice and it help
improve code quality in
statsmodels.