Skip to main content

Comparing Trial Planning Scenarios with rpact

Planning
Means
Utilities
Compare sample size requirements, power, and expected sample sizes for a blood pressure trial, from a fixed design to group sequential designs with different futility rules.
Author

Friedrich Pahlke

Published

November 23, 2026

Introduction

Planning a clinical trial usually involves more than one sample size calculation. How sensitive is the required sample size to the assumed treatment effect? What happens if the variability is larger than expected? Would an interim analysis reduce the expected number of patients, and how much power could be lost by stopping for futility?

This vignette illustrates how rpact brings these calculations together for design decisions. For a particularly simple, quick comparison, write object1 %vs% object2: the versus operator immediately returns a comparison summary and can be chained to include further objects. |> compare() instead returns a comparison container, starting from a planning object and extending it in a pipeline. Use getComparison() to create a container explicitly, either with named objects supplied directly or initially empty, then add scenarios as they are calculated using |> add().

Use fetch() to retrieve scenarios and delete() to remove them. We first plan a fixed design for a two-group blood pressure trial and validate the selected sample size with getPowerMeans(). We then extend the example to a group sequential design with one interim analysis and compare several futility rules.

The clinical assumptions are illustrative planning scenarios. These examples supplement the rpact help pages; they do not replace a study-specific justification of the effect, variability, and stopping rules.

library(rpact)
library(ggplot2)
packageVersion("rpact")
[1] '5.0.0'

Use an rpact version providing getComparison(), compare(), %vs%, and their associated methods. The package version used to execute this vignette is shown above.

The principle of a comparison

getComparison() collects existing rpact objects: designs, design characteristics, sample size calculations, power calculations, and simulation results. It does not perform another sample size calculation, vary parameters automatically, or choose a preferred design. First calculate the scenarios of interest, then add the resulting objects to the comparison.

Start empty and add named scenarios

To build a comparison incrementally with named scenarios: create it once with getComparison(), then use |> add() whenever another scenario is ready. This works interactively and in loops, without having to assemble all scenarios in a single constructor call. Give scenarios meaningful, unique names so that they remain easy to identify in tables, plot legends, and subsequent selections.

comp <- getComparison()
length(comp)
[1] 0
comp |> add(design1 = getDesignGroupSequential(kMax = 2))

Design comparison

1 objects; 2 comparison rows; 19 columns.

Object types

  • Group sequential design: 1

Observed metrics (across objects, stages and situations)

  • Maximum number of stages: 2
  • Significance level: 0.025
  • Type II error rate: 0.2

Available operations

  • summary(x): Compare differences
  • as.data.frame(x): Access all data
  • plot(x, xAxis = …, yAxis = …): Plot selected parameters
  • getObjects(x): Access contained objects
comp |> add(design2 = getDesignCharacteristics(
    getDesignGroupSequential(kMax = 3)
))

Design comparison

2 objects; 5 comparison rows; 27 columns.

Object types

  • Group sequential design: 1
  • Group sequential design characteristics: 1

Observed metrics (across objects, stages and situations)

  • Maximum number of stages: 2, 3
  • Significance level: 0.025
  • Type II error rate: 0.2

Available operations

  • summary(x): Compare differences
  • as.data.frame(x): Access all data
  • plot(x, xAxis = …, yAxis = …): Plot selected parameters
  • getObjects(x): Access contained objects
names(comp)
[1] "design1" "design2"
length(comp)
[1] 2

The comparison can contain different supported object types, as here. add() appends objects and modifies comp in place, so no reassignment is needed. Names must be unique; adding an existing name raises an error rather than replacing the scenario.

Retrieve an object with fetch(), either by its exact name or its position:

firstDesign <- comp |> fetch("design1")
identical(firstDesign, comp |> fetch(1))
[1] TRUE
selectedObjects <- comp |> fetch(c("design1", "design2"), output = "list")
names(selectedObjects)
[1] "design1" "design2"

A single selection returns the contained object itself. Use output = "list" when a named list is needed, including when selecting only one object.

Scenarios can also be removed as planning evolves. For example, add an exploratory fixed design, then remove it by name:

comp |> add(exploratory = getDesignFixed())

Design comparison

3 objects; 6 comparison rows; 27 columns.

Object types

  • Fixed sample size design: 1
  • Group sequential design: 1
  • Group sequential design characteristics: 1

Observed metrics (across objects, stages and situations)

  • Maximum number of stages: 1, 3
  • Significance level: 0.025
  • Type II error rate: 0.2

Available operations

  • summary(x): Compare differences
  • as.data.frame(x): Access all data
  • plot(x, xAxis = …, yAxis = …): Plot selected parameters
  • getObjects(x): Access contained objects
comp |> delete("exploratory")

Design comparison

2 objects; 5 comparison rows; 27 columns.

Object types

  • Group sequential design: 1
  • Group sequential design characteristics: 1

Observed metrics (across objects, stages and situations)

  • Maximum number of stages: 2, 3
  • Significance level: 0.025
  • Type II error rate: 0.2

Available operations

  • summary(x): Compare differences
  • as.data.frame(x): Access all data
  • plot(x, xAxis = …, yAxis = …): Plot selected parameters
  • getObjects(x): Access contained objects
names(comp)
[1] "design1" "design2"

delete() removes one object per call and also modifies the comparison in place. The original design object is not changed by removing it from the collection.

Add unnamed scenarios and select by index

Names are optional. Inspect names() rather than assuming that a generated plot label is also an object name:

unnamedComp <- getComparison()
unnamedComp |> add(getDesignGroupSequential(kMax = 2))

Design comparison

1 objects; 2 comparison rows; 18 columns.

Object types

  • Group sequential design: 1

Observed metrics (across objects, stages and situations)

  • Maximum number of stages: 2
  • Significance level: 0.025
  • Type II error rate: 0.2

Available operations

  • summary(x): Compare differences
  • as.data.frame(x): Access all data
  • plot(x, xAxis = …, yAxis = …): Plot selected parameters
  • getObjects(x): Access contained objects
unnamedComp |> add(getDesignGroupSequential(kMax = 3))

Design comparison

2 objects; 5 comparison rows; 18 columns.

Object types

  • Group sequential design: 2

Observed metrics (across objects, stages and situations)

  • Maximum number of stages: 2, 3
  • Significance level: 0.025
  • Type II error rate: 0.2

Available operations

  • summary(x): Compare differences
  • as.data.frame(x): Access all data
  • plot(x, xAxis = …, yAxis = …): Plot selected parameters
  • getObjects(x): Access contained objects
names(unnamedComp)
NULL
unique(as.data.frame(unnamedComp)[, c("objectNumber", "objectType")])
  objectNumber                 objectType
1            1 TrialDesignGroupSequential
3            2 TrialDesignGroupSequential
secondDesign <- unnamedComp |> fetch(2)
identical(secondDesign, unnamedComp[[2]])
[1] TRUE
unnamedComp |> delete(1)

Design comparison

1 objects; 3 comparison rows; 18 columns.

Object types

  • Group sequential design: 1

Observed metrics (across objects, stages and situations)

  • Maximum number of stages: 3
  • Significance level: 0.025
  • Type II error rate: 0.2

Available operations

  • summary(x): Compare differences
  • as.data.frame(x): Access all data
  • plot(x, xAxis = …, yAxis = …): Plot selected parameters
  • getObjects(x): Access contained objects
identical(secondDesign, unnamedComp |> fetch(1))
[1] TRUE
length(unnamedComp)
[1] 1

For this fully unnamed comparison, names(unnamedComp) returns NULL: add() does not generate stored names. The exported objectNumber identifies each object by its current position; automatically generated display labels are not names for fetch() or delete(). Use integer indices for unnamed entries. Deleting the first entry shifts the second entry to position 1, so recheck positions after a deletion. Explicit names are preferable when scenarios need stable identifiers.

Compare a few designs directly

When you want to compare just a few designs that can be specified immediately, passing them directly to getComparison() is also useful. This compact form creates a populated comparison in a single call:

smallComparison <- getComparison(
    two_stage = getDesignGroupSequential(kMax = 2),
    three_stage = getDesignGroupSequential(kMax = 3)
)
smallComparison |> print()

Design comparison

2 objects; 5 comparison rows; 19 columns.

Object types

  • Group sequential design: 2

Observed metrics (across objects, stages and situations)

  • Maximum number of stages: 2, 3
  • Significance level: 0.025
  • Type II error rate: 0.2

Available operations

  • summary(x): Compare differences
  • as.data.frame(x): Access all data
  • plot(x, xAxis = …, yAxis = …): Plot selected parameters
  • getObjects(x): Access contained objects

The same two design settings can also be compared by starting directly from the first design and piping it into compare():

pipedComparison <- getDesignGroupSequential(kMax = 2) |>
    compare(getDesignGroupSequential(kMax = 3))
length(pipedComparison)
[1] 2

The first compare(x, y) creates the comparison through getComparison(x, y). Further calls append to that comparison, so a third design fits naturally into the same pipeline:

pipedComparison |>
    compare(getDesignGroupSequential(kMax = 4))

Design comparison

3 objects; 9 comparison rows; 18 columns.

Object types

  • Group sequential design: 3

Observed metrics (across objects, stages and situations)

  • Maximum number of stages: 2, 4
  • Significance level: 0.025
  • Type II error rate: 0.2

Available operations

  • summary(x): Compare differences
  • as.data.frame(x): Access all data
  • plot(x, xAxis = …, yAxis = …): Plot selected parameters
  • getObjects(x): Access contained objects
length(pipedComparison)
[1] 3

When its first argument is already a comparison, compare() calls its $add() method and modifies it in place; no reassignment is needed. These entries are unnamed, so use positions to retrieve them. The pipe form also accepts design characteristics, sample size and power calculations, and simulation results, including mixtures of supported object types.

For a quick sample size comparison, calculate three effect assumptions and pass the result straight to summary() in a single pipeline:

getSampleSizeMeans(alternative = 0.22) |>
    compare(getSampleSizeMeans(alternative = 0.44)) |>
    compare(getSampleSizeMeans(alternative = 0.59)) |>
    summary()

Sample size calculation comparison summary

Comparison of 3 sample size means calculations. Result numbers follow the comparison input order. The comparison identifies 5 differing parameters and 16 shared parameters or profiles. Shared (examples): Object type, Endpoint, Calculation target, Standard deviation, Normal approximation, Mean ratio, … (all shared captions: showAll = TRUE)

Inputs and design settings

Alternatives [3 profiles]

Result 1 Result 2 Result 3
0.22 0.44 0.59

Results and derived parameters

Critical values (treatment effect scale) [3 profiles]

Result 1 Result 2 Result 3
0.1539693 0.3082939 0.4138996

Number of subjects fixed [3 profiles]

Result 1 Result 2 Result 3
650.59405 164.10993 92.15175

Number of subjects fixed (1) [3 profiles]

Result 1 Result 2 Result 3
325.29703 82.05496 46.07588

Number of subjects fixed (2) [3 profiles]

Result 1 Result 2 Result 3
325.29703 82.05496 46.07588

Legend

  • Profiles compare exact values on their applicable coordinates.

Complete display: summary(x, showAll = TRUE). Full data: as.data.frame(x). Exact profiles: summary(x)$parameterInfo.

No intermediate variables or explicit comparison constructor are needed. The summary shows how the required sample size changes across the three effect assumptions while the other planning settings remain the same.

Use |> compare() for a quick comparison starting from an existing planning object, pass named objects directly to getComparison() for a small, self-contained comparison, or start empty and use |> add() when named scenarios are calculated progressively or generated in a loop. All forms create the same kind of comparison object and support fetch(), delete(), and the reporting methods below.

Quick comparisons with the versus operator

For a quick inspection of two planning results, %vs% combines the objects with getComparison() internally and immediately returns their summary. There is no need to create a comparison variable or call summary() explicitly. For example, compare two assumptions about the treatment effect and variability:

sampleSize1 <- getSampleSizeMeans(alternative = 5, stDev = 7)
sampleSize2 <- getSampleSizeMeans(alternative = 6, stDev = 8)
sampleSize1 %vs% sampleSize2

Sample size calculation comparison summary

Comparison of 2 sample size means calculations. Result numbers follow the comparison input order. The comparison identifies 6 differing parameters and 15 shared parameters or profiles. Shared (examples): Object type, Endpoint, Calculation target, Normal approximation, Mean ratio, Treatment groups, … (all shared captions: showAll = TRUE)

Inputs and design settings

Alternatives [2 profiles]

Result 1 Result 2
5 6

Standard deviation [2 profiles]

Result 1 Result 2
7 8

Results and derived parameters

Critical values (treatment effect scale) [2 profiles]

Result 1 Result 2
3.512102 4.216251

Number of subjects fixed [2 profiles]

Result 1 Result 2
63.51430 57.79927

Number of subjects fixed (1) [2 profiles]

Result 1 Result 2
31.75715 28.89964

Number of subjects fixed (2) [2 profiles]

Result 1 Result 2
31.75715 28.89964

Legend

  • Profiles compare exact values on their applicable coordinates.

Complete display: summary(x, showAll = TRUE). Full data: as.data.frame(x). Exact profiles: summary(x)$parameterInfo.

The second scenario assumes both a larger effect and a larger standard deviation. Its standardized effect is nevertheless larger (6 / 8 = 0.75 versus approximately 5 / 7 = 0.71), so it requires fewer patients under the same significance level, power, and allocation settings. The summary puts the changed assumptions alongside the resulting sample sizes. These are joint planning scenarios: the comparison does not isolate the effect of changing variability alone.

Chain three sequential plans and plot the results

The operator can also be chained. Suppose a team considers three plausible combinations of effect and variability for the same two-stage group sequential design. Keeping the design fixed makes it easier to see how these assumptions change recruitment requirements and the efficacy boundaries on the endpoint’s original scale:

design <- getDesignGroupSequential(kMax = 2)
sampleSize1 <- design |> getSampleSizeMeans(alternative = 0.4, stDev = 0.5)
sampleSize2 <- design |> getSampleSizeMeans(alternative = 0.5, stDev = 0.6)
sampleSize3 <- design |> getSampleSizeMeans(alternative = 0.6, stDev = 0.7)

sampleSize1 %vs% sampleSize2 %vs% sampleSize3

Sample size calculation comparison summary

Comparison of 3 sample size means calculations. Result numbers follow the comparison input order. The comparison identifies 10 differing parameters and 23 shared parameters or profiles. Shared (examples): Object type, Endpoint, Calculation target, Maximum number of stages, Information rates, Normal approximation, … (all shared captions: showAll = TRUE)

Inputs and design settings

Alternatives [3 profiles]

Result 1 Result 2 Result 3
0.4 0.5 0.6

Standard deviation [3 profiles]

Result 1 Result 2 Result 3
0.5 0.6 0.7

Results and derived parameters

Maximum number of subjects [3 profiles]

Result 1 Result 2 Result 3
51.44676 47.57698 45.08554

Maximum number of subjects (1) [3 profiles]

Result 1 Result 2 Result 3
25.72338 23.78849 22.54277

Maximum number of subjects (2) [3 profiles]

Result 1 Result 2 Result 3
25.72338 23.78849 22.54277

Number of subjects [3 profiles]

Stage Result 1 Result 2 Result 3
1 25.72338 23.78849 22.54277
2 51.44676 47.57698 45.08554

Expected number of subjects under H0 [3 profiles]

Result 1 Result 2 Result 3
51.38032 47.51554 45.02732

Expected number of subjects under H0/H1 [3 profiles]

Result 1 Result 2 Result 3
50.52687 46.72629 44.27939

Critical values (treatment effect scale) [3 profiles]

Stage Result 1 Result 2 Result 3
1 0.6073681 0.7647210 0.9226527
2 0.2827050 0.3535361 0.4243800

Expected number of subjects [3 profiles]

Stage Result 1 Result 2 Result 3
1 46.05501 42.59080 40.36046
2 46.05501 42.59080 40.36046

Legend

  • Profiles compare exact values on their applicable coordinates.

Complete display: summary(x, showAll = TRUE). Full data: as.data.frame(x). Exact profiles: summary(x)$parameterInfo.

The standardized effects increase slightly across these scenarios, from 0.80 to approximately 0.83 and 0.86. Sample size requirements therefore decrease, even though the standard deviation increases. Only the final combined summary is displayed; chaining %vs% includes all three plans in that summary.

Pass the result directly to plot() to inspect several consequences together:

sampleSize1 %vs% sampleSize2 %vs% sampleSize3 |>
    plot(
        xAxis = "alternative",
        yAxis = c(
            "numberOfSubjects", "expectedNumberOfSubjects",
            "criticalValuesEffectScale"
        ),
        category = "stages"
    )

Planned and expected sample sizes and efficacy boundaries on the treatment effect scale for three two-stage planning scenarios.

