Skip to content

Ordered fix - #142

Open
xrobin wants to merge 9 commits into
developfrom
ordered_fix
Open

Ordered fix#142
xrobin wants to merge 9 commits into
developfrom
ordered_fix

Conversation

@xrobin

@xrobin xrobin commented Aug 31, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes #63. Ordered predictors such as aSAH$wfns are no longer coerced to
numeric codes. Thresholds are the factor levels plus an Inf sentinel
("Inf" or "-Inf" depending on direction), and lookup is by label.
This is a breaking change for code that reads roc$thresholds or
passes numeric cut-offs into coords(), ci.thresholds(), ci.coords(),
or plot.roc(print.thres) on an ordered ROC. Sensitivity, specificity,
and AUC match the old numeric conversion; only the cut-off labels change.

# Before (pROC ≤ 1.19.1): named levels became 1:5, thresholds were midpoints
coords(roc(aSAH$outcome, aSAH$wfns), 2.5)
# After: pass the level
coords(roc(aSAH$outcome, aSAH$wfns, quiet = TRUE), "3")

Numeric predictors are unchanged (midpoints, coords(roc, 0.55), etc.).
Also fixes ci.coords(..., x = "best", best.policy = "omit"), which
returned the first column of the coords data.frame instead of dropping
the replicate. That bug was not ordered-specific.

Behavior

  • An observation equal to the threshold is classified as positive
    (>= when direction = "<", <= when direction = ">").
  • direction = "<": thresholds are c(levels, Inf); ">": c(-Inf, levels).
  • Unused defined levels are kept as thresholds (they share SE/SP with the
    next occupied level toward the positive class).
  • cases and controls must have identical levels(). Ordered
    cases/controls now build predictor/response in the same order
    (controls then cases), which fixes non-stratified bootstrap and
    Venkatraman on that interface.
  • ci.coords() omits the threshold interval by default on ordered curves
    (labels are not numeric). ret = "threshold" is still accepted, returns
    NA, and warns.
  • Exact level labels take precedence over keyword prefixes ("a" vs "all").
    If a string is both a keyword and a level, the keyword wins with a warning.
  • Smoothing of ordered curves is binormal only.

Test plan

  • roc(aSAH$outcome, aSAH$wfns) thresholds are ordered levels + Inf,
    not midpoints; AUC equals roc(..., as.numeric(wfns)).
  • Named levels ("very low""very high") round-trip through
    coords(), ci.thresholds(), ci.coords(), plot(print.thres).
  • Numeric x / print.thres / thresholds on an ordered ROC errors.
  • Numeric ROC (ndka, s100b) still uses midpoints; coords(r, 0.55)
    and plot(r, print.thres = 0.55) unchanged.
  • ci.coords(r_tie, "best", best.policy = "omit") on a curve with
    several Youden points drops those replicates (row of NAs) instead
    of returning the threshold column.
  • devtools::test() / R CMD check
  • Run reverse dependency checks and report summary/results.

Post-test communication

  • Publish a blog post outlining user-facing ordered-threshold changes.
  • Prepare and send an email to maintainers of reverse dependencies with migration guidance.

@codecov

codecov Bot commented Aug 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.45299% with 30 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.52%. Comparing base (d7b1962) to head (087dfaf).

Files with missing lines Patch % Lines
R/roc.utils.R 84.50% 20 Missing ⚠️
R/coords.R 97.25% 3 Missing ⚠️
R/ci.coords.R 90.00% 2 Missing ⚠️
R/ci.thresholds.R 87.50% 2 Missing ⚠️
R/obuchowski.R 50.00% 2 Missing ⚠️
R/roc.R 94.74% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #142      +/-   ##
===========================================
+ Coverage    87.36%   87.52%   +0.16%     
===========================================
  Files           40       40              
  Lines         4146     4312     +166     
===========================================
+ Hits          3622     3774     +152     
- Misses         524      538      +14     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant