-
Notifications
You must be signed in to change notification settings - Fork 4
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
added delta method for glm links #37
added delta method for glm links #37
Conversation
Codecov Report
@@ Coverage Diff @@
## main #37 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 2 2
Lines 83 86 +3
=========================================
+ Hits 83 86 +3
📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more |
@spinkney thanks for your contribution! I wanted to just add tests and expand documentation, but the original math gave incorrect results. In the simplest identity case, the derivative is just a bunch a bunch of ones regardless of |
Nice, I didn't use the identity. Is it still wrong for other links? |
@spinkney I think there's another multiplication by the original |
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.
Looks good to me. This is a new feature but shouldn't be breaking (I'm assuming that the existing tests already cover the actual numbers that effects
returns) so bump patch and I think it's good to go.
By default (`invlink=identity`), effects are computed on the scale of the | ||
transformed response. For models with an explicit transformation, that | ||
transformation is the scale of the effects. For models with a link function, | ||
the scale of the effects is the _link_ scale, i.e. after application of the | ||
link function. For example, effects for logitistic regression models are on | ||
the logit and not the probability scale. |
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.
why is this the default when the link can (in principle) be obtained from the model itself? to avoid a dependency on GLM?
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.
Exactly, to avoid the dependency on GLM. As part of the associated docs issue (#38), I think it would be good to have a GLM example. If we decide to take GLM as a dependency, then we should add more specialized methods that take advantage of GLM.mueta
rather than using AD for the derivative.
Apologies for missing the re-review request for this but thanks @kleinschmidt for reviewing, @palday for getting it over the finish line, and of course @spinkney for the contribution. 🙂 |
I added the delta method for SE's after transformation. This pr adds an input into the
effects
function for the inverse link. The derivative of the effect is calculated usingForwardDiff
and the delta method is used to construct the SEs.I typically do not code in Julia so this may not be very Julian. It only took a few lines of code that I needed for a project I was working on. As such, you may use this pr as a reference to make the code more suitable for your needs and delete this pr.