numberOfSubjects shows the planned sample size at each analysis; expectedNumberOfSubjects accounts for early stopping under the planning alternative. criticalValuesEffectScale expresses the efficacy thresholds in the endpoint’s original units. category = "stages" distinguishes the interim and final analyses. Read each quantity against its labeled axis: patient counts and effect-scale thresholds have different units. The horizontal axis identifies the effect assumption, but the standard deviation also changes between points. These curves compare the three specified scenarios rather than varying the effect while holding variability fixed.

Configure the amount of summary output

Frequent users of %vs% may want complete comparison summaries by default, without adding a separate summary(showAll = TRUE) call each time. Set the R option for the session, or use the corresponding environment variable:

# R option
options(rpact.comparison.summary.showAll = TRUE)

# Alternatively, use the environment variable
Sys.setenv(RPACT_COMPARISON_SUMMARY_SHOW_ALL = "true")

showAll removes the summary’s display limits and text truncation and lists all shared parameter captions. It continues to focus the detailed comparison on differing parameters; it does not change the calculations. The environment variable takes precedence over the R option. See Trial Comparison Summaries in Hidden rpact Features for all summary settings, their defaults, and how to reset them. The configuration chunk above is not executed here, so it does not change the display settings for the rest of this vignette.

Unlike |> compare(), which returns a comparison container, %vs% returns a TrialComparisonSummary. This makes it convenient for immediate reporting and plotting. Use getComparison() and |> add() when building and maintaining a named collection over the course of a planning exercise.

Inspect and report the comparison

The named comparison comp still contains the two sequential scenarios:

comp |> print()

Design comparison

2 objects; 5 comparison rows; 27 columns.

Object types

  • Group sequential design: 1
  • Group sequential design characteristics: 1

Observed metrics (across objects, stages and situations)

  • Maximum number of stages: 2, 3
  • Significance level: 0.025
  • Type II error rate: 0.2

Available operations

  • summary(x): Compare differences
  • as.data.frame(x): Access all data
  • plot(x, xAxis = …, yAxis = …): Plot selected parameters
  • getObjects(x): Access contained objects
comp |> summary()

Design comparison summary

Comparison of 2 trial planning results: group sequential design, group sequential design characteristics. The comparison identifies 15 differing parameters and 8 shared parameters or profiles. Shared (examples): Endpoint, Calculation target, Type of design, Significance level, Type II error rate, Binding futility, … (all shared captions: showAll = TRUE)

Object types and scope

Object type [2 profiles]

design1 design2
TrialDesignGroupSequential TrialDesignCharacteristics

Inputs and design settings

Maximum number of stages [2 profiles]

design1 design2
2 3

Information rates [2 profiles]

Stage design1 design2
1 0.5000000 0.3333333
2 1.0000000 0.6666667
3 <absent> 1.0000000

Futility bounds (non-binding) [2 profiles]

Stage design1 design2
1 -Inf -Inf
2 -Inf -Inf
3 <absent> NA

Results and derived parameters

Cumulative alpha spending [2 profiles]

Stage design1 design2
1 0.0025828932 0.0002591737
2 0.0249999900 0.0071600594
3 <absent> 0.0249999900

Critical values [2 profiles]

Stage design1 design2
1 2.796510 3.471091
2 1.977431 2.454432
3 <absent> 2.004036

Stage levels (one-sided) [2 profiles]

Stage design1 design2
1 0.0025828932 0.0002591737
2 0.0239964687 0.0070553616
3 <absent> 0.0225331246

Inflation factor [2 profiles]

design1 design2
NA 1.017406

Informations [2 profiles]

Stage design1 design2
1 NA 2.661833
2 NA 5.323666
3 NA 7.985499

Power [2 profiles]

Stage design1 design2
1 NA 0.03291504
2 NA 0.44239580
3 NA 0.80000000

Rejection probabilities under H1 [2 profiles]

Stage design1 design2
1 NA 0.03291504
2 NA 0.40948076
3 NA 0.35760420

Futility probabilities under H1 [2 profiles]

Stage design1 design2
1 NA 0
2 NA 0
3 NA NA

3 more differing parameters; increase maxParameters or use showAll = TRUE.

Legend

  • Profiles compare exact values on their applicable coordinates.
  • <absent>: coordinate not present in this profile.
  • NA: missing/unavailable.

Complete display: summary(x, showAll = TRUE). Full data: as.data.frame(x). Exact profiles: summary(x)$parameterInfo.

print() gives a compact overview of the collection and selected ranges. summary() describes differences between the objects, separating their scope, inputs and design settings, and calculated results. In this mixed example, some parameters only exist for the design characteristics object. Such missing entries are represented by NA; they do not mean zero.

The following exports serve different purposes:

comp |> as.data.frame()
comp |> as.data.frame(niceColumnNamesEnabled = TRUE)
comp |> as.data.frame(removeConstantParameters = TRUE)
comp |> as.data.frame(transposed = TRUE)
Parameter design1 / Stage 1 design1 / Stage 2 design2 / Stage 1 design2 / Stage 2 design2 / Stage 3
Object number 1 1 2 2 2
Object name design1 design1 design2 design2 design2
Stage 1 2 1 2 3
Situation 1 1 1 1 1
Object type TrialDesignGroupSequential TrialDesignGroupSequential TrialDesignCharacteristics TrialDesignCharacteristics TrialDesignCharacteristics
Maximum # stages 2 2 3 3 3
Information rate 0.5000000 1.0000000 0.3333333 0.6666667 1.0000000
Futility bound (binding) -Inf -Inf -Inf -Inf NA
Cumulative alpha spending 0.0025828932 0.0249999900 0.0002591737 0.0071600594 0.0249999900
Critical value 2.796510 1.977431 3.471091 2.454432 2.004036
Stage level 0.0025828932 0.0239964687 0.0002591737 0.0070553616 0.0225331246
Inflation factor NA NA 1.017406 1.017406 1.017406
Information NA NA 2.661833 5.323666 7.985499
Power NA NA 0.03291504 0.44239580 0.80000000
Rejection probability under H1 NA NA 0.03291504 0.40948076 0.35760420
Futility probability under H1 NA NA 0 0 NA
Ratio expected vs fixed sample size under H1 NA NA 0.8562115 0.8562115 0.8562115
Ratio expected vs fixed sample size under a value between H0 and H1 NA NA 0.9830924 0.9830924 0.9830924
Ratio expected vs fixed sample size under H0 NA NA 1.01489 1.01489 1.01489

The default data frame retains technical parameter names and unrounded values for further calculations. niceColumnNamesEnabled = TRUE supplies readable column captions for reporting. removeConstantParameters = TRUE retains identifiers and parameters whose object profiles differ. A shared sequence of stage-specific values can therefore be removed even though it varies between rows. These export options do not change the stored objects. transposed = TRUE transposes the data.

Choosing plot axes explicitly

There are several varying parameters in this comparison. Calling plot() without specifying axes is ambiguous. The following chunk deliberately displays the resulting error and allows the vignette to continue:

comp |> plot()
Error:
! Missing argument: Cannot select plot axes unambiguously.
Please specify xAxis and yAxis explicitly.

Available for xAxis:
  - stages: Stages
  - kMax: Maximum number of stages
  - informationRates: Information rates

Available for yAxis:
  - alphaSpent: Cumulative alpha spending
  - criticalValues: Critical values
  - stageLevels: Stage levels (one-sided)
  - information: Informations
  - power: Power
  ... and 1 more.

Example:
  plot(x,
      xAxis = "stages",
      yAxis = "alphaSpent")

Choose the scientific question explicitly, for example the efficacy critical values at each analysis:

plot(comp, xAxis = "stages", yAxis = "criticalValues")

Efficacy critical values for the two-stage design and three-stage design characteristics.

xAxis selects the column for the horizontal axis; yAxis selects one or more numeric columns for the vertical axis. Use category to distinguish scenarios and group for an additional grouping. For example:

getSampleSizeMeans(alternative = 0.22, stDev = 0.5) |>
    compare(getSampleSizeMeans(alternative = 0.44, stDev = 1)) |>
    compare(getSampleSizeMeans(alternative = 0.59, stDev = 1)) |>
    plot(
        xAxis = "alternative",
        yAxis = c("nFixed", "criticalValuesEffectScale"),
        category = "stDev",
        plotLineEnabled = TRUE
    )

The selector can be inspected without drawing a plot or raising a plot-selection error:

selection <- comp |> getComparisonPlotParameters()
selection[c("xAxis", "yAxis", "message", "candidates")]
$xAxis
NULL

$yAxis
NULL

$message
[1] "Cannot select plot axes unambiguously.\nPlease specify xAxis and yAxis explicitly.\n\nAvailable for xAxis:\n  - stages: Stages\n  - kMax: Maximum number of stages\n  - informationRates: Information rates\n\nAvailable for yAxis:\n  - alphaSpent: Cumulative alpha spending\n  - criticalValues: Critical values\n  - stageLevels: Stage levels (one-sided)\n  - information: Informations\n  - power: Power\n  ... and 1 more.\n\nExample:\n  plot(x,\n      xAxis = \"stages\",\n      yAxis = \"alphaSpent\")"

$candidates
$candidates$xAxis
[1] "stages"           "kMax"             "informationRates"

$candidates$yAxis
[1] "alphaSpent"             "criticalValues"         "stageLevels"           
[4] "information"            "power"                  "rejectionProbabilities"

$candidates$category
[1] "objectName"   "objectNumber"

$candidates$group
 [1] "objectNumber"           "objectName"             "stages"                
 [4] "situation"              "objectType"             "endpoint"              
 [7] "calculationTarget"      "kMax"                   "informationRates"      
[10] "typeOfDesign"           "alpha"                  "beta"                  
[13] "futilityBounds"         "bindingFutility"        "sided"                 
[16] "tolerance"              "alphaSpent"             "criticalValues"        
[19] "stageLevels"            "inflationFactor"        "information"           
[22] "power"                  "rejectionProbabilities" "futilityProbabilities" 
[25] "averageSampleNumber1"   "averageSampleNumber01"  "averageSampleNumber0"  
comp |> names()
[1] "design1" "design2"

message is NULL when the selection is resolved. The names shown here are the identifiers supplied with add().

Fixed design: planning a blood pressure trial

Clinical question and assumptions

Consider a randomized superiority trial comparing an antihypertensive treatment with control. The endpoint is the reduction in systolic blood pressure from baseline to the assessment visit, in mmHg. We define reduction as baseline minus follow-up, so that a larger positive reduction is better. Thus alternative = 5 means a mean reduction that is 5 mmHg greater with treatment than with control. Group 1 is treatment and group 2 is control.

We initially assume:

  • a one-sided significance level of 0.025 and 90% power;
  • a common standard deviation of 12 mmHg;
  • equal allocation to treatment and control;
  • an unknown common variance, using the default t-test calculation (normalApproximation = FALSE).

The target effect is 5 mmHg. Effects of 4, 6, and 7 mmHg are included to assess sensitivity. We also consider a standard deviation of 15 mmHg and a 2:1 allocation, which might be attractive if more treatment exposure is desired.

fixedDesign <- getDesignFixed(alpha = 0.025, beta = 0.10, sided = 1)
planningEffects <- c(4, 5, 6, 7)

fixedPlans <- getComparison()
fixedPlans |> add(
    sd12_equal = getSampleSizeMeans(
        fixedDesign, alternative = planningEffects, stDev = 12,
        allocationRatioPlanned = 1
    )
)

Sample size calculation comparison

1 objects; 4 comparison rows; 25 columns.

Object types

  • Sample size means: 1

Observed metrics (across objects, stages and situations)

  • Maximum number of stages: 1
  • Significance level: 0.025
  • Type II error rate: 0.1
  • Number of subjects fixed: 125.4680, 380.1983

Available operations

  • summary(x): Compare differences
  • as.data.frame(x): Access all data
  • plot(x, xAxis = …, yAxis = …): Plot selected parameters
  • getObjects(x): Access contained objects
fixedPlans |> add(
    sd15_equal = getSampleSizeMeans(
        fixedDesign, alternative = planningEffects, stDev = 15,
        allocationRatioPlanned = 1
    )
)

Sample size calculation comparison

2 objects; 8 comparison rows; 25 columns.

Object types

  • Sample size means: 2

Observed metrics (across objects, stages and situations)

  • Maximum number of stages: 1
  • Significance level: 0.025
  • Type II error rate: 0.1
  • Number of subjects fixed: 125.4680, 592.9699

Available operations

  • summary(x): Compare differences
  • as.data.frame(x): Access all data
  • plot(x, xAxis = …, yAxis = …): Plot selected parameters
  • getObjects(x): Access contained objects
fixedPlans |> add(
    sd12_2to1 = getSampleSizeMeans(
        fixedDesign, alternative = planningEffects, stDev = 12,
        allocationRatioPlanned = 2
    )
)

Sample size calculation comparison

3 objects; 12 comparison rows; 25 columns.

Object types

  • Sample size means: 3

Observed metrics (across objects, stages and situations)

  • Maximum number of stages: 1
  • Significance level: 0.025
  • Type II error rate: 0.1
  • Number of subjects fixed: 125.4680, 592.9699

Available operations

  • summary(x): Compare differences
  • as.data.frame(x): Access all data
  • plot(x, xAxis = …, yAxis = …): Plot selected parameters
  • getObjects(x): Access contained objects
print(fixedPlans)

Sample size calculation comparison

3 objects; 12 comparison rows; 25 columns.

Object types

  • Sample size means: 3

Observed metrics (across objects, stages and situations)

  • Maximum number of stages: 1
  • Significance level: 0.025
  • Type II error rate: 0.1
  • Number of subjects fixed: 125.4680, 592.9699

Available operations

  • summary(x): Compare differences
  • as.data.frame(x): Access all data
  • plot(x, xAxis = …, yAxis = …): Plot selected parameters
  • getObjects(x): Access contained objects
summary(fixedPlans, digits = 3, maxParameters = 20, maxProfiles = 4)

Sample size calculation comparison summary

Comparison of 3 sample size means calculations. The comparison identifies 6 differing parameters and 15 shared parameters or profiles. Shared (examples): Object type, Endpoint, Calculation target, Alternatives, Type II error rate, Normal approximation, … (all shared captions: showAll = TRUE)

Inputs and design settings

Standard deviation [2 profiles]

sd12_equal, sd12_2to1 sd15_equal
12 15

Planned allocation ratio [2 profiles]

sd12_equal, sd15_equal sd12_2to1
1 2

Results and derived parameters

Critical values (treatment effect scale) [3 profiles]

Situation sd12_equal sd15_equal sd12_2to1
1 2.42 2.42 2.42
2 3.026 3.025 3.026
3 3.633 3.631 3.633
4 4.241 4.238 4.24

Number of subjects fixed [3 profiles]

Situation sd12_equal sd15_equal sd12_2to1
1 380.198 592.97 427.481
2 244.028 380.198 274.287
3 170.063 264.621 191.075
4 125.468 194.934 140.904

Number of subjects fixed (1) [3 profiles]

Situation sd12_equal sd15_equal sd12_2to1
1 190.099 296.485 284.987
2 122.014 190.099 182.858
3 85.031 132.311 127.383
4 62.734 97.467 93.936

Number of subjects fixed (2) [3 profiles]

Situation sd12_equal sd15_equal sd12_2to1
1 190.099 296.485 142.494
2 122.014 190.099 91.429
3 85.031 132.311 63.692
4 62.734 97.467 46.968

Legend

  • Profiles compare exact values on their applicable coordinates.
  • Display values are rounded.

Complete display: summary(x, showAll = TRUE). Full data: as.data.frame(x). Exact profiles: summary(x)$parameterInfo.

Each object contains several situations, one per effect assumption. The comparison retains both the object identity and the situations within it. The summary helps check that the intended assumptions differ while the significance level and target power are shared. Display limits can be increased for a fuller overview; they do not truncate the data frame.

Sample size sensitivity and allocation

fixedData <- as.data.frame(fixedPlans)
fixedTable <- fixedData[, c(
    "objectName", "alternative", "stDev", "allocationRatioPlanned",
    "nFixed", "nFixed1", "nFixed2"
)]
knitr::kable(fixedTable, digits = 1, row.names = FALSE)
objectName alternative stDev allocationRatioPlanned nFixed nFixed1 nFixed2
sd12_equal 4 12 1 380.2 190.1 190.1
sd12_equal 5 12 1 244.0 122.0 122.0
sd12_equal 6 12 1 170.1 85.0 85.0
sd12_equal 7 12 1 125.5 62.7 62.7
sd15_equal 4 15 1 593.0 296.5 296.5
sd15_equal 5 15 1 380.2 190.1 190.1
sd15_equal 6 15 1 264.6 132.3 132.3
sd15_equal 7 15 1 194.9 97.5 97.5
sd12_2to1 4 12 2 427.5 285.0 142.5
sd12_2to1 5 12 2 274.3 182.9 91.4
sd12_2to1 6 12 2 191.1 127.4 63.7
sd12_2to1 7 12 2 140.9 93.9 47.0

