Skip to content

Classify the bioequivalence design from the study rows, not from every endpoint's rows together - #718

Open
billdenney wants to merge 15 commits into
fix/no-tau-warning-groupfrom
fix/be-design-per-endpoint
Open

billdenney wants to merge 15 commits into
fix/no-tau-warning-groupfrom
fix/be-design-per-endpoint

Conversation

@billdenney

Copy link
Copy Markdown
Member

be_fit_models() (and so be_assess() and be_compare()) passed the rows of every endpoint to be_design(). Long NCA results hold one row per subject, period, and endpoint, so with several PPTESTCD values each subject had several rows per period:

  • a 2x2 crossover with Cmax and AUC rows was classified as "full_replicate", so reference scaling (EMA, FDA) looked feasible and failed later with a not-estimable error instead of the infeasible-design error;
  • a parallel study with two endpoints looked like repeated measures, and the lmer fit failed with "number of levels of each grouping factor must be < number of observations".

be_design() and be_within_var() called directly on such data read the endpoint rows as replicated administrations in the same way.

Fix

  • be_dataset() keeps design_rows: the distinct subject/sequence/period/treatment rows of the requested endpoints, including administrations whose value is missing, so missing values (such as an inestimable AUCinf) do not change the design. be_fit_models() classifies the study once from them. A design given by the user is still used as given.
  • be_dataset() stops with pknca_error_be_dataset_duplicate_period when an endpoint has more than one value for a subject and period (several intervals for one endpoint), and with pknca_error_be_dataset_design_conflict when endpoints disagree on a subject's treatment or sequence. Because be_compare() calls be_dataset() first, these are raised once rather than swallowed per framework.
  • An endpoint that cannot support the design (for example, missing for a whole period of a 2x2) stops with pknca_error_be_endpoint_not_repeated naming it, instead of the lme4 error.
  • be_design() and be_within_var() stop when a subject has more than one row in a period.
  • be_dataset() checks covariates for missing values only in the rows of the requested endpoints.

Tests

  • A 2x2 crossover with two endpoints gives "2x2x2", the same result as one endpoint's data, and EMA gives pknca_error_be_infeasible_design.
  • A parallel study with two endpoints gives "parallel"/"anova", the same result as one endpoint's data.
  • A full replicate with aucinf.obs missing in 55 of 96 rows stays "full_replicate", and its result equals that endpoint assessed alone.
  • A 2x2 with Cmax missing in period 2: the design is "2x2x2", and including Cmax gives the new error.
  • The duplicate-period and design-conflict errors through be_assess() and be_compare(), with exact messages; the be_design()/be_within_var() guards.

Stacked on fix/no-tau-warning-group; this PR's diff is only this fix.

🤖 Generated with Claude Code

billdenney and others added 15 commits November 9, 2026 18:42
be_fit_models() passed the rows of every endpoint to be_design(), so long
data with several PPTESTCD values had several rows per subject and period: a
2x2 crossover with Cmax and AUC read as a full replicate (making the EMA and
FDA frameworks look feasible), and a parallel study with two endpoints read as
repeated measures, so lme4 refused the per-endpoint mixed model.

The design is now classified from each endpoint's rows, and endpoints whose
designs differ stop with pknca_error_be_design_endpoints_differ.  be_design()
and be_within_var(), which take one endpoint's rows, stop when a subject has
more than one row in a period instead of reading the rows as replicates.  The
covariate-missing check of be_dataset() looks only at the rows of the
requested endpoints, like its design-column check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… values

Review of the per-endpoint classification: classifying each endpoint after
the missing values were dropped let routine missingness (aucinf.obs without
an estimable lambda.z) change one endpoint's design and stop a valid
assessment.  be_dataset() now keeps design_rows, the distinct subject,
sequence, period, and treatment rows of the requested endpoints, including
administrations whose value is missing, and be_fit_models() classifies the
study from them.

be_dataset() stops with pknca_error_be_dataset_duplicate_period when an
endpoint has more than one value for a subject and period (results with
several intervals), saying to filter to one interval, and with
pknca_error_be_dataset_design_conflict when endpoints disagree on a
subject's treatment or sequence in a period.  be_compare() calls
be_dataset() before its per-framework loop, so both are raised once there
rather than as skipped frameworks.  An endpoint left with one value per
subject stops lmer and nlme with pknca_error_be_endpoint_not_repeated
instead of an lme4 error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@billdenney
billdenney added this pull request to stack #717 November 13, 2026 18:08

This branch has not been deployed

No deployments
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