Fix get_cox_pairwise_df returning NA hazard ratios when arm has >2 levels#194
Open
Fix get_cox_pairwise_df returning NA hazard ratios when arm has >2 levels#194
Conversation
…add tests Co-authored-by: shajoezhu <3692541+shajoezhu@users.noreply.github.com> Agent-Logs-Url: https://github.com/insightsengineering/crane/sessions/f62410af-870a-4f1e-91f2-a62bbb90e321
Copilot
AI
changed the title
[WIP] Fix get_cox_pairwise_df to handle multiple levels in by variable
Fix get_cox_pairwise_df returning NA hazard ratios when arm has >2 levels
Mar 24, 2026
Contributor
Unit Tests Summary 1 files 144 suites 2m 24s ⏱️ Results for commit 4226e72. ♻️ This comment has been updated with latest results. |
Contributor
Code Coverage SummaryDiff against mainResults for commit: 4226e72 Minimum allowed coverage is ♻️ This comment has been updated with latest results |
Contributor
Unit Test Performance Difference
Additional test case details
Results for commit fd018ee ♻️ This comment has been updated with latest results. |
Contributor
|
@jszczypinski as you are working on this next, could you take a look and merge or replace this? Thanks :) |
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.
get_cox_pairwise_dfalways reads row1fromcoxph_ans$conf.int, but when the arm factor has >2 levels, subsetting the data doesn't drop unused factor levels — soconf.intstill contains a row per non-reference level (withNAfor absent ones). Only the first comparison returns valid results; all subsequent ones returnNA.Fix
Replace the hard-coded row index
1withpaste0(arm, current_arm), matching R's factor dummy variable naming convention:Tests
Added
test-get_cox_pairwise_df.Rcovering:NAHR and CI for all comparisons (the regression case)ref_groupfalls back to first factor levelOriginal prompt
📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.