nFixed is the total sample size, and nFixed1 and nFixed2 are the group-specific sizes. The calculations return fractional requirements; an operational plan needs integer group sizes. For a quick comparison of how sample size changes with the assumed effect:

plot(fixedPlans, xAxis = "alternative", yAxis = "nFixed")

Required total sample size for different effect, variability, and allocation assumptions.

The smaller effect requires substantially more patients. Higher variability also increases the requirement. With equal variances and otherwise identical assumptions, 2:1 allocation is less efficient in terms of total sample size than 1:1 allocation. The curves make this cost visible before deciding whether the additional treatment exposure justifies it.

Select an integer sample size and validate its power

Suppose the team selects the 5 mmHg effect, standard deviation 12 mmHg, and equal allocation. We retrieve the corresponding object and round the group size upward:

referencePlan <- fixedPlans |> fetch("sd12_equal")
referenceSituation <- match(5, referencePlan$alternative)
subjectsPerGroup <- ceiling(referencePlan$nFixed1[referenceSituation])
fixedTotal <- 2 * subjectsPerGroup

data.frame(subjectsPerGroup, fixedTotal)
  subjectsPerGroup fixedTotal
1              123        246

The resulting plan has 123 evaluable patients per group, or 246 in total. If 10% of randomized patients are expected to have no usable endpoint, a simple recruitment allowance would be 274 patients, rounding within each group. The power calculations below use the evaluable sample size, not the larger recruitment target. This allowance is a planning simplification and does not specify the analysis of missing outcomes.

Now hold the selected total sample size fixed and calculate power under several possible true effects. Recalculating the sample size for each effect would answer a different question.

powerEffects <- seq(3, 7, by = 0.5)
fixedPower <- getComparison()
fixedPower |> add(
    sd12_equal = getPowerMeans(
        fixedDesign, alternative = powerEffects, stDev = 12,
        allocationRatioPlanned = 1, maxNumberOfSubjects = fixedTotal
    )
)

Power calculation comparison

1 objects; 9 comparison rows; 28 columns.

Object types

  • Power means: 1

Observed metrics (across objects, stages and situations)

  • Maximum number of stages: 1
  • Significance level: 0.025
  • Type II error rate: 0.1
  • Maximum number of subjects: 246
  • Number of subjects fixed: 246
  • Overall reject: 0.4971536, 0.9952921

Available operations

  • summary(x): Compare differences
  • as.data.frame(x): Access all data
  • plot(x, xAxis = …, yAxis = …): Plot selected parameters
  • getObjects(x): Access contained objects
fixedPower |> add(
    sd15_equal = getPowerMeans(
        fixedDesign, alternative = powerEffects, stDev = 15,
        allocationRatioPlanned = 1, maxNumberOfSubjects = fixedTotal
    )
)

Power calculation comparison

2 objects; 18 comparison rows; 28 columns.

Object types

  • Power means: 2

Observed metrics (across objects, stages and situations)

  • Maximum number of stages: 1
  • Significance level: 0.025
  • Type II error rate: 0.1
  • Maximum number of subjects: 246
  • Number of subjects fixed: 246
  • Overall reject: 0.3454266, 0.9952921

Available operations

  • summary(x): Compare differences
  • as.data.frame(x): Access all data
  • plot(x, xAxis = …, yAxis = …): Plot selected parameters
  • getObjects(x): Access contained objects
fixedPower |> add(
    sd12_2to1 = getPowerMeans(
        fixedDesign, alternative = powerEffects, stDev = 12,
        allocationRatioPlanned = 2, maxNumberOfSubjects = fixedTotal
    )
)

Power calculation comparison

3 objects; 27 comparison rows; 28 columns.

Object types

  • Power means: 3

Observed metrics (across objects, stages and situations)

  • Maximum number of stages: 1
  • Significance level: 0.025
  • Type II error rate: 0.1
  • Maximum number of subjects: 246
  • Number of subjects fixed: 246
  • Overall reject: 0.3454266, 0.9952921

Available operations

  • summary(x): Compare differences
  • as.data.frame(x): Access all data
  • plot(x, xAxis = …, yAxis = …): Plot selected parameters
  • getObjects(x): Access contained objects
print(fixedPower)

Power calculation comparison

3 objects; 27 comparison rows; 28 columns.

Object types

  • Power means: 3

Observed metrics (across objects, stages and situations)

  • Maximum number of stages: 1
  • Significance level: 0.025
  • Type II error rate: 0.1
  • Maximum number of subjects: 246
  • Number of subjects fixed: 246
  • Overall reject: 0.3454266, 0.9952921

Available operations

  • summary(x): Compare differences
  • as.data.frame(x): Access all data
  • plot(x, xAxis = …, yAxis = …): Plot selected parameters
  • getObjects(x): Access contained objects
summary(fixedPower, digits = 3, maxParameters = 20)

Power calculation comparison summary

Comparison of 3 power means calculations. The comparison identifies 6 differing parameters and 18 shared parameters or profiles. Shared (examples): Object type, Endpoint, Calculation target, Alternatives, Maximum number of subjects, Type II error rate, … (all shared captions: showAll = TRUE)

Inputs and design settings

Standard deviation [2 profiles]

Situation sd12_equal, sd12_2to1 sd15_equal
1 12 15
2 12 15
3 12 15
4 12 15

sd12_equal, sd12_2to1: … (+5 values)

sd15_equal: … (+5 values)

Planned allocation ratio [2 profiles]

sd12_equal, sd15_equal sd12_2to1
1 2

Results and derived parameters

Overall reject [3 profiles]

Situation sd12_equal sd15_equal sd12_2to1
1 0.497 0.345 0.453
2 0.625 0.445 0.575
3 0.74 0.549 0.69
4 0.834 0.649 0.789

sd12_equal: … (+5 values)

sd15_equal: … (+5 values)

sd12_2to1: … (+5 values)

Critical values (treatment effect scale) [3 profiles]

sd12_equal sd15_equal sd12_2to1
3.014 3.768 3.197

Number of subjects fixed (1) [2 profiles]

sd12_equal, sd15_equal sd12_2to1
123 164

Number of subjects fixed (2) [2 profiles]

sd12_equal, sd15_equal sd12_2to1
123 82

More values available; increase maxValues or use showAll = TRUE.

Legend

  • Profiles compare exact values on their applicable coordinates.
  • Display values are rounded.

Complete display: summary(x, showAll = TRUE). Full data: as.data.frame(x). Exact profiles: summary(x)$parameterInfo.

For a concise decision table, retain the target and a smaller effect:

fixedPowerData <- as.data.frame(fixedPower)
knitr::kable(
    subset(fixedPowerData, alternative %in% c(4, 5), select = c(
        objectName, alternative, stDev, allocationRatioPlanned,
        maxNumberOfSubjects, overallReject
    )),
    digits = 3, row.names = FALSE
)
objectName alternative stDev allocationRatioPlanned maxNumberOfSubjects overallReject
sd12_equal 4 12 1 246 0.740
sd12_equal 5 12 1 246 0.902
sd15_equal 4 15 1 246 0.549
sd15_equal 5 15 1 246 0.740
sd12_2to1 4 12 2 246 0.690
sd12_2to1 5 12 2 246 0.866
plot(fixedPower, xAxis = "alternative", yAxis = "overallReject") +
    geom_hline(yintercept = 0.90, linetype = "dashed", colour = "grey40")

Power at the selected fixed total sample size; the dashed line marks 90% power.

overallReject is the probability of rejecting the null hypothesis. At 5 mmHg, the reference scenario reaches at least 90% power after rounding. A smaller effect, higher standard deviation, or unequal allocation at this same total can reduce power. This calculation checks consistency with the planning assumptions; it is not independent validation of the statistical model or software.

One interim analysis: comparing futility strategies

Efficacy and futility rules

We now consider an interim analysis at 50% information, followed by the final analysis. All sequential designs use the same one-sided alpha-spending O’Brien-Fleming efficacy rule (typeOfDesign = "asOF"), significance level, and target power. Only the interim futility rule changes:

