Thanks to visit codestin.com
Credit goes to github.com

Skip to content

gosukehommaEX/bbssr

Repository files navigation

bbssr: Blinded Sample Size Re-estimation for Binary Endpoints

CRAN_Status_Badge R-CMD-check downloads downloads

Overview

bbssr is a comprehensive R package designed for blinded sample size re-estimation (BSSR) in two-arm clinical trials with binary endpoints. Unlike traditional fixed-sample designs, BSSR allows for adaptive sample size adjustments during the trial while maintaining the statistical integrity and blinding of the study.

Key Features

  • Blinded Sample Size Re-estimation: Implement adaptive trial designs that adjust sample sizes based on pooled data without unblinding treatment assignments
  • Multiple Exact Statistical Tests: Support for five different exact statistical tests optimized for binary endpoints
  • Flexible Design Options: Choose between restricted, unrestricted, and weighted BSSR approaches
  • Comprehensive Power Analysis: Calculate exact power for both traditional and BSSR designs
  • High-Performance Computing: Optimized algorithms deliver significant speed improvements over existing packages
  • Validated Accuracy: Extensive validation confirms identical results to established packages (Exact, exact2x2) across multiple scenarios

Statistical Methods Supported

The package implements five exact statistical tests specifically designed for binary endpoints in clinical trials:

  1. Pearson chi-squared test ('Chisq') - One-sided exact test
  2. Fisher exact test ('Fisher') - Classical exact conditional test
  3. Fisher mid-p test ('Fisher-midP') - Less conservative alternative to Fisher exact
  4. Z-pooled exact unconditional test ('Z-pool') - Unconditional exact test with pooled variance
  5. Boschloo exact unconditional test ('Boschloo') - Most powerful unconditional exact test

Why Use BSSR?

Traditional clinical trials with fixed sample sizes often suffer from:

  • Inefficient resource allocation when initial assumptions are incorrect
  • Underpowered studies due to overly optimistic effect size estimates
  • Ethical concerns about continuing underpowered or overpowered trials

BSSR addresses these issues by:

  • Maintaining statistical validity through exact methods
  • Preserving blinding by using only pooled response rates
  • Optimizing sample sizes based on observed data
  • Improving trial efficiency while controlling Type I error

Installation

Install the released version from CRAN:

install.packages("bbssr")

Or install the development version from GitHub:

# install.packages("devtools")
devtools::install_github("gosukehommaEX/bbssr")

Quick Start

Basic Power Calculation

library(bbssr)

# Calculate power for a traditional design
power_traditional <- BinaryPower(
  p1 = 0.5,     # Response rate in treatment group
  p2 = 0.2,     # Response rate in control group  
  N1 = 40,      # Sample size in treatment group
  N2 = 40,      # Sample size in control group
  alpha = 0.025, # One-sided significance level
  Test = 'Fisher' # Statistical test
)

print(power_traditional)

Sample Size Calculation

# Calculate required sample size
sample_size <- BinarySampleSize(
  p1 = 0.5,           # Expected response rate in treatment group
  p2 = 0.2,           # Expected response rate in control group
  r = 1,              # Allocation ratio (1:1)
  alpha = 0.025,      # One-sided significance level
  tar.power = 0.8,    # Target power
  Test = 'Boschloo'   # Most powerful exact test
)

print(sample_size)

Blinded Sample Size Re-estimation

library(dplyr)

# BSSR with different design rules
bssr_result <- BinaryPowerBSSR(
  asmd.p1 = 0.45,      # Assumed response rate in treatment group
  asmd.p2 = 0.09,      # Assumed response rate in control group
  p = seq(0.1, 0.9, by = 0.1), # Range of pooled response rates
  Delta.A = 0.36,      # Assumed treatment effect
  Delta.T = 0.36,      # True treatment effect
  N1 = 24,             # Initial sample size in treatment group
  N2 = 24,             # Initial sample size in control group
  omega = 0.5,         # Fraction for interim analysis
  r = 1,               # Allocation ratio
  alpha = 0.025,       # Significance level
  tar.power = 0.8,     # Target power
  Test = 'Z-pool',     # Statistical test
  restricted = FALSE,   # Unrestricted design
  weighted = FALSE     # Non-weighted approach
)

head(bssr_result)

Advanced Example: Comparing BSSR Designs

library(bbssr)
library(dplyr)
library(ggplot2)

# Compare different BSSR approaches
power_comparison <- tibble(
  Rule = factor(
    c('Restricted', 'Unrestricted', 'Weighted'), 
    levels = c('Restricted', 'Unrestricted', 'Weighted')
  ),
  restricted = c(TRUE, FALSE, FALSE),
  weighted = c(FALSE, FALSE, TRUE)
) %>% 
  group_by_all() %>% 
  reframe(r = c(1, 2), N1 = c(24, 36), N2 = c(24, 18)) %>% 
  group_by_all() %>% 
  reframe(
    BinaryPowerBSSR(
      asmd.p1 = 0.45, asmd.p2 = 0.09, p = seq(0.1, 0.9, by = 0.01),
      Delta.A = 0.36, Delta.T = 0.36, N1, N2, omega = 0.5, r, 
      alpha = 0.025, tar.power = 0.8, Test = 'Z-pool', 
      restricted, weighted
    )
  ) %>% 
  mutate(
    Rule = factor(Rule, levels = c('Restricted', 'Unrestricted', 'Weighted')),
    Allocation = paste0('Allocation ratio = ', r, ':1')
  )

# Visualize the results
ggplot(power_comparison, aes(x = p, y = power.BSSR, color = Rule)) +
  geom_line(linewidth = 1.2) +
  facet_wrap(~Allocation) +
  geom_hline(yintercept = 0.8, color = 'gray', linetype = 'dashed') +
  labs(
    x = "Pooled Response Rate (θ)",
    y = "Power",
    title = "Power Comparison: BSSR Design Rules",
    subtitle = "Horizontal line shows target power = 0.8"
  ) +
  theme_minimal() +
  theme(legend.position = "bottom")

BSSR Design Comparison

The plot above demonstrates how different BSSR design rules perform across various pooled response rates. Key observations:

  • Weighted Design: Shows the most robust performance with consistent power across different pooled response rates
  • Unrestricted Design: Provides good flexibility while maintaining target power
  • Restricted Design: More conservative approach that ensures final sample size ≥ initial sample size
  • Allocation Ratios: Different allocation ratios (1:1 vs 2:1) show distinct power patterns

Key Functions

Function Purpose
BinaryPower() Calculate power for traditional fixed-sample designs
BinarySampleSize() Calculate required sample size for given power
BinaryPowerBSSR() Calculate power for BSSR designs
BinaryRR() Compute rejection regions for exact tests

Design Options for BSSR

Restricted Design (restricted = TRUE)

  • Conservative approach
  • Final sample size ≥ initially planned sample size
  • Maintains original study timeline

Unrestricted Design (restricted = FALSE)

  • Flexible approach
  • Allows both increases and decreases in sample size
  • Optimizes efficiency based on observed data

Weighted Design (weighted = TRUE)

  • Advanced approach
  • Uses weighted averaging across interim scenarios
  • Provides robust performance across different pooled response rates

Statistical Validity

All methods in bbssr maintain exact Type I error control at the specified α level. The package implements exact statistical tests rather than asymptotic approximations, ensuring validity even for small sample sizes commonly encountered in clinical trials.

Vignettes

For detailed examples and theoretical background, see:

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Author

Gosuke Homma


Note: This package is designed for use by statisticians and clinical researchers familiar with adaptive trial designs. For regulatory submissions, please consult with biostatisticians and regulatory affairs specialists to ensure compliance with relevant guidelines (FDA, EMA, etc.).

About

No description, website, or topics provided.

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Packages

No packages published

Languages