Skip to content

Add comparison = "ratio" as shortcut - #672

Merged
strengejacke merged 5 commits into
mainfrom
add_shortcut_ratios
Oct 8, 2026
Merged

strengejacke merged 5 commits into
mainfrom
add_shortcut_ratios

Conversation

@strengejacke

Copy link
Copy Markdown
Member

No description provided.

@strengejacke
strengejacke requested a lite review from Copilot October 8, 2026 11:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

2 open findings
What changed in this PR

Adds a new comparison = "ratio" shortcut to estimate_contrasts() / marginal contrasts generation, so users can request pairwise ratios without writing formula syntax.

Changes:

  • Add "ratio" as a recognized comparison string and internally map it to ratio ~ pairwise.
  • Update formatting logic to treat "ratio" like the formula-based ratio comparison.
  • Add NEWS + documentation updates and a new test covering the shortcut.
File Description
tests/​testthat/​test-estimate_contrasts.R Adds test asserting comparison="ratio" returns expected columns/value
R/​get_marginalcontrasts.R Implements "ratio" shortcut mapping and allows "ratio" in validation
R/​format.R Updates ratio-detection logic to support string "ratio" as well as formulas
R/​estimate_contrasts.R Documents "ratio" as a supported comparison string and explains behavior
NEWS.md Announces new comparison="ratio" shortcut
DESCRIPTION Bumps package version
Files not reviewed (2)
  • man/estimate_contrasts.Rd: Generated file
  • man/get_emmeans.Rd: Generated file

🧠 Review effort: Lite


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

Comment on lines +1994 to +1995
expect_named(out, c("Level1", "Level2", "Ratio", "SE", "CI_low", "CI_high", "z", "p"))
expect_equal(out$Ratio, 6.14634, tolerance = 1e-4)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exp(coef()) returns an odds ratio, while estimate_contrasts(m, "sex", comparison = "ratio") computes the ratio between two predicted probabilities, i.e. a risk ratio.

Comment thread NEWS.md Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@strengejacke
strengejacke merged commit 2a51861 into main Oct 8, 2026
11 of 20 checks passed
@strengejacke
strengejacke deleted the add_shortcut_ratios branch October 8, 2026 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants