Learn R Programming

rpact

rpact is an R package for planning, simulating, and analyzing confirmatory clinical trials. It supports common tasks such as sample size and power calculations for standard fixed-sample trials, as well as classical group sequential designs with interim analyses. Methods are available for continuous, binary, survival (time-to-event), and count data endpoints.

For innovative trial designs, rpact provides simulation-based evaluation of power and other operating characteristics, multi-stage adaptive hypothesis tests based on the combination testing principle, adaptive sample size or event-number reassessment, multi-arm multi-stage (MAMS) designs, and population enrichment designs. This allows users to start with routine trial planning and use the same package for more advanced adaptive methods when needed.

What rpact can do

rpact covers the main steps of confirmatory trial planning, simulation, and analysis:

Sample size and power planning

  • Standard fixed-sample designs without interim analyses
  • Classical group sequential designs with planned interim analyses
  • Sample size and power calculations for
    • means (continuous endpoints)
    • rates (binary endpoints)
    • survival (time-to-event) endpoints with flexible recruitment and survival-time options
    • count data endpoints

Simulation and adaptive trial design

  • Power and operating-characteristic simulations for means, rates, survival data, and count data
  • Assessment of adaptive sample size or event-number reassessment based on conditional power
  • Multi-stage adaptive hypothesis testing based on the combination testing principle
  • Assessment of treatment selection strategies in multi-arm trials, including multi-arm multi-stage (MAMS) settings for means, rates, and survival endpoints
  • Simulation and analysis methods for population enrichment designs with means, rates, and hazard ratios

Analysis and trial conduct

  • Confirmatory analysis for means and rates in one-arm and two-arm trials, and for survival endpoints in treatment comparisons
  • Multi-arm and population enrichment analysis for means, rates, and survival endpoints
  • Analysis of general estimates and standard errors supplied through getDataset(est = ..., se = ...)
  • Support for fixed-sample designs, classical group sequential designs, and adaptive multi-arm multi-stage (MAMS) designs based on the inverse normal or Fisher combination test
  • Automatic boundary recalculation during a trial using alpha-spending approaches, including under- and over-running

Installation

Install the latest stable release from CRAN:

install.packages("rpact")

Development version

To try features that are not yet available in the CRAN release, install the development version of rpact from GitHub:

# install.packages("pak")
pak::pak("rpact-com/rpact")

Documentation

Package information and tutorials are available at www.rpact.org. For function arguments, return values, and examples, see the function reference.

Vignettes

Step-by-step examples and tutorials are available in the rpact vignettes at www.rpact.org/vignettes.

Quick start

A simple sample size calculation

This deliberately simple example illustrates a basic sample size calculation with rpact.

Suppose a study compares two treatments for high blood pressure. We expect the new treatment to lower systolic blood pressure by 15 mmHg on average, compared with 10 mmHg under standard treatment—a difference of 5 mmHg. We assume a standard deviation of 12 mmHg in each group. These numbers are illustrative assumptions, not recommendations for a clinical study.

How many participants are needed in two equally sized groups to detect this difference with 80% power?

library(rpact)

getSampleSizeMeans(
    groups = 2, # Two treatment groups
    alternative = 5, # Expected difference: 15 - 10 mmHg
    stDev = 12, # Assumed standard deviation in each group
    alpha = 0.05, # 5% significance level
    beta = 0.20, # 80% power
    sided = 2 # Two-sided test
) |>
    summary()

Sample size calculation for a continuous endpoint

Fixed sample analysis, two-sided significance level 5%, power 80%. The results were calculated for a two-sample t-test, H0: mu(1) - mu(2) = 0, H1: effect = 5, standard deviation = 12.

StageFixed
Stage level (two-sided)0.0500
Efficacy boundary (z-value scale)1.960
Lower efficacy boundary (t)-3.503
Upper efficacy boundary (t)3.503
Number of subjects182.8

Legend:

  • (t): treatment effect scale

This example uses a conventional two-sided test at the 5% significance level, without interim analyses. The calculated total sample size is approximately 183 participants. Rounding up to equally sized groups gives 92 participants per group, before allowing for missing data or dropouts. Power of 80% means an 80% chance of detecting the assumed difference if it truly exists under the planning assumptions.

A more advanced example: adding an interim analysis

