Skip to content

Fix best-metric highlighting for LL/AIC/BIC and add "always" to update_check options#311

Draft
Copilot wants to merge 62 commits intoMichaelfrom
copilot/sub-pr-309-again
Draft

Fix best-metric highlighting for LL/AIC/BIC and add "always" to update_check options#311
Copilot wants to merge 62 commits intoMichaelfrom
copilot/sub-pr-309-again

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 26, 2026

Three bugs from the ab132e5 review: LL/AIC/BIC "best" detection used closest-to-0 instead of minimum, and "always" was a supported update_check value that couldn't be persisted through the UI.

Changes

  • R/PM_compare.R + R/PMutilities.R — Replace single-target heuristic with three-way logic:

    • LL$|AIC$|BIC$min(x) (smallest is best)
    • Sl|R2 → closest to 1
    • everything else (bias, imprecision, intercepts) → closest to 0
    # Before: all non-slope/R2 defaulted to closest-to-0, mis-ranking LL/AIC/BIC
    target <- ifelse(grepl("Sl|R2", col), 1, 0)
    valid[which(abs(x[valid] - target) == min(abs(x[valid] - target)))]
    
    # After
    if (grepl("LL$|AIC$|BIC$", col, ignore.case = TRUE)) {
      valid[which(x[valid] == min(x[valid]))]
    } else if (grepl("Sl|R2", col)) {
      diffs <- abs(x[valid] - 1); valid[which(diffs == min(diffs))]
    } else {
      diffs <- abs(x[valid]); valid[which(diffs == min(diffs))]
    }
  • R/PMoptions.R — Add "always" to the validation allowlist and to the Shiny UI selectInput choices, so it can round-trip through the options UI (it was already handled by pm_update_interval_days() but silently replaced with "weekly" on save).


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Siel and others added 30 commits February 12, 2026 09:03
Add BestDose dose optimization feature ported from Pmetrics_rust bestdose branch:

- R/PM_bestdose.R: PM_bestdose and PM_bestdose_problem R6 classes for
  Bayesian dose optimization with support for concentration and AUC targets
- src/rust/src/bestdose_executor.rs: Rust backend for BestDose optimization
  using pmcore's BestDoseProblem with ODE model support
- Updated lib.rs with bestdose, bestdose_prepare, bestdose_optimize exports
- Updated extendr-wrappers.R with R-side wrapper functions
- Updated NAMESPACE with PM_bestdose, PM_bestdose_problem, bestdose exports
- Bumped pmcore dependency from 0.21.1 to 0.22.1 (required for bestdose)
- Added libloading dependency for dynamic model loading
- Added bestdose example data (past, prior, target CSVs) and test script
- Fixed executor.rs mutability issue for pmcore 0.22.1 compatibility
Reworked bd and bd_post R6 classes: bd_post$optimize() now returns a bd
object, and bd$new() supports one-shot usage. Removed dead Rust code
(bestdose(), bestdose_ode(), bestdose_analytical()). Fixed bias_weight
being NULL and print() breaking with variable dose counts. Updated PMcore
dep to use relative time_offset gap semantics.
- Combine clean one-shot/two-stage API with inline future=list(...) support
- Add top-5 weighted plot curves, triangle dose indicators, plot() method
- Fix .sim_future() dose recycling when past doses are present
…sed most of the logs for bestdose, needs more work
Copilot AI changed the title [WIP] Update bug fixes and feature enhancements Fix best-metric highlighting for LL/AIC/BIC and add "always" to update_check options Mar 26, 2026
Copilot AI requested a review from mnneely March 26, 2026 14:36
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.

3 participants