Bayesian Sample Size Determination
Technical documentation for sample size calculation in single-arm Bayesian trials with operating characteristics. This module determines the minimum sample size to achieve target power while controlling Type I error under a Bayesian decision framework.
Contents
1. Overview & Problem Setup
This calculator determines the sample size for a single-arm Bayesian trial comparing a response rate to a null hypothesis threshold using posterior probability as the decision criterion.
Design Setting
- Endpoint: Binary outcome (response/no response)
- Arms: Single-arm (no control group)
- Prior: Beta distribution (from Prior Elicitation module)
- Decision: Posterior probability criterion
Hypotheses
Null Hypothesis
Response rate is at or below an unacceptable threshold
Alternative Hypothesis
Response rate exceeds the threshold (drug is effective)
Typical Application: Oncology Phase II
A common scenario is testing whether a new therapy achieves a response rate significantly above the historical standard. For example: (null, historical rate) vs. (alternative, target rate).
2. Bayesian Decision Rule
The trial succeeds if the posterior probability that the response rate exceeds the null threshold exceeds a decision threshold:
Where is typically 0.95 or 0.975, analogous to one-sided frequentist significance levels of 0.05 or 0.025.
Posterior Computation
With a Beta prior and observed data successes in trials:
The decision probability is computed as:
Example Calculation
Prior: (mean 12%, ESS 50)
Observed: 25 responders out of 100 patients
Null threshold:
Posterior:
Posterior mean:
Decision: Success (99.98% > 95% threshold)
3. Operating Characteristics
Despite using a Bayesian decision rule, we evaluate the design using frequentist operating characteristics to satisfy regulatory requirements. This is computed via Monte Carlo simulation.
Type I Error Rate
Probability of declaring success when
Target: ≤ 0.05 (or 0.025 for confirmatory)
Power
Probability of declaring success when
Target: ≥ 0.80 (or 0.90 for pivotal)
Monte Carlo Simulation Algorithm
for simulation in 1...N_simulations:
# Under null hypothesis (θ = θ₀)
k_null = Binomial(n, θ₀)
posterior_prob_null = P(θ > θ₀ | k_null, n, prior)
if posterior_prob_null >= γ:
type1_count += 1
# Under alternative hypothesis (θ = θ₁)
k_alt = Binomial(n, θ₁)
posterior_prob_alt = P(θ > θ₀ | k_alt, n, prior)
if posterior_prob_alt >= γ:
power_count += 1
type1_error = type1_count / N_simulations
power = power_count / N_simulationsPrior Impact on Operating Characteristics
An informative prior can inflate Type I error if it's too optimistic, or reduce power if it's too skeptical. The calculator reports prior ESS and its contribution to the posterior to help assess prior influence.
4. Sample Size Search Algorithm
The algorithm searches for the minimum sample size that achieves target power while maintaining Type I error control using a grid search approach.
Search Strategy
- 1.Grid Search: Evaluate operating characteristics at
- 2.Constraint Check: At each , verify Type I error ≤ target AND power ≥ target
- 3.Selection: Return the smallest meeting both constraints. If none found, return the best trade-off (prioritizing Type I error control).
- 4.Sensitivity: Evaluate at for robustness
Search Output
The calculator returns the smallest satisfying both constraints, along with all evaluated sample sizes (for custom analysis) and sensitivity results at nearby sample sizes.
5. Power Curve Analysis
The power curve shows how the probability of declaring success varies with the true response rate. This is essential for understanding the design's operating characteristics across the parameter space.
Key Points on the Power Curve
| Point | True Rate | Interpretation |
|---|---|---|
| Type I Error | False positive rate at null | |
| Power at Design Alternative | Primary endpoint | |
| Crossover | where Power = 50% | Minimum detectable effect |
Interpreting the Power Curve
A steeper power curve indicates better discrimination between null and alternative. The curve should cross 50% somewhere between and , ideally closer to .
6. Sensitivity Analysis
The calculator provides sensitivity analysis across sample sizes near the recommendation to understand the robustness of the design.
Default Sensitivity Grid
Operating characteristics are computed at:
- (under-powered option)
- (recommended)
- (over-powered buffer)
Prior Sensitivity (Regulatory Requirement)
Per FDA guidance, sensitivity to prior specification should also be assessed. Consider re-running with an uninformative prior to understand the marginal benefit of the informative prior.
7. Regulatory Considerations
FDA Bayesian Guidance Requirements
The January 2026 FDA guidance mandates reporting of frequentist operating characteristics (Type I error and power) even for Bayesian designs to ensure proper error rate control.
SAP Documentation Checklist
- Prior Specification: Report , source, and ESS
- Decision Rule: State ,, and success criterion
- Sample Size: Report with operating characteristics
- Type I Error: Demonstrate control at ≤ 0.05 (or 0.025)
- Power: Report power at design alternative
- Sensitivity: Show robustness to prior and sample size
8. API Quick Reference
Key Parameters
| Parameter | Type | Description |
|---|---|---|
| prior_alpha, prior_beta | float | Beta prior parameters (from Prior Elicitation) |
| null_rate | float | Null hypothesis threshold θ₀ |
| alternative_rate | float | Design alternative θ₁ |
| decision_threshold | float | Posterior probability threshold γ (default: 0.95) |
| target_power | float | Target power (default: 0.80) |
Key Response Fields
recommended_n— Recommended sample sizeoperating_characteristics— Type I error and power at recommended nconstraints_met— Whether design meets error constraintspower_curve— Power across range of true rates