Skip to content

Take times without a unit to be hours when detecting the dosing interval - #667

Merged
billdenney merged 3 commits into
mainfrom
feat/intervals-unit-aware
Oct 7, 2026
Merged

billdenney merged 3 commits into
mainfrom
feat/intervals-unit-aware

Conversation

@billdenney

@billdenney billdenney commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Without a time unit, find.tau(), find.dose.regimen(), choose.auc.intervals(), PKNCAdata() and pk.nca() now match the dosing interval to the built-in nominal intervals in hours, the same assumption PKNCA already makes for date-times. find.tau(c(0, 24, 50)) is 24 (once daily) rather than the median spacing of 25.
  • A stated timeu overrides the assumption. A stated unit that cannot be converted to hours still leaves the interval to the dose times. timeu = NA says so explicitly.

Behaviour changes

  • Unitless dose times recorded a little early or late give the nominal interval (24 rather than 24.5 h). That moves the interval generated for the last dose and multiple-dose parameters such as mrt.md.obs.
  • Unitless data whose interval matches no nominal interval in hours, such as data recorded in minutes or days without saying so, or dosing every hour, now give pknca_warning_tau_not_nominal. State timeu in PKNCAconc() to avoid it.

Tests

  • Tests that pinned data-derived medians without a unit now expect the snapped values, with the data-derived values pinned under timeu = NA. Tests of times in days, minutes or abstract units assert the new warning or pass timeu = NA.
  • The full suite passes, and R CMD check gives 0 errors and 0 warnings.

🤖 Generated with Claude Code

billdenney and others added 3 commits October 6, 2026 19:27
With no time unit, find.dose.regimen() and so find.tau(),
choose.auc.intervals(), PKNCAdata() and pk.nca() now match the dosing
interval to the built-in nominal set in hours, the same assumption PKNCA
already makes for date-times:  find.tau(c(0, 24, 50)) is 24 rather than
the median spacing of 25.  A stated unit overrides the assumption.

timeu = NA now says that a unit is stated but cannot be used, which
leaves the interval to the data as an unusable unit did before.
pknca_group_timeu() returns NULL for no unit (hours) and NA for several
units in a group or a unit that cannot be converted, so an arbitrary
unit label in PKNCAconc() still gives the data-derived interval.  The
date-time flag is no longer needed and is removed.

Tests that pinned data-derived medians without a unit now expect the
snapped values (24 and 121.5 rather than 24.5 and 122), with the
data-derived values pinned under timeu = NA or an unusable unit.  Tests
of times in days, minutes, or abstract units now assert the not-nominal
warning, or pass timeu = NA where the units are abstract.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@billdenney billdenney changed the title Feat/intervals unit aware Take times without a unit to be hours when detecting the dosing interval Oct 7, 2026
@billdenney
billdenney merged commit efc5971 into main Oct 7, 2026
9 checks passed
@billdenney
billdenney deleted the feat/intervals-unit-aware branch October 7, 2026 00:52
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