Repository navigation
fix(r_to_oddsratio): forward n1 and n2 to r_to_d() - #725
Merged
Merged
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the group-size forwarding fix.
No open issues 🎉
What changed in this PR
Fixes correlation-to-odds-ratio conversion by forwarding group sizes to r_to_d(), so unequal group sizes are respected by both r_to_oddsratio() and r_to_logoddsratio().
Changes:
- Passes
n1andn2tor_to_d()instead ofd_to_oddsratio(). - Adds regression tests for unequal group sizes, single-group-size arguments, and round-trip consistency.
| File | Description |
|---|---|
| tests/testthat/test-convert_between.R | Adds regression coverage for group-size forwarding and conversion consistency. |
| R/convert_between_d_to_r.R | Corrects group-size forwarding in r_to_oddsratio(). |
Review effort: Balanced
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #725 +/- ##
==========================================
- Coverage 90.75% 89.04% -1.71%
==========================================
Files 59 59
Lines 4488 4491 +3
==========================================
- Hits 4073 3999 -74
- Misses 415 492 +77 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Description
In
r_to_oddsratio()(R/convert_between_d_to_r.R:138), the group sizesn1andn2are currently passed tod_to_oddsratio()(which absorbs them in...and ignores them) instead of tor_to_d():As a result,
n1andn2are silently ignored by bothr_to_oddsratio()andr_to_logoddsratio(), which always fall back to the equal-group-size approximation (h = 4), breaking round-trip consistency withoddsratio_to_r(..., n1, n2)andd_to_oddsratio(r_to_d(r, n1, n2)).Proposed Changes
R/convert_between_d_to_r.R: passn1andn2tor_to_d(r, n1, n2)insider_to_oddsratio(). Becauser_to_logoddsratio()delegates directly tor_to_oddsratio(r, n1, n2, log = log), both functions are fixed.tests/testthat/test-convert_between.R: add regression tests verifyingr_to_oddsratio()andr_to_logoddsratio()with unequaln1/n2, single-argumentn1/n2, and round-trip consistency withoddsratio_to_r().Minimal Reproducible Example
main):r_to_oddsratio(0.5, n1 = 10, n2 = 40):8.120527(identical tor_to_oddsratio(0.5))r_to_logoddsratio(0.5, n1 = 10, n2 = 40):2.094395r_to_oddsratio(0.5, n1 = 10, n2 = 40):13.00195(matchesd_to_oddsratio(r_to_d(0.5, 10, 40)))r_to_logoddsratio(0.5, n1 = 10, n2 = 40):2.5651(matchesd_to_logoddsratio(r_to_d(0.5, 10, 40)))Verification
testthat::test_file("tests/testthat/test-convert_between.R"): 68/68 passed (1 CRAN skip).R/convert_between_d_to_r.R): 3 failures intest-convert_between.R; restoringR/convert_between_d_to_r.Rreturns to 68/68 passed.air formatand checked withlintr(0 lints onR/convert_between_d_to_r.R, 0 new lints ontest-convert_between.R).This PR was assisted by Gemini 4 Neon via Antigravity CLI; I have reviewed and verified the change.