New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
null deviance and null loglikelihood for GLM #352
Conversation
Codecov Report
@@ Coverage Diff @@
## master #352 +/- ##
==========================================
- Coverage 79.56% 77.18% -2.38%
==========================================
Files 7 7
Lines 685 653 -32
==========================================
- Hits 545 504 -41
- Misses 140 149 +9
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Should be OK if it matches R, but can you check the other families too? You can reproduce examples from the tests.
I realized I forgot about this. I apologize for that. I will be picking this up slowly, starting with a rebase and then adding more checks against R as I continue tests. |
8a8b939
to
f385a65
Compare
Codecov Report
@@ Coverage Diff @@
## master #352 +/- ##
==========================================
- Coverage 79.56% 77.18% -2.38%
==========================================
Files 7 7
Lines 685 653 -32
==========================================
- Hits 545 504 -41
- Misses 140 149 +9
Continue to review full report at Codecov.
|
Bumping this for @andreasnoack and @nalimilan. I forgot about this PR for a long time but am determined to finish it. It just adds a I think I need some help getting this over the finish line. As you can see in the The original intention of this PR was to add |
Thanks. Looks good. For offsets, I think you can just add For the negative binomial, I think there are two different cases:
Regarding |
I just took a look at this again and spent a few hours trying to get I tried replicating what R does here but couldn't get numbers to match. In particular, I played around with Additionally, I noticed that R has different null deviance based on whether or not there is an intercept. However, GLM doesn't store whether or not a model has an intercept in anything but the object I will take another look at this soon and see if things start making sense. |
I guess, a concrete question: we have nested structs starting with
Currently, |
It's probably OK to have the functions take an If offset doesn't work, can you just throw an error when an offset has been specified? @kleinschmidt Opinions? |
One possibility is extending the use of The default would check the formula stored with a model and packages can implement their own specializations as needed... |
We're in GLM here so we don't have to follow any public interface. :-) |
Well, at the moment in order to support GLM models as they are usual fit by folks you'd have to define a The advantage of using |
Following discussion on Slack, I will write a little function that checks if the matrix has all constant for some value. This should be fast since if it was constructed via a After this I will add a few tests of models without intercepts. I am going to abandon my effort to get I also still have to work on negative binomial models. |
I ended up reimplementing this at #479. The handling of offsets is indeed tricky. Closing in favor the the other PR. |
This is a commit to fix #256, noting that GLM is without a null deviance or null log likelihood function. It's important to have this because likelihood ratio tests and R^2 use null deviance.
I am not 100% if this is correct. So far my results match R's
glm
withgaussian()
andbinomial()
families, but to be honest I am still taking econometrics courses so my knowledge of this is slim.I will add
nullloglikelihood
next, then tests for everything I can, then addr2
functions and anything else that might use them.