Repository navigation
Fix the link-scale footer text for transform, and the transform = exp error in estimate_contrasts() - #689
Merged
Conversation
…r output is the data
…row the NEWS entry
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Add coverage for transformed-response footer labeling and correct the remaining comment typo.
1 open issue
What changed in this PR
Fixes link-scale footer labels and preserves user-supplied transformations across prediction and contrast workflows.
Changes:
- Adds transformation-aware footer labeling.
- Preserves transformation metadata and corrects precedence when reusing outputs.
- Adds regression tests and bumps the package version.
| File | Summary |
|---|---|
tests/testthat/test-table_footer.R |
Adds footer regression coverage. |
R/table_footer.R |
Generates corrected link-scale labels; transformed-response coverage is still needed. |
R/get_marginalmeans.R |
Stores the original transform argument; includes a comment typo. |
R/get_marginalcontrasts.R |
Propagates transformation metadata. |
R/estimate_predicted.R |
Corrects inherited metadata precedence. |
NEWS.md |
Documents the fixes. |
DESCRIPTION |
Bumps the development version. |
Review effort: Lite
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.

For non-linear models, the footer of link-scale output printed "FALSE-transformed link-scale" or "TRUE-transformed link-scale".
.table_footer()(R/table_footer.R) pastedtransforminto the text. But most callers storetransformasTRUEorFALSE, and the emmeans code always storesTRUE.Example, with
d <- mtcars; d$cyl <- factor(d$cyl)andg <- glm(am ~ wt + cyl, data = d, family = binomial):estimate_link(g, by = "cyl")estimate_means(g, "cyl", predict = "link", backend = "emmeans")estimate_means(g, "cyl", predict = "link", transform = exp)estimate_contrasts(g, "cyl", predict = "link", transform = exp)estimate_contrasts(g, "cyl", predict = "link", transform = "exp")estimate_expectation(g, data = estimate_link(g, by = "cyl"))What changed:
transform_argkeeps thetransformargument as the user passed it.get_marginalmeans(),get_marginalcontrasts()and.estimate_predicted()set it. The new helper.link_transform_label()reads it for the link-scale line. A name such as"exp"gives "exp-transformed", and a function gives "transformed". Ifinsight::find_transformation()finds a response transformation,transform = TRUEgives "transformed". Otherwise it gives "link-scale", because nothing changes. The logicaltransformattribute stays as it was, because the plot code and the linear-model hint read it.databrings its ownpredictandtransformattributes into.estimate_predicted(). Before,c(grid_specs, list(predict = predict), ...)put them first, soinfo$predicttook the old value. Now the values of the call replace them.Tests in
test-table_footer.Rcover the calls above with both backends, andtransform = TRUE. They also cover an earlier output asdatain both directions, contrasts ofestimate_link()output, and contrasts of slopes.Not fixed here:
transformfunction changed the values.estimate_link(g, transform = "exp")with a string stops with "could not find function trans_fun".backend = "emmeans"ignores atransformfunction inestimate_means().data, the footer reads themodel_infoof that output.devtools::test()gives 0 failures and 0 errors locally.devtools::check()gives 0 errors and 0 warnings. The version is bumped to 0.17.0.17.