Models
The model fitted depends on the paradigm and, for crossover designs, on the custom_model and homogeneity arguments. This page defines each model and the arguments that select it; the computations behind the reported quantities (the confidence interval, the within-subject variability, and the p-values) are covered in Details of Computation. For the underlying statistical theory see the Pumas course on bioequivalence.
All models are fitted on the log-transformed endpoint. The formulas below are written as log(endpoint) ~ … to make the log transformation explicit, but each model is fitted on a column already named endpoint: run_be assumes the endpoint is already on the log scale, and preprocess_be is what applies the natural-log transformation (unless logtransformed = true, in which case the supplied values are taken as already log-transformed). Point estimates and confidence bounds are exponentiated back to the ratio (GMR) scale for reporting.
Models by paradigm
The study_paradigm value appears in small type under each paradigm name (see Study Designs).
| Paradigm | Default model | Effect of custom_model |
|---|---|---|
Parallelparallel_paradigm |
Two-sample t-test: equal variance (homogeneity = true, default) or Welch's unequal-variance test (homogeneity = false). |
Not accepted. |
Pairedpaired_paradigm |
Paired t-test. | Not accepted. |
Non-replicated crossovernon_replicated_crossover_paradigm |
Fixed-effects linear model (subjects fixed). | LinearMixedModel fits a subjects-random mixed model instead (equal-variance only; homogeneity = false is rejected). LinearModel is the default and a no-op. |
Replicated crossoverreplicated_crossover_supports_abe_and_abel_onlyreplicated_crossover_supports_abe_abel_and_rsabe |
Mixed model (subjects random); see below. | LinearModel fits the subjects-fixed model instead (the EMA default; requires homogeneity = true). LinearMixedModel is the default. |
Nonparametricnonparametric_paradigm |
A rank procedure, chosen by the design. | SignedRankTest, and no other value. |
The custom_model argument selects the crossover model (LinearModel vs LinearMixedModel) and, on the nonparametric path, the rank procedure, where SignedRankTest is the only accepted value; it is not accepted on the parallel and paired paths. The nonparametric row is deliberately terse: which rank procedure a design gets, and what SignedRankTest does to it, vary by design and are tabulated per design under Nonparametric paradigm, the last section of this page. The fitted model is reported in the output (see inference_model_type), e.g. "Linear model", "Mixed model with REML (unequal variance)", "T test (equal variance)", or "Cross-sequence rank sum test (normal approximation)".
Model details
This section covers the four paradigms that fit a model. The nonparametric paradigm fits none and is described separately below.
Parallel paradigm
Paradigm parallel_paradigm; the R|T parallel-group design (see Study Designs).
Two independent groups (reference and test), one formulation per subject. A two-sample t-test compares the group log-means: the pooled equal-variance test when homogeneity = true (default), or Welch's unequal-variance test (with Satterthwaite degrees of freedom) when homogeneity = false. The estimate δ̂ is the difference of log-means and exp(δ̂) the GMR. Variability is reported as a single pooled CV when there is one period, or as separate CVᵣ and CVₜ (from the per-formulation within-subject estimates) when subjects are measured over more than one period.
Paired paradigm
Paradigm paired_paradigm; a single-sequence design such as RT or TR (see Study Designs).
A single sequence measured over two periods. The per-subject log-differences (test − reference) are analysed with a one-sample t-test on n − 1 degrees of freedom; exponentiating the mean difference and its interval gives the GMR and its bounds.
Non-replicated crossover paradigm: linear model
Paradigm non_replicated_crossover_paradigm; the non-replicated crossover design RT|TR (the multi-formulation designs RST|… and ADBC|… share this fixed-effects linear model; see Study Designs).
Subjects are treated as fixed effects, nested within sequence:
log(endpoint) ~ formulation + sequence + sequence & id_within_sequence + period(sequence & id_within_sequence is effects-coded; formulation, sequence, and period are dummy-coded). The formulation contrast is the log-GMR, and its confidence interval uses the model's residual degrees of freedom. The within-subject CV is derived from the residual standard deviation.
Replicated crossover paradigm: mixed model
Paradigms replicated_crossover_supports_abe_and_abel_only and replicated_crossover_supports_abe_abel_and_rsabe; the replicate designs RTR|TRT, RRT|RTR|TRR, RTRT|TRTR, the Balaam design RR|RT|TR|TT, and the like (see Study Designs).
Subjects are random effects. With homogeneity = false (the default) a separate within-subject variance is fitted per formulation; with homogeneity = true a single residual variance is pooled across formulations:
# homogeneity = false (separate variances, FDA-preferred)
log(endpoint) ~ formulation + sequence + period +
(formulation + 0 | id) + zerocorr(formulation + 0 | row)
# homogeneity = true (equal variances)
log(endpoint) ~ formulation + sequence + period + (1 | id)Estimation is by REML (pass reml = false for maximum likelihood), and the formulation-contrast degrees of freedom use the Satterthwaite approximation (see Confidence intervals). A replicated design may instead be fitted with the subjects-fixed linear model above by passing custom_model = LinearModel (the EMA default).
How custom_model and homogeneity interact
On replicated designs the StandardBioequivalenceCriterion and FDA criteria default to the separate-variance mixed model, while the EMA criteria default to the subjects-fixed linear model (and to the equal-variance form when a mixed model is requested). A ★ marks the default applied when the argument is left unset (and StandardBioequivalenceCriterion is used when no criterion is passed).
| Design | Criterion | custom_model | homogeneity | Model fitted |
|---|---|---|---|---|
| non-replicate | StandardBioequivalenceCriterion, EMA_NarrowTherapeuticIndex | Linear ★ | true † | Linear |
Mixed | true ★ | Mixed equal var | ||
false | Not allowed | |||
| replicate | StandardBioequivalenceCriterion | Linear | true | Linear |
Mixed ★ | true | Mixed equal var | ||
false ★ | Mixed separate var | |||
FDA_HighlyVariable, FDA_NarrowTherapeuticIndex | Linear | true | Not allowed | |
Mixed ★ | true | Mixed equal var | ||
false ★ | Mixed separate var | |||
EMA_HighlyVariable, EMA_NarrowTherapeuticIndex | Linear ★ | true | Linear | |
Mixed | true ★ | Mixed equal var | ||
false | Mixed separate var |
In the table above, Linear is the subjects-fixed LinearModel and Mixed is the subjects-random LinearMixedModel. † Implied rather than passed: on a non-replicate design with custom_model left unset, passing homogeneity (either value) raises an ArgumentError, since the argument has no effect on the default linear model. Pass it only together with an explicit custom_model. The homogeneity argument selects the residual-variance structure when a mixed model is fitted (true = equal/pooled, false = separate per formulation); on the Linear path it must be true (passing false raises an ArgumentError). Three contrasts are worth noting:
- On a non-replicate design there is one observation per subject and formulation, so the separate-variance mixed model is not identifiable; the default is the
Linearmodel, andhomogeneitymust be left unset unless an explicitcustom_modelis also given (see † above). - The default
homogeneitydepends on the criterion:false(separate variance) forStandardBioequivalenceCriterionand the FDA criteria,true(equal variance) for the EMA criteria, which in any case default toLinear. - The subjects-fixed
Linearmodel is available underStandardBioequivalenceCriterionand the EMA criteria, but is rejected by the FDA criteria (which require a mixed model).
Both LinearModel and LinearMixedModel are re-exported for convenience, so they can be passed to custom_model without an extra import.
In the EMA Q&A terminology, the three model choices in the table above broadly correspond to the EMA's "Method A", "Method B", and "Method C":
- Method A: the subjects-fixed linear model (
custom_model = LinearModel; the Linear rows); - Method B: the equal-variance mixed model (
custom_model = LinearMixedModel,homogeneity = true; the Mixed equal var rows); - Method C: the separate-variance mixed model (
custom_model = LinearMixedModel,homogeneity = false; the Mixed separate var rows).
The correspondence is only approximate: the exact model specifications (contrasts, variance structure, and degrees-of-freedom handling) differ in subtle ways from the EMA's definitions, so these are a guide to intent rather than an exact match.
Nonparametric paradigm
Paradigm nonparametric_paradigm; every two-formulation design listed below (see Study Designs), selected for endpoints such as Tmax.
The nonparametric paradigm is selected for endpoints such as Tmax, or explicitly with nonparametric = true. It exists because Tmax is not really measured: it is read off the finite list of sampling times, so its distribution sits on the sampling grid however many subjects are enrolled. A log transformation relocates those mass points but does not reduce their number, so the log-normal model behind the other paradigms does not apply and a rank-based argument replaces it.
Replicates are collapsed first: for each subject the log endpoint is averaged across that subject's observed replicates of each formulation, a per-subject geometric mean, giving one reference value and one test value per subject. A replicate lost to a missing observation drops out of that average rather than taking the subject with it, so a subject with one surviving replicate of a formulation still supplies a value for it.
The two procedures, and what to call them. Everything below is built from just two rank procedures, and each is known by more than one name, so the vocabulary is fixed first. The rank sum test compares two independent groups by ranking the pooled observations. The Wilcoxon rank sum test and the Mann–Whitney U test are this same test under two names: their statistics differ only by a constant fixed by the group sizes, so they give identical p-values. The signed rank test takes a single sample of within-subject differences and tests symmetry about zero by ranking their absolute values; this is the Wilcoxon signed rank test. These pages use the descriptive names, "rank sum" and "signed rank", because those are the names the Model line of the output prints. The one place a proper name survives is custom_model = SignedRankTest, which is the value the keyword takes.
The organizing question is then not whether the data are paired but whether the period effect can be eliminated, and the answer selects the procedure:
| Situation | Procedure | What it estimates |
|---|---|---|
| No subject receives both formulations | rank sum on the two formulation groups | the formulation shift; with no subject seen under both, there is no within-subject difference for a period effect to enter |
| Subjects receive both across a mirror pair of sequences | cross-sequence rank sum on the within-subject differences, one subject from each sequence, halved | the formulation contrast, with the period effect canceled |
| Subjects receive both within a single sequence | pooled signed rank on the within-subject differences | the formulation contrast displaced by the period contrast, which the design cannot separate from it |
Every design, and what custom_model does to it
The paradigm accepts every two-formulation design the package detects, with one exception, and refuses everything else with an ArgumentError saying so. The middle column is the default; the right-hand column is what custom_model = SignedRankTest changes it to.
| Design | Default | With custom_model = SignedRankTest |
|---|---|---|
R|T (parallel) | rank sum | rejected: no subject supplies a difference, so there is nothing to pool |
RR|TT | rank sum | rejected, for the same reason |
one sequence, RT or TR alone | pooled signed rank | no change; this is already the pooled analysis |
RT|TR | cross-sequence rank sum | pooled signed rank |
RTR|TRT | cross-sequence rank sum | pooled signed rank |
RTT|TRR | cross-sequence rank sum | pooled signed rank |
RRTT|TTRR | cross-sequence rank sum | pooled signed rank |
RTTR|TRRT | cross-sequence rank sum | pooled signed rank |
RTRT|TRTR | cross-sequence rank sum | pooled signed rank |
RTR|TRR | raises: the two period contrasts do not sum to zero, so nothing cancels between the sequences | pooled signed rank |
RRT|RTR|TRR (partial replicate) | raises: cancels only over triples of sequences, for which no standard distribution-free interval exists | pooled signed rank |
RRTT|RTTR|TRRT|TTRR | raises: two mirror pairs carrying different period contrasts, and how to combine two intervals is a specification decision | pooled signed rank |
RTRT|RTTR|TRRT|TRTR | raises, for the same reason | pooled signed rank |
The first nine rows are the three situations a distribution-free interval follows from: each subject given one formulation throughout, a mirror pair, or a single sequence, where the pooled analysis is the only one available and the period contrast is carried inside it. RT|TR and the single-sequence designs are the only crossovers in the table that replicate nothing; in every other row each subject's repeats of a formulation are averaged on the log scale before any difference is formed.
The last four rows have no usable mirror pair, so no distribution-free interval follows and the default raises rather than returning a contaminated estimate. That is a refusal of the default only. Every subject in these designs receives both formulations, so the pooled analysis is well defined and rests on the same subjects the medians do; custom_model = SignedRankTest reaches it, and the error message names that option. What it then returns is displaced by the period contrast unless that contrast is nil, which is the same assumption the mirror-pair rows make when SignedRankTest is passed.
The designs the paradigm does not accept at all, where custom_model changes nothing:
| Design | Why it is not accepted |
|---|---|
RR|RT|TR|TT (Balaam) | its RT and TR subjects do form a mirror pair, but its RR and TT subjects supply no within-subject difference, so an estimate would rest on part of the study while the medians printed beside it rest on all of it. A block whose two halves describe different subjects is worse than no block |
The multi-formulation designs RST|… and ADBC|…, and anything else with more than two formulations | each pairwise comparison would draw a difference from every sequence, which the two-sequence construction has no reading of, and the block renders a single comparison |
The difference between this table and the rows above it is worth being explicit about. A design with no usable mirror pair still supports the pooled analysis, and that analysis reaches every subject the medians reach, so the refusal is of the default and custom_model lifts it. The designs in this table support nothing coherent, so there is no analysis to opt into and custom_model is not consulted. Their parametric analysis remains available with nonparametric = false, and the error message says so: an endpoint named Tmax selects this paradigm by default, so the caller may not have asked for a rank procedure at all.
custom_model = SignedRankTest is separately rejected in two more places: on the parallel routes above, where no within-subject difference exists to pool, and on any parametric paradigm, since it names a rank procedure and nonparametric = true is what selects one.
Two sequences form a mirror pair when one is the formulation-complement of the other period by period: wherever one administers the reference the other administers the test. The period contrast entering a subject's within-subject difference is then equal and opposite in the two sequences, so a contrast formed from one subject of each cancels it exactly. The two-sequence designs in standard use (RT|TR, RTR|TRT, RTT|TRR, RRTT|TTRR, RTTR|TRRT, RTRT|TRTR) all satisfy this.
Why the cross-sequence construction is the default. Pooling every within-subject difference and testing it, which is what a signed rank test on a crossover design does, does not remove the period effect. Writing π for the period contrast, a subject in RT receives the test formulation in the later period and one in TR in the earlier one, so the two sequence groups' differences are centered at δ + π and δ − π. The pooled sample is therefore a mixture of two populations separated by 2π: displaced away from δ under unbalanced allocation, and more dispersed than a clean sample under any allocation. Koch's construction[koch] takes the median over only those pairwise contrasts built from one subject of each sequence, which are free of π, and the rank sum machinery computes exactly that.
The construction needs a subject in each of the two sequences, so a mirror-pair design can still fail to admit it. A subject observed under one formulation only, through a dropped period or a missing observation, supplies no within-subject difference and drops out of the comparison, though not out of the medians, which are descriptive and computed over every subject contributing the formulation they summarize. If that leaves one of the two sequences with no subject at all, the period contrast has nothing to cancel against, and the analysis raises an ArgumentError rather than pooling silently, even though the two sequences do mirror. If it leaves no complete subject at all, both formulations observed but never on the same subject, the study is refused outright: it has not thereby become a parallel study, since its two formulation groups are confounded with period, and neither within-subject procedure has a difference to work with. The converse holds too: a design with more than two sequences is refused from its design, not from its data, so a four-sequence replicate that missing data has reduced to one contributing mirror pair still refuses. The sequences the study contains decide the procedure; which subjects are complete decides only whether that procedure can run. A subject with one observed period still counts toward their sequence, so the design is read correctly through ordinary dropouts; only a sequence with no observed value of the endpoint at all goes unseen, as it does in every paradigm. Size is the other thing the data decide: a rank interval is a pair of order statistics, so a sample with too few pairwise contrasts cannot reach the requested level at all, and every route refuses such a sample with an ArgumentError naming the coverage it could reach; the thresholds are under Confidence intervals.
Choosing the pooled analysis. Passing custom_model = SignedRankTest forces the pooled signed rank analysis on a design that would otherwise use the cross-sequence construction. It estimates the same quantity only if the period effect is nil, and that is an assumption about the protocol (an adequate washout, or an endpoint with no plausible period drift) rather than something the data can be asked to support: the quantity that would settle it is the between-sequence contrast, which the cross-sequence construction consumes in order to remove it. It is therefore reached by naming it, and the choice is recorded in the Model line of the output. In a single-sequence design the same assumption is imposed by the design itself, silently, and no procedure can avoid it.
Exact or approximate. Both procedures have an exact null distribution and a normal approximation, and each chooses between them from the sample it is given, by size first and ties second. The signed rank procedure is exact at up to 15 non-zero differences whatever the ties, and from 16 to 50 only when there are none; the rank sum procedure is exact at up to 10 observations across the two groups combined whatever the ties, and from 11 to 50 only when there are none. Above those sizes, or with ties inside the tie-sensitive range, the normal approximation is used with the tie-corrected variance. The thresholds are stated precisely, with what counts as a tie in each case, under Exact or approximate. So a tied endpoint such as Tmax does not force the approximation: a pooled signed rank on up to 15 non-zero differences, or a rank sum on up to 10 subjects, reports (exact) however tied the sample is. Which was used is stated in parentheses on the Model line, because the two invert different null distributions.
What is reported. The ranks are formed on the log scale, as everywhere else in the package, and the results are presented on the ratio scale. The point estimate is labelled Median Ratio (%): it is exp of the Hodges–Lehmann estimate, and it is the quantity the interval beside it inverts. Which set of pairs that median runs over depends on the procedure, and the three differ. On the cross-sequence route it is the median of the geometric means of one subject's ratio with another's taken across the two sequences only, and that restriction to cross-sequence pairs is exactly what cancels the period effect; the pooled signed rank instead takes the median over every pair, each subject included with itself; and on the parallel route no subject has a ratio of its own, so it is the median of Tᵢ/Rⱼ between different subjects. It is the rank analogue of the geometric mean ratio, and deliberately not called one, being a different number from the GMR, from the ratio of the two medians printed above it, and from the median of the individual subject ratios. Those two medians are descriptive summaries in the endpoint's own units: ordinary medians over the per-subject values, replicates collapsed as above, and not a back-transformed log-scale median. The ratio of the two medians is deliberately not printed: the Hodges–Lehmann estimate is a median of pairwise contrasts, whereas a ratio of medians is a contrast of medians, and showing both would suggest an additivity that does not hold.
Every supported design has exactly two formulations, so a nonparametric output always holds a single comparison.
- kochKoch, G. G. (1972). The Use of Non-Parametric Methods in the Statistical Analysis of the Two-Period Change-Over Design. Biometrics, 28(2), 577–584. 10.2307/2556170.