We now make the study objective more explicit: we want to demonstrate that the new treatment lowers blood pressure more than the standard treatment. We therefore use a one-sided test at the 2.5% significance level, a common choice for confirmatory superiority trials. The direction of benefit is specified before the study begins. Blood pressure reductions are recorded as positive values, so alternative = 5 represents the expected additional reduction with the new treatment.

We keep the same illustrative assumptions and 80% power, but add one interim analysis, when approximately half of the total statistical information is available. If the evidence is sufficiently strong, the study can stop early for efficacy. Otherwise, it continues to the final analysis.

Simply testing twice at the usual significance level would increase the chance of a false-positive conclusion. A group sequential design accounts for both analyses. Here, we use O’Brien–Fleming boundaries, which require particularly strong evidence to stop early.

getDesignGroupSequential(
    kMax = 2, # One interim and one final analysis
    informationRates = c(0.5, 1), # 50% information at interim, 100% at final
    typeOfDesign = "OF", # O'Brien–Fleming boundaries
    alpha = 0.025, # One-sided 2.5% significance level
    beta = 0.20, # 80% power
    sided = 1 # One-sided test
) |>
    getSampleSizeMeans(
        groups = 2, # Two treatment groups
        alternative = 5, # Additional blood pressure reduction (mmHg)
        stDev = 12 # Assumed standard deviation (mmHg)
    ) |>
    summary()

Sample size calculation for a continuous endpoint

Sequential analysis with a maximum of two looks (group sequential design), one-sided overall significance level 2.5%, power 80%. The results were calculated for a two-sample t-test, H0: mu(1) - mu(2) = 0, H1: effect = 5, standard deviation = 12.

Stage12
Planned information rate50%100%
Cumulative alpha spent0.00260.0250
Stage levels (one-sided)0.00260.0240
Efficacy boundary (z-value scale)2.7971.977
Efficacy boundary (t)7.1693.520
Cumulative power0.20960.8000
Number of subjects92.1184.2
Expected number of subjects164.9
Stopping probability0.2096
Efficacy stopping probability by stage (under H0)0.0026
Efficacy stopping probability by stage0.2096

Legend:

  • (t): treatment effect scale

The output shows the planned cumulative sample sizes and the efficacy boundaries at each analysis. Allowing an early stop usually requires a slightly larger maximum sample size than a corresponding study without interim analyses, but may reduce the number of participants actually needed.

This is an illustration of the workflow; a clinical study requires additional planning, including the timing and conduct of the interim analysis.

Issues and Feature Requests

If you find a bug or would like to suggest an improvement, please use the rpact GitHub issue tracker.

Copy Link

Version

Install

install.packages('rpact')

Monthly Downloads

4,432

Version

5.0.0

License

LGPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Friedrich Pahlke

Last Published

November 16th, 2026

Functions in rpact (5.0.0)

ConditionalPowerResults

Conditional Power Results
ConditionalPowerResultsRates

Conditional Power Results Rates
ConditionalPowerResultsSurvival

Conditional Power Results Survival
ClosedCombinationTestResults

Analysis Results Closed Combination Test
AnalysisResultsMultiHypotheses

Basic Class for Analysis Results Multi-Hypotheses
ConditionalPowerResultsEnrichmentRates

Conditional Power Results Enrichment Rates
AnalysisResultsMultiArmFisher

Analysis Results Multi-Arm Fisher
AnalysisResultsMultiArmInverseNormal

Analysis Results Multi-Arm Inverse Normal
FieldSet

Field Set
DatasetSurvival

Dataset of Survival Data
EventProbabilities

Event Probabilities
ConditionalPowerResultsMeans

Conditional Power Results Means
FisherInformation

Fisher Information
PlotSettings

Plot Settings
PiecewiseSurvivalTimeMultiGroup

Piecewise Survival Times for Multiple Groups
NumberOfSubjects

Number Of Subjects
DatasetMeans

Dataset of Means
ParameterSet

Parameter Set
DatasetRates

Dataset of Rates
InstallationQualificationResult

Installation Qualification Result Object
SimulationResults

Class for Simulation Results
MarkdownReporter

Markdown Reporter for Test Results
PowerAndAverageSampleNumberResult

Power and Average Sample Number Result
DatasetGeneral

Dataset of General Estimates
PiecewiseSurvivalTimeEnrichment

Piecewise Exponential Survival Time for Population Enrichment
ConditionalPowerResultsEnrichmentMeans

Conditional Power Results Enrichment Means
Dataset

Dataset
SimulationResultsRates

Class for Simulation Results Rates
SimulationResultsMultiArmSurvival

