Skip to content

Add predictive_ipred to collected TDMs#40

Merged
roninsightrx merged 3 commits intomainfrom
pred-calcs
Mar 26, 2026
Merged

Add predictive_ipred to collected TDMs#40
roninsightrx merged 3 commits intomainfrom
pred-calcs

Conversation

@roninsightrx
Copy link
Copy Markdown
Contributor

@roninsightrx roninsightrx commented Mar 26, 2026

Summary

  • Adds predictive_ipred column to TDM data frames: simulates a prediction from the estimation model using the current parameter estimates (population prior on dose 1, MAP estimates on subsequent doses) and stores it alongside the observed TDMs — enabling post-hoc predictive performance analysis without changing existing behaviour.
  • also adds claude.md file

Test plan

  • New tests in test-collect_tdms.R: predictive_ipred is NA when no est_model supplied; numeric and equal to true_y when same model/params used for both sim and est.
  • New tests in test-sample_and_adjust.R: predictive_ipred is populated across multiple dose adjustments (exercises the rbind fix); is NA when est_design is not supplied.
  • All pre-existing tests continue to pass.

Simulates a prediction from the estimation model using current parameters
(population prior on dose 1, MAP estimates thereafter) and stores it as
`predictive_ipred` in the TDM data frame. This supports post-hoc predictive
analysis without changing any existing behaviour.

Fixes a bug where `tdms_i` was initialised without the `predictive_ipred`
column, causing `rbind` to fail on the first accumulation step.

Renames the new `est_model_design` parameter to `est_design` to avoid R's
partial-argument-matching silently binding `est_model` (a `...` argument) to
the formal parameter instead of forwarding it to the dose optimisation method.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a predictive_ipred column to collected TDM data so predictive performance can be assessed post-hoc by simulating an individual prediction from the estimation model/parameters alongside observed TDMs.

Changes:

  • Extend collect_tdms() to optionally simulate and return predictive_ipred (or NA when not requested).
  • Plumb estimation design info through sim_subject()sample_and_adjust_by_dose() so TDM collection can compute predictive_ipred during iterative dose adjustment.
  • Add/extend tests to assert presence and expected population/NA behavior of predictive_ipred.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
R/collect_tdms.R Adds optional estimation-model simulation and appends predictive_ipred to the returned TDM data frame.
R/sample_and_adjust.R Initializes TDM accumulator with predictive_ipred and forwards estimation model/parameters into collect_tdms().
R/sim_subject.R Passes design$est into sample_and_adjust_by_dose() via new est_design arg.
tests/testthat/test-collect_tdms.R Updates expectations and adds tests for NA vs populated predictive_ipred.
tests/testthat/test-sample_and_adjust.R Adds integration tests for predictive_ipred across dose adjustments and when est_design is absent.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

roninsightrx and others added 2 commits March 26, 2026 09:26
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@roninsightrx roninsightrx requested a review from jasmineirx March 26, 2026 16:31
Copy link
Copy Markdown
Collaborator

@jasmineirx jasmineirx left a comment

Choose a reason for hiding this comment

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

lgtm

@roninsightrx roninsightrx merged commit 41b7036 into main Mar 26, 2026
3 checks passed
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