Repository navigation
ENH: Revise loglike/deviance to correctly handle scale - #3856
Conversation
|
This pull request introduces 1 alert and fixes 1 - view on lgtm.com new alerts:
fixed alerts:
Comment posted by lgtm.com |
|
Lunch does marvelous thing. I think all but Gamma and Tweedie are working now. |
|
This pull request introduces 1 alert - view on lgtm.com new alerts:
Comment posted by lgtm.com |
4420677 to
3e562c7
Compare
|
I have most of this working, I think. Deviance and loglike seem good for pretty much everything except loglike for Gaussian. Also, I'm not totally convinced that my binomial loglike is working. I think the problem lies in this special case that I've never really understood (other than to match stata, I think). I also need to work on the docstrings... I'll play with that later... |
dbb7f01 to
d6b62d8
Compare
|
OK I realized that with ordinary least squares, its a rather simple adjustment... scale needs to be divided by I worked through the docstrings with some drafts.... lotsa changes so there's likely lotsa problems. For I probably need to proofread this. I believe this latest commit will pass all unittests. Considering I had to adjust the unittests to make this happen, I'm not sure how valid this truly is. I'll probably sleep on this progress. |
1 similar comment
|
I'd like to re-approach how we do documentation/structure of I've come to like the way that What I'd propose is that we move all the documentation for each family to the class level and have @josef-pkt Any thoughts? Maybe do this in another PR? I think it would make maintaining this documentation much easier. |
|
about documentation/class structure change: If the point is mainly to avoid duplication in docstrings, then I think using the template version that we use in several other classes that have elaborate inheritance. |
|
@josef-pkt Could you point me to a good example of a template version that statsmodels uses for documentation? |
|
I'm not sure about good examples because I don't use them much. |
|
one other thing I remembered: |
|
Sounds good. I might approach this in a different PR. My annoyance is that because I've had to re-do the API for a few of the methods, I was trying to make all the copypasta unnecessary. You are right though... the only other family that I guess we could add is multinomial. I'm unaware (generally) of any other family that we'd ever want to add and as this is all used internally, I have difficulty seeing any advantage here. Back to this PR, I still need to check a bunch and I'm hoping to find time tomorrow or this weekend at the latest. |
0fe4953 to
b2084b8
Compare
|
@josef-pkt Any thoughts on this? Basically, my strategery is that within I also fixed what I think is a bug with I gave the docstrings a read and they look pretty good to me. I fixed a few other things for readability-sake as well. Can you let me know if this is on a good path? |
1 similar comment
|
I updated my notebook in the gist again. So no warning about var_weights are needed in fit_regularized. |
…cov_type to summary
cde093c to
24d8a78
Compare
|
This pull request fixes 1 alert - view on lgtm.com fixed alerts:
Comment posted by lgtm.com |
|
@josef-pkt Anything else? Feels pretty good to me. I cov-type is working now. |
|
I was just playing :) I haven't seen any problems today, everything looks good in the examples. |
|
I added Poisson replicating Binomial to the gist. |
|
Too many details to review again. So I'm just merging this. Thanks @thequackdaddy Those things are a lot of work, and I'm glad I don't have to do it all myself, or for most parts don't have to do it at all myself. |
|
Thanks @thequackdaddy I closed two, but leave #3030 open for now (based on original motivation not because of content) |
|
Great. Let me know if I can be of any assistance getting a release out. Happy to help make statsmodels great again. |
|
Thanks, one task is to add the changes and enhancements to the release notes If the tweedie PR is not dangerous in the sense of having a not low probability of introducing new problems, then it could still be merged. |
|
about #3030 GLM class does not have loglike_obs yet for the standard interface. only the family has loglike_obs |
|
one more notebook in a gist (that's where I was missing loglike_obs) |
|
re anscombe residuals... for reasons I don't remember, I did not weight the residuals by Easy enough to change it. |
|
yes, I'm pretty sure we need var_weights in resid_anscombe the same way as scale. all of the anscombe look like they need |
|
using qqplot also shows that resid_anscombe without var_weights has the wrong scale/variance. an updated version in a new gist |
|
One more update to the latest notebook in gist The agreement between frequencies and standard normal probabilities is good, even higher than I expected, given that Poisson itself is not close to normal. (I just realized I forgot to reset the random.seed before running the var_weights version - FIXED in edit here) with exposure with var_weights (resid_anscombe not corrected yet) |
xref #3773
I apologize for this taking longer than had hoped, but my busy period was exacerbated by some unforeseen events. But I'm somewhat back now.
This is the first step to solving the above issue.
Still a lot is missing... I've only really gotten
logliketo work for all the families exceptGamma,Binomial,Gaussian, andTweedie(which has never hadloglike). I also need to re-work the docstrings. I'm thinking its more logical to have aloglike_obsfunction called in each family and then have aloglikefunction in theFamilyclass so thatloglikewill simply be inherited. I think you the doctrings could be elegantly written to handle this too.I'm thinking I will work on deviance next and then ciricle back to
loglike... I feel like R takes some computational shortcuts...