Class for Simulation Results Multi-Arm Survival
SimulationResultsBaseSurvival

Common Survival Simulation Results
PiecewiseSurvivalTimeMultiArm

Piecewise Exponential Survival Time for Multiple Treatment Arms
SimulationResultsMultiArmMeans

Class for Simulation Results Multi-Arm Means
PerformanceScore

Performance Score
SimulationResultsSurvival

Class for Simulation Results Survival
PiecewiseSurvivalTime

Piecewise Exponential Survival Time
StageResultsMultiArmRates

Stage Results Multi Arm Rates
StageResults

Basic Stage Results
SimulationResultsMultiArmRates

Class for Simulation Results Multi-Arm Rates
SimulationResultsEnrichmentRates

Class for Simulation Results Enrichment Rates
SimulationResultsEnrichmentMeans

Class for Simulation Results Enrichment Means
SimulationResultsCountData

Class for Simulation Results Count Data
StageResultsEnrichmentRates

Stage Results Enrichment Rates
StageResultsEnrichmentMeans

Stage Results Enrichment Means
StageResultsMeans

Stage Results of Means
SimulationResultsEnrichmentSurvival

Class for Simulation Results Enrichment Survival
add

Add Objects to a Collection
StageResultsMultiArmMeans

Stage Results Multi Arm Means
TrialComparisonSummary

Summary of a Trial Comparison
TrialComparison

Trial Comparison
SummaryFactory

Summary Factory
StageResultsMultiArmSurvival

Stage Results Multi Arm Survival
TrialDesign

Basic Trial Design
StageResultsSurvival

Stage Results of Survival Data
TrialDesignPlanMeans

Trial Design Plan Means
StageResultsRates

Stage Results of Rates
as.data.frame.TrialDesignSet

Coerce Trial Design Set to a Data Frame
TrialDesignSet

Class for trial design sets.
TrialDesignPlanSurvival

Trial Design Plan Survival
as.data.frame.PiecewiseSurvivalTimeMultiGroup

Coerce a Multi-Group Piecewise Survival Specification to a Data Frame
as.data.frame.AnalysisResults

Coerce AnalysisResults to a Data Frame
as.matrix.FieldSet

Coerce Field Set to a Matrix
StageResultsGeneral

Stage Results of General Estimates
as.data.frame.ParameterSet

Coerce Parameter Set to a Data Frame
TrialDesignConditionalDunnett

Conditional Dunnett Design
TrialDesignInverseNormal

Inverse Normal Design
TrialDesignGroupSequential

Group Sequential Design
TrialDesignCharacteristics

Trial Design Characteristics
StageResultsEnrichmentSurvival

Stage Results Enrichment Survival
as.data.frame.TrialDesignCharacteristics

Coerce TrialDesignCharacteristics to a Data Frame
as.data.frame.TrialDesignPlan

Coerce Trial Design Plan to a Data Frame
TrialDesignPlanRates

Trial Design Plan Rates
dataEnrichmentMeans

Enrichment Dataset of Means
as.data.frame.PowerAndAverageSampleNumberResult

Coerce Power And Average Sample Number Result to a Data Frame
as251Normal

Algorithm AS 251: Normal Distribution
as251StudentT

Algorithm AS 251: Student T Distribution
delete

Delete an Object from a Collection
dataEnrichmentMeansStratified

Stratified Enrichment Dataset of Means
disableStartupMessages

Disable Startup Messages
dataEnrichmentRatesStratified

Stratified Enrichment Dataset of Rates
dataEnrichmentSurvivalStratified

Stratified Enrichment Dataset of Survival Data
as.data.frame.StageResults

Coerce Stage Results to a Data Frame
dataEnrichmentSurvival

Enrichment Dataset of Survival Data
SimulationResultsMeans

Class for Simulation Results Means
getClosedConditionalDunnettTestResults

Get Closed Conditional Dunnett Test Results
getClosedCombinationTestResults

Get Closed Combination Test Results
dataEnrichmentRates

Enrichment Dataset of Rates
dataRates

One-Arm Dataset of Rates
.addExpectedDropoutProportions

Add Expected Dropout Proportions to a Survival Design Plan
.getDropoutIncidence

Calculate Competing-Risk Dropout Incidence
TrialDesignFisher

Fisher Design
dataSurvival

One-Arm Dataset of Survival Data
obtain