Scenario Interim futility rule Planning interpretation
no_futility No futility stopping Continue unless efficacy is established.
z0 Stop if the interim Z statistic is below 0 Stop for an effect in the unfavorable direction.
z0_5 Stop if Z is below 0.5 Require at least a modest favorable signal to continue.
z1 Stop if Z is below 1 A more demanding continuation rule, with greater risk of discarding an effective treatment.

These are candidate rules for discussion with the study team. Their one-sided p-value thresholds are 0.50, approximately 0.31, and approximately 0.16, respectively; they are not conditional-power thresholds. The corresponding thresholds in mmHg depend on information, sample size, and variability and can be inspected in the sample size plans.

We specify non-binding futility. The efficacy boundaries control the Type I error even if a futility recommendation is not followed. However, the power and expected sample size calculations below assume that the stated futility stopping rule is followed. Ignoring it changes those operating characteristics.

futilityRules <- c(no_futility = -Inf, z0 = 0, z0_5 = 0.5, z1 = 1)
sequentialDesigns <- lapply(futilityRules, function(bound) {
    binding <- if (is.finite(bound)) {
        FALSE
    } else {
        NA
    }
    return(getDesignGroupSequential(
        kMax = 2, informationRates = c(0.5, 1),
        alpha = 0.025, beta = 0.10, sided = 1,
        typeOfDesign = "asOF", futilityBounds = bound,
        bindingFutility = binding
    ))
})

designComparison <- getComparison()
designComparison |> add(objects = sequentialDesigns)

Design comparison

4 objects; 8 comparison rows; 20 columns.

Object types

  • Group sequential design: 4

Observed metrics (across objects, stages and situations)

  • Maximum number of stages: 2
  • Significance level: 0.025
  • Type II error rate: 0.1

Available operations

  • summary(x): Compare differences
  • as.data.frame(x): Access all data
  • plot(x, xAxis = …, yAxis = …): Plot selected parameters
  • getObjects(x): Access contained objects
summary(designComparison, digits = 3, maxParameters = 20, maxProfiles = 4)

Design comparison summary

Comparison of 4 trial planning results: group sequential design. The comparison identifies 1 differing parameter and 15 shared parameters or profiles. Shared (examples): Object type, Endpoint, Calculation target, Type of design, Type II error rate, Information rates, … (all shared captions: showAll = TRUE)

Inputs and design settings

Futility bounds (non-binding) [4 profiles]

Stage no_futility z0 z0_5 z1
1 -Inf 0 0.5 1
2 -Inf 0 0.5 1

Legend

  • Profiles compare exact values on their applicable coordinates.
  • Display values are rounded.

Complete display: summary(x, showAll = TRUE). Full data: as.data.frame(x). Exact profiles: summary(x)$parameterInfo.

Since the designs are already available as a named list, pass the entire list to add() in one call. Its entries are added in list order and retain their names; there is no need for another loop. You can also pass the list directly to the constructor with getComparison(objects = sequentialDesigns).

The design summary checks that the efficacy settings agree and that the futility bounds differ as intended. -Inf disables futility stopping at the interim analysis.

Re-plan each strategy for the same target power

For each design, calculate the sample size needed for 90% power at effects of 4, 5, and 6 mmHg, using standard deviation 12 mmHg and equal allocation:

sequentialPlans <- getComparison()
for (scenarioName in names(designComparison)) {
    design <- designComparison |> fetch(scenarioName)
    plan <- getSampleSizeMeans(
        design, alternative = c(4, 5, 6), stDev = 12,
        allocationRatioPlanned = 1
    )
    sequentialPlans |> add(objects = setNames(list(plan), scenarioName))
}

print(sequentialPlans)

Sample size calculation comparison

4 objects; 24 comparison rows; 42 columns.

Object types

  • Sample size means: 4

Observed metrics (across objects, stages and situations)

  • Maximum number of stages: 2
  • Significance level: 0.025
  • Type II error rate: 0.1
  • Maximum number of subjects: 170.6439, 450.1830
  • Expected number of subjects: 149.0983, 363.0042

Available operations

  • summary(x): Compare differences
  • as.data.frame(x): Access all data
  • plot(x, xAxis = …, yAxis = …): Plot selected parameters
  • getObjects(x): Access contained objects
summary(sequentialPlans, digits = 3, maxParameters = 25, maxProfiles = 4)

Sample size calculation comparison summary

Comparison of 4 sample size means calculations. The comparison identifies 15 differing parameters and 23 shared parameters or profiles. Shared (examples): Object type, Endpoint, Calculation target, Alternatives, Standard deviation, Type of design, … (all shared captions: showAll = TRUE)

Inputs and design settings

Futility bounds (non-binding) [4 profiles]

Stage no_futility z0 z0_5 z1
1 -Inf 0 0.5 1
2 -Inf 0 0.5 1

Results and derived parameters

Maximum number of subjects [4 profiles]

Situation no_futility z0 z0_5 z1
1 381.498 384.609 399.003 450.183
2 244.862 246.859 256.097 288.947
3 170.644 172.036 178.474 201.367

Maximum number of subjects (1) [4 profiles]

Situation no_futility z0 z0_5 z1
1 190.749 192.305 199.501 225.091
2 122.431 123.429 128.049 144.474
3 85.322 86.018 89.237 100.683

Maximum number of subjects (2) [4 profiles]

Situation no_futility z0 z0_5 z1
1 190.749 192.305 199.501 225.091
2 122.431 123.429 128.049 144.474
3 85.322 86.018 89.237 100.683

Number of subjects [4 profiles]

Stage Situation no_futility z0 z0_5 z1
1 1 190.749 192.305 199.501 225.091
1 2 122.431 123.429 128.049 144.474
1 3 85.322 86.018 89.237 100.683
2 1 381.498 384.609 399.003 450.183

no_futility: … (+2 values)

z0: … (+2 values)

z0_5: … (+2 values)

z1: … (+2 values)

Expected number of subjects under H0 [4 profiles]

Situation no_futility z0 z0_5 z1
1 381.207 288.164 260.751 260.46
2 244.675 184.956 167.361 167.175
3 170.514 128.896 116.634 116.504

Expected number of subjects under H0/H1 [4 profiles]

Situation no_futility z0 z0_5 z1
1 374.861 353.903 341.749 349.893
2 240.602 227.15 219.349 224.577
3 167.675 158.301 152.864 156.507

Reject per stage [4 profiles]

Stage no_futility z0 z0_5 z1
1 0.253 0.256 0.269 0.32
2 0.647 0.644 0.631 0.58

Futility stop [4 profiles]

Stage Situation no_futility z0 z0_5 z1
1 1 NA 0.011 0.032 0.068
1 2 NA 0.011 0.032 0.068
1 3 NA 0.011 0.032 0.068
2 1 NA NA NA NA

no_futility: … (+2 values)

z0: … (+2 values)

z0_5: … (+2 values)

z1: … (+2 values)

Overall futility stop [4 profiles]

Stage Situation no_futility
1 1 NA
1 2 NA
1 3 NA
2 1 NA

no_futility: … (+2 values)

z0
0.011
z0_5
0.032
z1
0.068

Early stop [4 profiles]

no_futility z0 z0_5 z1
0.253 0.266 0.302 0.387

Critical values (treatment effect scale) [4 profiles]

Stage Situation no_futility z0 z0_5 z1
1 1 5.216 5.194 5.097 4.792
1 2 6.559 6.531 6.407 6.019
1 3 7.93 7.895 7.743 7.266
2 1 2.427 2.417 2.373 2.233

no_futility: … (+2 values)

z0: … (+2 values)

z0_5: … (+2 values)

z1: … (+2 values)

Futility bounds (treatment effect scale) [4 profiles]

Stage Situation no_futility z0 z0_5 z1
1 1 NA 0 0.851 1.603
1 2 NA 0 1.063 2.004
1 3 NA 0 1.275 2.404
2 1 NA NA NA NA

no_futility: … (+2 values)

z0: … (+2 values)

z0_5: … (+2 values)

z1: … (+2 values)

Futility bounds (one-sided p-value scale) [4 profiles]

Stage Situation no_futility z0 z0_5 z1
1 1 NA 0.5 0.309 0.159
1 2 NA 0.5 0.309 0.159
1 3 NA 0.5 0.309 0.159
2 1 NA NA NA NA

no_futility: … (+2 values)

z0: … (+2 values)

z0_5: … (+2 values)

z1: … (+2 values)

Expected number of subjects [4 profiles]

Stage Situation no_futility z0 z0_5 z1
1 1 333.33 333.439 338.805 363.004
1 2 213.946 214.016 217.46 232.992
1 3 149.098 149.147 151.548 162.372
2 1 333.33 333.439 338.805 363.004

