The zzpower package provides a Shiny application for conducting power analysis and sample size calculations for two-group parallel clinical trial designs.
Features
- Multiple Effect Size Methods: Support for Cohen’s d, percentage reductions, difference in change scores, and treatment group changes
-
Design Considerations: Accounts for dropout rates, drop-in rates, and unequal group allocation ratios
- Interactive Visualizations: Real-time power curves and detailed results tables
- Report Generation: Downloadable reports in PDF, HTML, or Word formats
- Advanced Settings: Configurable Type I error rates and one-sided vs two-sided testing
Installation
The development version may be installed of zzpower from GitHub with:
# install.packages('pak')
pak::pak('rgt47/zzpower')Usage
To launch the interactive application:
The application will open in the default web browser and provide an interactive interface for:
- Sample Size Planning: Set total sample size and expected dropout rates
- Effect Size Specification: Choose from multiple methods to specify the expected treatment effect
- Advanced Configuration: Adjust randomization ratios, Type I error rates, and testing approaches
- Results Visualization: View interactive power curves and detailed results tables
- Report Generation: Download reports in multiple formats
Effect Size Methods
The application supports four different approaches to specifying effect sizes:
- Standard Deviation Units (Cohen’s d): Direct specification of standardized effect sizes
-
Percent Reduction: Effect size specified as percentage reduction from placebo
- Difference in Change Scores: Absolute difference between treatment groups in outcome units
- Change in Active Group: Specifying the treatment group change directly
Example Workflow
- Launch the application with
launch_zzpower() - Set the total planned sample size using the slider
- Specify expected dropout rate
- Select the preferred effect size method
- Set the range of effect sizes to evaluate
- Review the power curve and identify the detectable effect size at 80% power
- Download a report documenting your power analysis
Dependencies
This package builds on several the following R packages:
-
shiny- Web application framework -
bslib- Bootstrap themes and components
-
bsicons- Bootstrap icons -
pwr- Power analysis calculations -
ggplot2- Data visualization -
DT- Interactive tables -
rmarkdown- Report generation
Supported Statistical Tests
The application includes 5 statistical tests via a scalable plugin architecture:
| Test | Use Case | Effect Size |
|---|---|---|
| Two-Group t-test | Parallel RCT designs | Cohen’s d, % reduction |
| Paired t-test | Before-after designs | Standardized difference |
| One-Sample t-test | Single-group vs reference | Cohen’s d |
| Two Proportions | Binary outcomes | Proportions, OR, RR |
| Correlation | Bivariate relationships | Correlation r |
Documentation
-
vignette("quickstart")- Quick start guide
Reproducibility
This package is developed using the zzcollab framework for reproducible research. To reproduce the development environment:
Author
Ronald (Ryy) G. Thomas (rgthomas@ucsd.edu)
