Repository navigation
Use link derivative for back-transformed SE and order CI bounds - #725
Merged
strengejacke merged 2 commits intoNov 27, 2026
Merged
Conversation
Member
|
Attaching as attributes is finde. LGTM, thanks! |
Member
|
Thanks. Two things:
|
strengejacke
approved these changes
Nov 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In
.backtransform_predictions(),exp(means$estimate) * means$std.errorapplies the log-link derivative to all link functions. Withpredict = "inverse_link",estimate_means(glm(am ~ factor(cyl) + wt, mtcars, binomial), by = "cyl")returns SE = 3.17 for cyl = 8 instead of 0.25 fromemmeans(..., type = "response")(abs(mu.eta(eta)) * SE). OnGamma("inverse"), SE is 0.0018 instead of 1.24 and the 95% CI is inverted ([29.47, 24.34])..link_inverse()now attachesmu.eta(including the bias-adjusted derivative),.backtransform_predictions()multiplies SE byabs(mu.eta(estimate))with a finite-difference fallback, and inverted CI bounds are swapped. Happy to passmu_etainpredict_argsinstead of an attribute if you prefer.Testing:
test-backtransform_se.R(15 passed, 8 failed before),test-bias_correction.R(4 passed),test-estimate_means.R(167 passed),test-offset.R(34 passed).