no_futility: … (+2 values)

z0: … (+2 values)

z0_5: … (+2 values)

z1: … (+2 values)

More values available; increase maxValues or use showAll = TRUE.

Legend

  • Profiles compare exact values on their applicable coordinates.
  • NA: missing/unavailable.
  • Display values are rounded.

Complete display: summary(x, showAll = TRUE). Full data: as.data.frame(x). Exact profiles: summary(x)$parameterInfo.

Here the loop calculates a new plan and adds it immediately. In this case, setNames(list(plan), scenarioName) supplies the scenario name programmatically. add(objects = ...) retains the list entry’s name; add(scenarioName = plan) would instead use the literal name "scenarioName".

For a sequential trial, distinguish the maximum sample size, which determines the recruitment commitment if the study continues, from the expected sample size, which averages over early stopping. A stronger futility rule can require a larger maximum sample size to preserve the target power, even while reducing expected recruitment under an ineffective treatment.

The comparison data have one row per stage and situation. Overall results are repeated across stages, while quantities such as numberOfSubjects and rejectPerStage are stage-specific. For a table of overall sample size requirements, select the final-stage rows rather than adding the repeated totals:

sequentialData <- as.data.frame(sequentialPlans)
sequentialTotals <- subset(sequentialData, stages == kMax)
knitr::kable(
    subset(sequentialTotals, alternative == 5, select = c(
        objectName, 
        alternative, 
        maxNumberOfSubjects,
        expectedNumberOfSubjects
    )),
    digits = 1, row.names = FALSE
)
objectName alternative maxNumberOfSubjects expectedNumberOfSubjects
no_futility 5 244.9 213.9
z0 5 246.9 214.0
z0_5 5 256.1 217.5
z1 5 288.9 233.0

For reference, the fixed design at 5 mmHg required 244 patients before rounding and has no early stopping benefit.

plot(
    sequentialPlans,
    xAxis = "alternative",
    yAxis = c("maxNumberOfSubjects", "expectedNumberOfSubjects"),
    yAxisSide = "left",
    main = "Maximum and expected sample size"
) +
    labs(y = "Total sample size (patients)")

Maximum and expected total sample size under the planning alternative for each futility strategy.

Both plotted quantities use the same unit, patients, and the same axis. The line types distinguish the maximum from the expected size. A design decision should consider both, together with the expected size under the null shown in the table.

Validate each rounded maximum sample size

First validate each strategy at its own rounded maximum sample size, keeping the 50% information analysis and equal allocation. This checks that re-planning has compensated for the power cost of futility.

roundedMaxima <- vapply(getObjects(sequentialPlans), function(plan) {
    situation <- match(5, plan$alternative)
    return(2 * ceiling(plan$maxNumberOfSubjects[situation] / 2))
}, numeric(1))

sequentialValidation <- getComparison()
for (scenarioName in names(designComparison)) {
    validation <- getPowerMeans(
        designComparison |> fetch(scenarioName), alternative = 5, stDev = 12,
        allocationRatioPlanned = 1,
        maxNumberOfSubjects = roundedMaxima[[scenarioName]]
    )
    sequentialValidation |> add(objects = setNames(list(validation), scenarioName))
}
validationData <- as.data.frame(sequentialValidation)

knitr::kable(
    subset(validationData, stages == kMax, select = c(
        objectName, maxNumberOfSubjects, overallReject,
        expectedNumberOfSubjects, futilityStop
    )),
    digits = 3, row.names = FALSE
)
objectName maxNumberOfSubjects overallReject expectedNumberOfSubjects futilityStop
no_futility 246 0.901 214.727 NA
z0 248 0.901 214.805 0.010
z0_5 258 0.902 218.767 0.032
z1 290 0.901 233.638 0.067

At the target effect, all strategies should reach at least 90% power, subject to numerical precision. The calculation retains the specified information fractions. In an operational plan, round the interim group sizes as well and check the resulting information fractions if they change materially. For the short assessment window assumed here, recruitment can be paused for the interim decision; patients already recruited but awaiting outcomes would need additional planning if that assumption is unrealistic.

Compare power and expected recruitment at a common budget

The previous comparison allowed the maximum sample size to differ. A complementary question is: What would each stopping rule achieve with the same recruitment budget? Suppose the team can support the rounded maximum required by the z0_5 design at 5 mmHg. Hold that maximum fixed for every rule and vary the true effect, including zero.

commonMaximum <- roundedMaxima[["z0_5"]]
sequentialPower <- getComparison()
for (scenarioName in names(designComparison)) {
    power <- getPowerMeans(
        designComparison |> fetch(scenarioName),
        alternative = seq(0, 7, by = 0.5), stDev = 12,
        allocationRatioPlanned = 1, maxNumberOfSubjects = commonMaximum
    )
    sequentialPower |> add(objects = setNames(list(power), scenarioName))
}

print(sequentialPower)

Power calculation comparison

4 objects; 120 comparison rows; 40 columns.

Object types

  • Power means: 4

Observed metrics (across objects, stages and situations)

  • Maximum number of stages: 2
  • Significance level: 0.025
  • Type II error rate: 0.1
  • Maximum number of subjects: 258
  • Overall reject: 0.02037052, 0.99654328
  • Expected number of subjects: 149.2698, 257.8032

Available operations

  • summary(x): Compare differences
  • as.data.frame(x): Access all data
  • plot(x, xAxis = …, yAxis = …): Plot selected parameters
  • getObjects(x): Access contained objects
summary(sequentialPower, digits = 3, maxParameters = 25, maxProfiles = 4)

Power calculation comparison summary

Comparison of 4 power means calculations. The comparison identifies 9 differing parameters and 27 shared parameters or profiles. Shared (examples): Object type, Endpoint, Calculation target, Alternatives, Standard deviation, Maximum number of subjects, … (all shared captions: showAll = TRUE)

Inputs and design settings

Futility bounds (non-binding) [4 profiles]

Stage no_futility z0 z0_5 z1
1 -Inf 0 0.5 1
2 -Inf 0 0.5 1

Results and derived parameters

Expected number of subjects [4 profiles]

Situation no_futility z0 z0_5 z1
1 257.803 193.303 168.605 149.27
2 257.588 205.108 179.644 157.271
3 257.179 216.072 191.211 166.694
4 256.445 225.521 202.533 177.089

no_futility: … (+11 values)

z0: … (+11 values)

z0_5: … (+11 values)

z1: … (+11 values)

Reject per stage [4 profiles]

Stage Situation no_futility z0 z0_5 z1
1 1 0.002 0.002 0.002 0.002
1 2 0.003 0.003 0.003 0.003
1 3 0.006 0.006 0.006 0.006
1 4 0.012 0.012 0.012 0.012

no_futility: … (+26 values)

z0: … (+26 values)

z0_5: … (+26 values)

z1: … (+26 values)

Overall reject [4 profiles]

Situation no_futility z0 z0_5 z1
1 0.025 0.025 0.024 0.02
2 0.052 0.051 0.049 0.043
3 0.098 0.097 0.093 0.081
4 0.168 0.166 0.16 0.141

no_futility: … (+11 values)

z0: … (+11 values)

z0_5: … (+11 values)

z1: … (+11 values)

Futility stop [4 profiles]

Situation Stage no_futility z0 z0_5 z1
1 - NA <absent> <absent> <absent>
1 1 <absent> 0.5 0.691 0.841
2 - NA <absent> <absent> <absent>
2 1 <absent> 0.407 0.604 0.778
3 - NA <absent> <absent> <absent>
3 1 <absent> 0.319 0.511 0.701
4 - NA <absent> <absent> <absent>
4 1 <absent> 0.24 0.418 0.615

no_futility: … (+11 values)

z0: … (+26 values)

z0_5: … (+26 values)

z1: … (+26 values)

Overall futility stop [4 profiles]

Situation no_futility z0 z0_5 z1
1 NA 0.5 0.691 0.841
2 NA 0.407 0.604 0.778
3 NA 0.319 0.511 0.701
4 NA 0.24 0.418 0.615

no_futility: … (+11 values)

z0: … (+11 values)

z0_5: … (+11 values)

z1: … (+11 values)

Early stop [4 profiles]

Situation no_futility z0 z0_5 z1
1 0.002 0.502 0.693 0.843
2 0.003 0.41 0.607 0.781
3 0.006 0.325 0.518 0.708
4 0.012 0.252 0.43 0.627

no_futility: … (+11 values)

z0: … (+11 values)