Extract a single parameter
[[.TrialComparison

Access Objects in a Trial Comparison
checkInstallationQualificationStatus

Check Installation Qualification Status
TrialDesignPlan

Basic Trial Design Plan
TrialDesignFixed

Fixed Design
getComparisonParameterNames

Select Comparison Parameters
compare

Start or Extend a Trial Comparison
fetch.TrialComparison

Fetch Objects from a Trial Comparison
getAccrualTime

Get Accrual Time
TrialDesignPlanCountData

Trial Design Plan Count Data
dataMultiArmMeans

Multi-Arm Dataset of Means
dataMeans

One-Arm Dataset of Means
.getDropoutProportionsGroupwise

Average Dropout Incidence over Accrued Subjects
getData

Get Simulation Data
getComparisonPlotParameters

Select Parameters for a Comparison Plot
getDataset

Get Dataset
enableStartupMessages

Enable Startup Messages
as.data.frame.TrialComparison

Trial Comparison Data Frame
dataMultiArmRates

Multi-Arm Dataset of Rates
as.data.frame.TrialDesign

Coerce TrialDesign to a Data Frame
getAnalysisResults

Get Analysis Results
dataMultiArmSurvival

Multi-Arm Dataset of Survival Data
getDesignConditionalDunnett

Get Design Conditional Dunnett Test
getDesignCharacteristics

Get Design Characteristics
plotTypes

Get Available Plot Types
getFisherInformation

Get Fisher Information From a Design Plan or Simulation Results
getDesignGroupSequential

Get Design Group Sequential
getDesignInverseNormal

Get Design Inverse Normal
getComparisonParameterDescriptions

Describe Comparison Parameters
getEventProbabilities

Get Event Probabilities
getDesignSet

Get Design Set
getComparison

Compare Existing Trial Planning Objects
getLongFormat

Get Long Format
getLogLevel

Get Log Level
getFinalConfidenceInterval

Get Final Confidence Interval
getFinalPValue

Get Final P Value
getConditionalPower

Get Conditional Power
getConditionalRejectionProbabilities

Get Conditional Rejection Probabilities
getDesignFisher

Get Design Fisher
getGroupSequentialProbabilities

Get Group Sequential Probabilities
getDesignFixed

Get Fixed Design
getPiecewiseSurvivalTimeEnrichment

Piecewise Exponential Enrichment Survival Time
getPiecewiseSurvivalTime

Get Piecewise Survival Time
getLambdaStepFunction

Get Lambda Step Function
getObjects

Get Objects from a Collection
getObservedInformationRates

Get Observed Information Rates
getFutilityBounds

Get Futility Bounds
rcmd

Get Object R Code
getPiecewiseSurvivalTimeMultiArm

Piecewise Exponential Multi-Arm Survival Time
getNumberOfSubjects

Get Number Of Subjects
getOutputFormat

Get Output Format
getParameterName

Get Parameter Name
getPlotSettings

Get Plot Settings
getParameterType

Get Parameter Type
getPowerSurvival

Get Power Survival
getSampleSizeRates

Get Sample Size Rates
getPerformanceScore

Get Performance Score
getPiecewiseHazardRatioArray

Create an Array of Piecewise Hazard Ratios
getPowerMeans

Get Power Means
getSampleSizeMeans

Get Sample Size Means
getSampleSizeCounts

Get Sample Size Counts
getSampleSizeSurvival

Get Sample Size Survival
getRawData

Get Simulation Raw Data for Survival
getPowerRates

Get Power Rates
getParameterCaption

Get Parameter Caption
getRepeatedConfidenceIntervals

Get Repeated Confidence Intervals
getPowerAndAverageSampleNumber

Get Power And Average Sample Number
getPowerCounts

Get Power Counts
getRepeatedPValues

Get Repeated P Values
AnalysisResultsFisher

Analysis Results Fisher
AccrualTime

Accrual Time
AnalysisResultsEnrichmentFisher

Analysis Results Enrichment Fisher
AnalysisResultsEnrichmentInverseNormal

Analysis Results Enrichment Inverse Normal
AnalysisResultsGroupSequential

Analysis Results Group Sequential
AnalysisResultsInverseNormal

Analysis Results Inverse Normal
AnalysisResultsEnrichment

Basic Class for Analysis Results Enrichment
AnalysisResultsConditionalDunnett

Analysis Results Multi-Arm Conditional Dunnett
AnalysisResultsMultiArm

Basic Class for Analysis Results Multi-Arm
AnalysisResults

Basic Class for Analysis Results