Optimal Two-Stage Designs for Ordered Categorical Outcomes
Overview
Functions to design and simulate optimal two-stage randomized controlled trials (RCTs) with ordered categorical outcomes, using rank-based tests and interim decision rules for futility and superiority, following Park (2025) doi:10.1371/journal.pone.0318211. The functions 'rule()', 'op()' and 'design_table()' provide a single entry point for constructing designs, evaluating their operating characteristics, and tabulating several designs at once. The separate functions provided for each combination of test statistic and stopping rule up to version 1.0.2 were deprecated in 1.0.3 and are removed here. Please see the package reference manual and the vignette for details.
Interface
The many separate design and simulation functions are replaced by two entry
points, in response to the referee reports on the accompanying article.
rule()constructs a decision rule. The test statistic (test), the monitoring scheme (stopping) and the optimality criterion (criterion) are arguments.op()evaluates a design by simulation, taking the object returned byrule()and reporting both hypotheses in a single call.design_table()sweeps a set of tests and criteria and returns a data frame.
Both return classed objects with named components and print() methods, so
the output no longer has to be indexed by position.
Removed
Show all changes in 1.1.0Hide the rest of the changes in 1.1.0
The functions below were deprecated in 1.0.3, which warned on every call, and
are removed here. If a script written for 1.0.2 stops working, the replacement is listed below.
ruleF()andruleFS()becomerule(..., stopping = "F")andrule(..., stopping = "FS").Decision_rule_S.F(),Decision_rule_M.F()andDecision_rule_W.F()becomerule(..., test = "S"/"M"/"W", stopping = "F").Decision_rule_S.FS(),Decision_rule_M.FS()andDecision_rule_W.FS()becomerule(..., test = "S"/"M"/"W", stopping = "FS").Decision_rule_S_1stage(),Decision_rule_M_1stage()andDecision_rule_W_1stage()becomerule(..., test = "S"/"M"/"W", stopping = "none").op.F(),op.FS()andop.1stage()becomeop(design, nsim, seed), wheredesignis the object returned byrule().
The helpers p_plus(), p_minus() and pq_fun() are no longer exported.
They are intermediate quantities inside the variance calculations rather than
part of the interface, and they are still used internally.
V_S.over.nk(), QR_fun() and W_W() remain exported and are now documented
with examples. They give the asymptotic variance of the score,
Mann-Whitney-Wilcoxon and win odds statistics, the quantities defined in the
appendix of the accompanying article, and they let a threshold be computed at a
sample size of the user's choosing rather than at the optimal one.
Designs and operating characteristics are unchanged: the new interface
reproduces every value the old one produced, and the package test suite checks
this against the tables published in the article.
Fixed
design_table()andprint()on an operating-characteristic object now round the expected sample sizes the same way.EN0,ENaandENare each shown to two decimal places, rounded once from the value actually simulated;ENis no longer recomputed from the already-roundedEN0andENa, which madedesign_table()print a third decimal thatop()did not. Because each column is rounded independently,(EN0 + ENa)/2taken from the printed columns can differ from the printedENby up to 0.01.- The printed operating-characteristic summary no longer reports a Monte Carlo standard error keyed to a nominal level of 0.05, which was wrong for any other choice of
alpha. The table already gives the standard error of each rejection probability, computed from that probability. - The FS design's continuation probability under the alternative,
beta3 = Pr(T1 <= t1s | Ha), was computed for the score test without the factorn1in the mean of the statistic. The score statistic has meantheta * V * n, unlike the rank-based statistics, whose means do not scale with the sample size, so the omission made the value far too large (0.98 against a true 0.45 in the article's Example 1 configuration). This entered the expected sample size under the alternative and therefore the objective of criteria 2, 3 and 5, sorule(..., test = "S", stopping = "FS")could return a design that did not minimise what it was asked to minimise. The Mann-Whitney-Wilcoxon and win odds expressions were already correct, and the F design does not use this quantity, so neither table in the accompanying article is affected. The internal variable is now namedbeta3, matching the article's notation, rather thanbeta2, which denotesbeta - beta1in the F design.
New
- Input validation on all exported functions:
p1andp2are checked for numeric type, equal length, at least two categories, absence of missing values, non-negativity, and summation to one within1e-6. Proportional_odds_assumption()explains itself and warns instead of returning a bareNA.rule()detects a degenerate optimum, warns, and by default substitutes the single-stage design; controlled byon_degenerate.op()reports futility and superiority stopping probabilities separately, with Monte Carlo standard errors on the rejection probabilities, and refuses to simulate an unsubstituted degenerate design unlessallow_degenerate.- Decision boundaries are reported on an interpretable effect-size scale, the odds ratio for the score test and the win odds for the rank-based tests.
- A vignette, "Designing two-stage trials with ordered categorical outcomes".
- An automated test suite under
tests/testthat.
From NEWS.md in the release
Install
Health
- OK13 OK2026-09-08
- ERROR12 OK, 1 ERROR2026-09-07
- OK13 OK2026-08-05
- NOTE12 OK, 1 NOTE2026-08-01
- OK14 OK2026-03-10
Documentation
- Help pages
- 10includes a package overview page
- Examples that run
- 100%9 run in a plain check
- Exported functions with examples
- 100%
- Documented parameters
- 92%
- Return-value docs
- 100%
- Help pages citing references
- 10%
Downloads
Dependencies
Installing OptOTrials adds no packages beyond those that come with R.
Code & Tests
People & History
Pick two releases to compare their code metrics.
- 1.1.0Latest2026-09-23 · current release · diff ↗ ·
removed 17 exports
ruleF, ruleFS, op.F, op.FS, op.1stage, Decision_rule_S.F, Decision_rule_S.FS, Decision_rule_S_1stage, Decision_rule_M.F, Decision_rule_M.FS, Decision_rule_M_1stage, Decision_rule_W.F, Decision_rule_W.FS, Decision_rule_W_1stage, p_plus, p_minus, pq_fun - 1.0.3
- RR 4.6.0 released · 2026-04-24
- 1.0.22025-09-05
- RR 4.5.0 released · 2025-04-11
Package metadata
- First published
- 2025-09-05
- Total releases
- 3 / 1 yrs
- License
- GPL-3 OSI
- Minimum R
- ≥ 4.0
- Download size
- 46 KB
Cite
Cite this package
Run in R for the authors' preferred citation:
citation("OptOTrials")This package has no citation file, so citation() returns this entry built from DESCRIPTION.
Cite the R Observatory
For a number measured here: a download total, a coverage figure, an archival date.
From data release v2026-10-25, which the citation names so these numbers can be found later. More on citing and the projects behind them.