z0_5: … (+11 values)

z1: … (+11 values)

Futility bounds (treatment effect scale) [4 profiles]

Stage Situation no_futility z0 z0_5 z1
1 1 NA 0 1.059 2.121
1 2 NA 0 1.059 2.121
1 3 NA 0 1.059 2.121
1 4 NA 0 1.059 2.121

no_futility: … (+26 values)

z0: … (+26 values)

z0_5: … (+26 values)

z1: … (+26 values)

Futility bounds (one-sided p-value scale) [4 profiles]

Stage Situation no_futility z0 z0_5 z1
1 1 NA 0.5 0.309 0.159
1 2 NA 0.5 0.309 0.159
1 3 NA 0.5 0.309 0.159
1 4 NA 0.5 0.309 0.159

no_futility: … (+26 values)

z0: … (+26 values)

z0_5: … (+26 values)

z1: … (+26 values)

More values available; increase maxValues or use showAll = TRUE.

Legend

  • Profiles compare exact values on their applicable coordinates.
  • <absent>: coordinate not present in this profile.
  • -: coordinate not applicable to this profile; values are not repeated across categories.
  • NA: missing/unavailable.
  • Display values are rounded.

Complete display: summary(x, showAll = TRUE). Full data: as.data.frame(x). Exact profiles: summary(x)$parameterInfo.

plot(
    sequentialPower, xAxis = "alternative", yAxis = "overallReject"
) +
    geom_hline(yintercept = 0.90, linetype = "dashed", colour = "grey40")

Probability of rejection under a common maximum sample size and different futility rules.
plot(
    summary(sequentialPower),
    xAxis = "alternative",
    yAxis = "expectedNumberOfSubjects"
)

Expected total sample size under the same common maximum sample size.

Plotting the summary uses its captured comparison data. The expected sample size can be largest at intermediate effects: a clearly ineffective treatment may stop for futility, and a large effect may stop for efficacy, while an intermediate effect often reaches the final analysis.

To support the design meeting, extract a table at the null, a smaller effect, and the target effect:

sequentialPowerData <- as.data.frame(sequentialPower)
decisionTable <- subset(
    sequentialPowerData, stages == kMax & alternative %in% c(0, 4, 5),
    select = c(
        objectName, alternative, maxNumberOfSubjects, overallReject,
        expectedNumberOfSubjects, futilityStop, earlyStop
    )
)
knitr::kable(decisionTable, digits = 3, row.names = FALSE)
objectName alternative maxNumberOfSubjects overallReject expectedNumberOfSubjects futilityStop earlyStop
no_futility 0 258 0.025 257.803 NA 0.002
no_futility 4 258 0.759 239.837 NA 0.141
no_futility 5 258 0.914 222.848 NA 0.272
z0 0 258 0.025 193.303 0.500 0.502
z0 4 258 0.755 236.011 0.030 0.170
z0 5 258 0.912 221.660 0.009 0.282
z0_5 0 258 0.024 168.605 0.691 0.693
z0_5 4 258 0.741 229.143 0.083 0.224
z0_5 5 258 0.902 218.767 0.032 0.304
z1 0 258 0.020 149.270 0.841 0.843
z1 4 258 0.694 215.604 0.188 0.329
z1 5 258 0.867 211.581 0.087 0.360
targetDecision <- subset(decisionTable, alternative == 5)
nullDecision <- subset(decisionTable, alternative == 0)

At zero effect, overallReject is the actual Type I error under the stated stopping policy. It can be below 0.025 when non-binding futility is followed. futilityStop is the probability of stopping early for futility; earlyStop includes both early efficacy and futility stopping. At 5 mmHg, the table shows whether the available maximum can sustain the target power for each rule. At 4 mmHg, it quantifies the consequences of an overoptimistic effect assumption.

For the design without futility, the exported futilityStop is NA because no futility rule is active. In this scenario there is no early stopping for futility; do not treat this entry as an estimated stopping probability.

With a common maximum of 258 patients, the z1 rule achieves only 86.7% power at 5 mmHg. The z0_5 rule retains 90.2% power and requires an expected 169 patients under the null, compared with 258 without futility. These figures make the recruitment benefit and the power trade-off explicit.

The z0_5 design is a candidate, not an automatically selected optimum. Compared with no futility stopping, it trades some probability of success at a common maximum for lower expected recruitment under small effects. A more demanding rule such as z1 may require a larger maximum to recover 90% power. The final choice depends on the acceptable risk of stopping an effective treatment, recruitment capacity, and the value of early termination.

Working with comparison objects

Generic functions and object access

The following methods complement the reporting workflow:

Function or operator Use in a planning workflow
compare(x, y) Start a comparison from planning objects or append to an existing comparison in place.
x %vs% y Create and immediately summarize a comparison; chain further objects or pipe the summary to plot().
print(x) Inspect the collection and selected observed ranges.
summary(x) Identify differing inputs, design settings, and results.
plot(x) or plot(summary(x)) Plot selected results against assumptions or stages.
as.data.frame(x) Export the full unrounded comparison table.
names(x), length(x) Inspect scenario names and the number of contained objects.
getObjects(x) Retrieve the list of contained objects.
fetch(x, ...) Retrieve objects by name or position, including several selections.
x[[i]], x[["name"]], x$name Access a contained object directly.
add(x, ...), delete(x, index) Extend a comparison or remove one object in place.

For example, build a shortlist without altering the collection of all fixed-design scenarios:

names(fixedPlans)
[1] "sd12_equal" "sd15_equal" "sd12_2to1" 
length(fixedPlans)
[1] 3
names(getObjects(fixedPlans))
[1] "sd12_equal" "sd15_equal" "sd12_2to1" 
identical(fixedPlans$sd12_equal, fixedPlans[["sd12_equal"]])
[1] TRUE
identical(fetch(fixedPlans, 1), fixedPlans[[1]])
[1] TRUE
shortlist <- getComparison()
shortlist |> add(objects = fixedPlans |>
    fetch(c("sd12_equal", "sd15_equal"), output = "list"))

Sample size calculation comparison

2 objects; 8 comparison rows; 25 columns.

Object types

  • Sample size means: 2

Observed metrics (across objects, stages and situations)

  • Maximum number of stages: 1
  • Significance level: 0.025
  • Type II error rate: 0.1
  • Number of subjects fixed: 125.4680, 592.9699

Available operations

  • summary(x): Compare differences
  • as.data.frame(x): Access all data
  • plot(x, xAxis = …, yAxis = …): Plot selected parameters
  • getObjects(x): Access contained objects
shortlist |>
    add(sd12_2to1 = fixedPlans[["sd12_2to1"]]) |>
    delete("sd15_equal")

Sample size calculation comparison

2 objects; 8 comparison rows; 25 columns.

Object types

  • Sample size means: 2

Observed metrics (across objects, stages and situations)

  • Maximum number of stages: 1
  • Significance level: 0.025
  • Type II error rate: 0.1
  • Number of subjects fixed: 125.4680, 427.4805

Available operations

  • summary(x): Compare differences
  • as.data.frame(x): Access all data
  • plot(x, xAxis = …, yAxis = …): Plot selected parameters
  • getObjects(x): Access contained objects
names(shortlist)
[1] "sd12_equal" "sd12_2to1" 

Comparisons retain references to their contained objects. add(), delete(), and compare() with an existing comparison modify it in place; assigning it to another variable does not create an independent collection. Construct a new comparison, as above, to make a separate shortlist. The contained plans are still shared. Existing summaries are snapshots, so call summary() again after changing a comparison. R6 member names take precedence with $; use [["name"]] if a scenario name collides with a method name.

Using the results for a design decision

The fixed-design comparison exposes the cost of uncertainty in effect and variability before committing to a sample size. The subsequent power comparison quantifies what happens if the selected assumptions do not hold. For the sequential trial, the equal-power sample size comparison and the common-budget power comparison answer complementary questions: the first establishes recruitment requirements, and the second shows the consequences of choosing different stopping rules within a feasible maximum.

Start directly from a planning object with |> compare(), or create a named collection with getComparison() and extend it with |> add() as scenarios become available. Use fetch() to select scenarios and delete() to refine the collection. Use print() for an initial overview, summary() to verify the intended differences, plots to examine sensitivity, and selected data-frame columns to document the decision. Record the chosen effect, standard deviation, allocation, integer sample sizes, analysis timing, and stopping policy together with the resulting power and expected recruitment.

For further background, see planning trials with a continuous endpoint and specifying futility bounds on different scales.