| Type: | Package |
| Title: | Sample Size Calculation for External Pilot Studies for a Continuous Endpoint |
| Version: | 1.0.0 |
| Description: | An implementation of sample size calculations for external pilot studies that minimize the overall trial sample size for the external pilot and main trial for a continuous endpoint as described in Whitehead et al. (2016) <doi:10.1177/0962280215588241>. |
| License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
| Encoding: | UTF-8 |
| URL: | https://github.com/joeldadiboe-rgb/ssPilot |
| BugReports: | https://github.com/joeldadiboe-rgb/ssPilot/issues |
| Imports: | ggplot2, rlang |
| Suggests: | quarto, testthat (≥ 3.0.0) |
| VignetteBuilder: | quarto |
| Config/testthat/edition: | 3 |
| Config/roxygen2/version: | 8.1.0 |
| NeedsCompilation: | no |
| Packaged: | 2026-09-18 14:28:08 UTC; joeld |
| Author: | Joel Dadiboe [aut, cre, cph], Marcio Diniz [aut, rev, cph] |
| Maintainer: | Joel Dadiboe <joeldadiboe@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-09-29 13:30:02 UTC |
Main trial sample size using the non-central t-distribution
Description
Calculates the required main-trial sample size per treatment arm using the non-central t-distribution (NCT) approach described by Julious and Owen.
Usage
nct_sample_size(
pilot_n,
sd,
effect,
power = 0.9,
alpha = 0.05,
allocation = 1,
max_n = 10000
)
Arguments
pilot_n |
Pilot trial sample size per treatment arm. |
sd |
Pilot estimate of the standard deviation. |
effect |
Expected treatment difference. |
power |
Desired statistical power. |
alpha |
Type I error rate. |
allocation |
Allocation ratio of experimental to control arm. |
max_n |
Maximum main-trial sample size per arm to search. |
Details
See also ssPilot::optimized_nct_sample_size.
Value
A list containing the pilot-trial sample size per arm, pilot-trial degrees of freedom, required main-trial sample size per arm, main-trial degrees of freedom, central t critical value, non-central t quantile, and the right-hand side of Equation (4).
References
Julious SA and Owen RJ. Sample size calculations for clinical studies allowing for uncertainty about the variance. Pharmaceut Stat 2006; 5: 29–37.
Examples
nct_sample_size(
pilot_n = 12,
sd = 1,
effect = 0.50,
power = 0.90,
alpha = 0.05
)
Optimize pilot sample size using the non-central t-distribution
Description
Determines the pilot-trial sample size per treatment arm that minimizes the total sample size required for the pilot and main trials using the non-central t-distribution (NCT) approach.
Usage
optimized_nct_sample_size(
sd,
effect,
power = 0.9,
alpha = 0.05,
allocation = 1,
min_pilot_n = 10,
max_pilot_n = 100,
max_main_n = 10000
)
Arguments
sd |
Anticipated standard deviation based on prior knowledge, previous studies, published literature, or other available evidence. |
effect |
Expected treatment difference. |
power |
Desired statistical power. |
alpha |
Type I error rate. |
allocation |
Allocation ratio of experimental to control arm. |
min_pilot_n |
Minimum pilot sample size per treatment arm. |
max_pilot_n |
Maximum pilot sample size per treatment arm. |
max_main_n |
Maximum main-trial sample size per treatment arm passed to [nct_sample_size()]. |
Details
The function evaluates a range of possible pilot sample sizes and calls [nct_sample_size()] for each candidate pilot size. The optimal pilot sample size is the one that minimizes the combined pilot and main-trial sample size per arm.
Value
A list containing:
- optimal_pilot_n_per_arm
Optimal pilot sample size per arm.
- main_n_per_arm
Required main-trial sample size per arm corresponding to the optimal pilot size.
- total_n_per_arm
Combined pilot and main-trial sample size per arm.
- pilot_degrees_of_freedom
Degrees of freedom from the pilot trial.
- main_degrees_of_freedom
Degrees of freedom from the main trial.
- critical_value
Critical value from the corresponding main-trial calculation.
- nct_quantile
Non-central t quantile from the corresponding calculation.
- equation_value
Sample-size equation value from the corresponding calculation.
- optimization_results
Data frame containing the results for all candidate pilot sample sizes.
References
Whitehead, A. L., Julious, S. A., Cooper, C. L., & Campbell, M. J. (2016). Estimating the sample size for a pilot randomised trial to minimise the overall trial sample size for the external pilot and main trial for a continuous outcome variable. Statistical Methods in Medical Research, 25(3), 1057–1073.
Examples
results <- optimized_nct_sample_size(
sd = 1,
effect = 0.50,
power = 0.90,
alpha = 0.05
)
plot(results)
Optimized pilot sample size using the UCL method
Description
Finds the pilot-trial sample size per treatment arm that minimizes the combined pilot and main-trial sample size using the upper confidence limit approach.
Usage
optimized_ucl_sample_size(
sd,
effect,
power = 0.9,
alpha = 0.05,
allocation = 1,
conf_level = 0.8,
min_pilot = 10,
max_pilot = 100
)
Arguments
sd |
Anticipated standard deviation based on prior knowledge, previous studies, published literature, or other available evidence. |
effect |
Expected treatment difference. |
power |
Desired statistical power for the main trial. |
alpha |
Type I error rate. |
allocation |
Allocation ratio of experimental to control arm. |
conf_level |
Confidence level for the upper confidence limit. |
min_pilot |
Minimum pilot sample size per treatment arm. |
max_pilot |
Maximum pilot sample size per treatment arm to search. |
Value
A list containing the optimal pilot sample size per arm, the corresponding main-trial sample size per arm, the total sample size per arm, the confidence level used, and a data frame containing the optimization results for all candidate pilot sample sizes.
References
Whitehead, A. L., Julious, S. A., Cooper, C. L., & Campbell, M. J. (2016). Estimating the sample size for a pilot randomised trial to minimise the overall trial sample size for the external pilot and main trial for a continuous outcome variable. Statistical Methods in Medical Research, 25(3), 1057–1073.
Examples
results <- optimized_ucl_sample_size(
sd = 1,
effect = 0.50,
power = 0.90,
alpha = 0.05,
conf_level = 0.80
)
plot(results)
Plot pilot and main-trial sample size relationship
Description
Creates a plot showing the relationship between pilot-trial sample size and the corresponding main-trial sample size from an optimized sample size calculation. The combination that minimizes the total sample size is highlighted.
Usage
## S3 method for class 'sspilot'
plot(x, ...)
Arguments
x |
A data frame containing the optimization results. It must contain columns named 'pilot_n_per_arm', 'main_n_per_arm', and 'total_n_per_arm'. |
... |
Additional arguments to be passed to methods. |
Value
A ggplot object showing pilot-trial sample size against main-trial sample size, with the optimal combination highlighted.
Examples
ucl_results <- optimized_ucl_sample_size(
sd = 1,
effect = 0.50,
power = 0.90,
alpha = 0.05
)
plot(ucl_results)
Standard sample size for a two-arm continuous outcome trial
Description
Calculates the required main-trial sample size per treatment arm assuming the population standard deviation is known.
Usage
standard_sample_size(sd, effect, power = 0.9, alpha = 0.05, allocation = 1)
Arguments
sd |
Population standard deviation. |
effect |
Expected treatment difference. |
power |
Desired statistical power. |
alpha |
Type I error rate. |
allocation |
Allocation ratio of experimental to control arm. |
Value
Required sample size per treatment arm.
Examples
standard_sample_size(
sd = 1,
effect = 0.5,
power = 0.90,
alpha = 0.05
)
Main trial sample size using the upper confidence limit method
Description
Calculates the required main-trial sample size per treatment arm using the upper confidence limit (UCL) approach described by Browne.
Usage
ucl_sample_size(
pilot_n,
sd,
effect,
power = 0.9,
alpha = 0.05,
allocation = 1,
conf_level = 0.8
)
Arguments
pilot_n |
Pilot trial sample size per treatment arm. |
sd |
Pilot estimate of the standard deviation. |
effect |
Expected treatment difference. |
power |
Desired statistical power. |
alpha |
Type I error rate. |
allocation |
Allocation ratio of experimental to control arm. |
conf_level |
Confidence level for the upper confidence limit. |
Details
Browne recommends an 80 level. However, Sim and Lewis, set X at 0.95 or the 95
Value
A list containing the degrees of freedom, upper confidence limit for the variance, upper confidence limit for the standard deviation, and main-trial sample size per treatment arm.
References
Browne RH. On the use of a pilot sample for sample size determination. Stat Med 1995; 14: 1933–1940.
Sim J and Lewis M. The size of a pilot study for a clinical should be calculated in relation to considerations of precision and efficiency. J Clin Epidemiol 2012; 65: 301–308.
Examples
ucl_sample_size(
pilot_n = 16,
sd = 1,
effect = 0.50,
power = 0.90,
alpha = 0.05,
conf_level = 0.80
)