Skip to content

Commit da3ae30

Browse files
author
Thomas Debray
committed
Improve documentation
1 parent dc8f8be commit da3ae30

26 files changed

+496
-545
lines changed

DESCRIPTION

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Package: SimTOST
2-
Title: Sample size estimation for bioequivalence trials through simulation
2+
Title: Sample Size Estimation for Bioequivalence Trials Through Simulation
33
Version: 1.0.0
44
Authors@R: c(
55
person(given = "Thomas",
@@ -8,13 +8,13 @@ Authors@R: c(
88
role = c("aut", "cre"),
99
comment= c(ORCID = "0000-0002-1790-2719")),
1010
person(given = "Johanna",
11-
family = "Muñoz",
11+
family = "Munoz",
1212
email = "[email protected]",
1313
role = c("aut")),
1414
person(given = "Dewi",
1515
family = "Amaliah",
1616
email = "[email protected]",
17-
role = c("aut")),
17+
role = c("ctb")),
1818
person(given = "Wei",
1919
family = "Wei",
2020
email = "[email protected]",
@@ -23,9 +23,13 @@ Authors@R: c(
2323
family = "Mitroiu",
2424
email = "[email protected]",
2525
role = c("ctb")),
26+
person(given = "Scott",
27+
family = "McDonald",
28+
email = "[email protected]",
29+
role = c("ctb")),
2630
person("Biogen Inc", role = c("cph", "fnd"))
2731
)
28-
Description: SimTOST is an R package designed for bioequivalence studies, providing simulation-based sample size estimation for the Two One-Sided Tests (TOST) procedure. With flexible options for testing multiple hypotheses, treatments, and correlated endpoints, SimTOST enables robust planning of bioequivalence trials by accommodating complex study designs.
32+
Description: Conducts sample size estimation for bioequivalence studies using the Two One-Sided Tests (TOST) procedure. A simulation-based approach enables flexible hypothesis testing, supports multiple treatments, and accommodates correlated endpoints.
2933
License: Apache License 2.0
3034
Encoding: UTF-8
3135
Roxygen: list(markdown = TRUE)
@@ -48,5 +52,4 @@ Suggests:
4852
VignetteBuilder: knitr
4953
Config/testthat/edition: 3
5054
LinkingTo: Rcpp, RcppArmadillo
51-
URL: https://github.com/smartdata-analysis-and-statistics/SimTOST,
52-
https: //smartdata-analysis-and-statistics.github.io/SimTOST/
55+
URL: https://smartdata-analysis-and-statistics.github.io/SimTOST/

R/RcppExports.R

Lines changed: 72 additions & 106 deletions
Large diffs are not rendered by default.

R/SampleSize.R

Lines changed: 67 additions & 75 deletions
Large diffs are not rendered by default.

R/sampleSize_Mielke.R

Lines changed: 96 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,57 @@
1-
#' @title Simulated Test Statistic for Given Settings in Noninferiority/Equivalence Trials
2-
#'
3-
#' @description This function simulates test statistics for multiple hypothesis testing in the context of biosimilar development, using the approach described by Mielke et al. (2018). It calculates the necessary sample size for meeting equivalence criteria across multiple endpoints, considering correlation structures, and applying multiplicity adjustments.
4-
#'
5-
#' @details Following the methodology by Mielke et al. (2018), this function is designed for multiple endpoint clinical trials where success is defined as meeting equivalence criteria on at least a subset of tests. The function simulates test statistics based on multivariate normal distribution assumptions and supports k-out-of-m success criteria for regulatory approval. Additionally, Type I error control is achieved through multiplicity adjustments as proposed by Lehmann and Romano (2005) to ensure rigorous error rate management.
6-
#'
7-
#' The approach is particularly relevant for biosimilar studies where sample size estimation must account for multiple comparisons across endpoints, doses, or populations, as regulatory agencies often require equivalence across all relevant comparisons. This method provides a framework for estimating power and sample size, even when equivalence is not required on all endpoints.
8-
#'
9-
#' @param N Integer. The number of subjects per sequence.
10-
#' @param m Integer. The number of endpoints.
11-
#' @param k Integer. The number of endpoints that must be successful to consider the test a success.
12-
#' @param R Matrix. The correlation matrix between the endpoints (e.g., generated with the `variance.const.corr()` function), with dimensions m x m.
13-
#' @param sigma Numeric. The standard deviation of the endpoints. This can either be a vector of length m (one for each endpoint) or a single value. If a single value is provided, it is assumed that the standard deviation is constant across all endpoints. In the case of a 2x2 crossover design, the input is the within-subject variance; for a parallel group design, it represents the standard deviation in the treatment group, assumed identical for both test and reference groups.
14-
#' @param true.diff Numeric. The assumed true difference between the test and reference. This can be a vector of length m (one for each endpoint) or a single value.
15-
#' @param equi.tol Numeric. Equivalence margins, with the interval being (-equi.tol, +equi.tol).
16-
#' @param design Character. The study design, either "22co" for a 2x2 crossover design or "parallel" for a parallel groups design.
17-
#' @param alpha Numeric. The significance level.
18-
#' @param adjust Character. The method for multiplicity adjustment. Options are "no" for no adjustment, "bon" for Bonferroni correction, or "k" for k-adjustment.
1+
#' @title Simulated Test Statistic for Noninferiority/Equivalence Trials
2+
#'
3+
#' @description
4+
#' Simulates test statistics for multiple hypothesis testing in biosimilar development,
5+
#' following the approach described by Mielke et al. (2018). It calculates the necessary
6+
#' sample size for meeting equivalence criteria across multiple endpoints while
7+
#' considering correlation structures and applying multiplicity adjustments.
8+
#'
9+
#' @details
10+
#' This function is designed for multiple-endpoint clinical trials, where success
11+
#' is defined as meeting equivalence criteria for at least a subset of tests.
12+
#' Simulated test statistics are based on multivariate normal distribution assumptions,
13+
#' and the function supports k-out-of-m success criteria for regulatory approval.
14+
#'
15+
#' Type I error control is achieved through multiplicity adjustments as proposed by
16+
#' Lehmann and Romano (2005) to ensure rigorous error rate management. This approach
17+
#' is particularly relevant for biosimilar studies, where sample size estimation must
18+
#' account for multiple comparisons across endpoints, doses, or populations.
19+
#'
20+
#' @param N Integer specifying the number of subjects per sequence.
21+
#' @param m Integer specifying the number of endpoints.
22+
#' @param k Integer specifying the number of endpoints that must meet equivalence
23+
#' to consider the test successful.
24+
#' @param R Matrix specifying the correlation structure between endpoints.
25+
#' This should be an \code{m x m} matrix, e.g., generated using \code{variance.const.corr()}.
26+
#' @param sigma Numeric specifying the standard deviation of endpoints.
27+
#' Can be a vector of length \code{m} (one per endpoint) or a single value.
28+
#' In a 2x2 crossover design, this represents within-subject variance.
29+
#' In a parallel-group design, it represents the treatment group standard deviation.
30+
#' @param true.diff Numeric specifying the assumed true difference between test and reference.
31+
#' Can be a vector of length \code{m} or a single value.
32+
#' @param equi.tol Numeric specifying the equivalence margins.
33+
#' The interval is defined as \code{(-equi.tol, +equi.tol)}.
34+
#' @param design Character specifying the study design.
35+
#' Options are \code{"22co"} for a 2x2 crossover design or \code{"parallel"} for a parallel-group design.
36+
#' @param alpha Numeric specifying the significance level.
37+
#' @param adjust Character specifying the method for multiplicity adjustment.
38+
#' Options include \code{"no"} for no adjustment, \code{"bon"} for Bonferroni correction,
39+
#' and \code{"k"} for k-adjustment.
1940
#'
2041
#' @references
42+
#' Kong, L., Kohberger, R. C., & Koch, G. G. (2004). Type I Error and Power in
43+
#' Noninferiority/Equivalence Trials with Correlated Multiple Endpoints: An Example
44+
#' from Vaccine Development Trials. \emph{Journal of Biopharmaceutical Statistics, 14}(4), 893–907.
2145
#'
22-
#' Kong, L., Kohberger, R. C. & Koch, G. G. Type I Error and Power in Noninferiority/Equivalence Trials with Correlated Multiple Endpoints: An Example from Vaccine Development Trials. Journal of Biopharmaceutical Statistics 14, 893–907 (2004).
46+
#' Lehmann, E. L., & Romano, J. P. (2005). Generalizations of the Familywise Error Rate.
47+
#' \emph{The Annals of Statistics, 33}(2), 1138–1154.
2348
#'
24-
#' Lehmann, E. L. & Romano, J. P. Generalizations of the Familywise Error Rate. The Annals of Statistics 33, 1138–1154 (2005).
49+
#' Mielke, J., Jones, B., Jilma, B., & König, F. (2018). Sample Size for Multiple
50+
#' Hypothesis Testing in Biosimilar Development. \emph{Statistics in Biopharmaceutical Research, 10}(1), 39–49.
2551
#'
26-
#' Mielke, J., Jones, B., Jilma, B. & König, F. Sample Size for Multiple Hypothesis Testing in Biosimilar Development. Statistics in Biopharmaceutical Research 10, 39–49 (2018).
52+
#' @return
53+
#' A numeric vector representing a realization of the simulated test statistic for the given setting.
2754
#'
28-
#' @return A realization of the simulated test statistic for the given setting. If values are provided as a single number (constant for all endpoints), a vector is created.
2955
#'
3056
#' @keywords internal
3157
sign_Mielke <- function(N, m, k, R, sigma, true.diff, equi.tol = log(1.25),
@@ -69,25 +95,39 @@ sign_Mielke <- function(N, m, k, R, sigma, true.diff, equi.tol = log(1.25),
6995
return(dec = test.dec)
7096
}
7197

72-
#' @title Power Calculation for Hypothesis Testing Using Mielke's Method
73-
#' @description Calculate power of hypothesis testing using Mielke's
74-
#'
75-
#' @param N Integer. The number of subjects per sequence.
76-
#' @param m Integer. The number of endpoints.
77-
#' @param k Integer. The number of endpoints that must be successful to consider the test a success.
78-
#' @param R Matrix. The correlation matrix between the endpoints (e.g., generated with the `variance.const.corr()` function), with dimensions m x m.
79-
#' @param sigma Numeric. The standard deviation of the endpoints. This can either be a vector of length m (one for each endpoint) or a single value. If a single value is provided, it is assumed that the standard deviation is constant across all endpoints. In the case of a 2x2 crossover design, the input is the within-subject variance; for a parallel group design, it represents the standard deviation in the treatment group, assumed identical for both test and reference groups.
80-
#' @param true.diff Numeric. The assumed true difference between the test and reference. This can be a vector of length m (one for each endpoint) or a single value.
81-
#' @param equi.tol Numeric. Equivalence margins, with the interval being (-equi.tol, +equi.tol). Default is log(1.25).
82-
#' @param design Character. The study design, either "22co" for a 2x2 crossover design or "parallel" for a parallel groups design.
83-
#' @param alpha Numeric. The significance level. Default is 0.05.
84-
#' @param adjust Character. The method for multiplicity adjustment. Options are "no" for no adjustment, "bon" for Bonferroni correction, or "k" for k-adjustment.
85-
#' @param nsim Integer. The number of simulations to perform. Default is 10,000.
86-
#'
87-
#' @return Numeric. The estimated power based on the simulations.
98+
#' @title Power Calculation for Hypothesis Testing in Equivalence Trials
99+
#'
100+
#' @description
101+
#' Estimates the power of hypothesis testing in equivalence trials using
102+
#' the method described by Mielke et al. This approach accounts for multiple
103+
#' endpoints, correlation structures, and multiplicity adjustments.
104+
#'
105+
#' @param N Integer specifying the number of subjects per sequence.
106+
#' @param m Integer specifying the number of endpoints.
107+
#' @param k Integer specifying the number of endpoints that must meet equivalence
108+
#' to consider the test successful.
109+
#' @param R Matrix specifying the correlation structure between endpoints.
110+
#' This should be an \code{m x m} matrix, e.g., generated using \code{variance.const.corr()}.
111+
#' @param sigma Numeric specifying the standard deviation of endpoints.
112+
#' Can be a vector of length \code{m} (one per endpoint) or a single value.
113+
#' In a 2x2 crossover design, this represents within-subject variance.
114+
#' In a parallel-group design, it represents the treatment group standard deviation.
115+
#' @param true.diff Numeric specifying the assumed true difference between test and reference.
116+
#' Can be a vector of length \code{m} or a single value.
117+
#' @param equi.tol Numeric specifying the equivalence margins, with the interval defined as
118+
#' \code{(-equi.tol, +equi.tol)}. Default is \code{log(1.25)}.
119+
#' @param design Character specifying the study design.
120+
#' Options are \code{"22co"} for a 2x2 crossover design or \code{"parallel"} for a parallel-group design.
121+
#' @param alpha Numeric specifying the significance level. Default is \code{0.05}.
122+
#' @param adjust Character specifying the method for multiplicity adjustment.
123+
#' Options include \code{"no"} for no adjustment, \code{"bon"} for Bonferroni correction,
124+
#' and \code{"k"} for k-adjustment.
125+
#' @param nsim Integer specifying the number of simulations to perform. Default is \code{10,000}.
126+
#'
127+
#' @return
128+
#' A numeric value representing the estimated power based on the simulations.
88129
#'
89130
#' @keywords internal
90-
#'
91131
power_Mielke <- function(N, m, k, R, sigma, true.diff, equi.tol = log(1.25),
92132
design, alpha=0.05, adjust="no", nsim = 10000) {
93133
mean(replicate(nsim, sign_Mielke(N = N, m = m, k = k, R = R, sigma = sigma,
@@ -96,23 +136,23 @@ power_Mielke <- function(N, m, k, R, sigma, true.diff, equi.tol = log(1.25),
96136
adjust = adjust)))
97137
}
98138

99-
#' @title Power Calculation for Hypothesis Testing of Difference of Means (DOM)
100-
#'
101-
#' @description This function calculates the power of hypothesis testing for the difference of means (DOM) between two groups, using simulations to estimate the achieved power based on the provided parameters such as sample sizes, means, standard deviations, and significance level.
102-
#'
103-
#' @param seed Integer. A seed value for reproducibility of the simulations.
104-
#' @param mu_test Numeric. The arithmetic mean of the test group.
105-
#' @param mu_control Numeric. The arithmetic mean of the control group.
106-
#' @param sigma_test Numeric. The standard deviation of the test group.
107-
#' @param sigma_control Numeric. The standard deviation of the control group.
108-
#' @param N_test Integer. The sample size of the test group.
109-
#' @param N_control Integer. The sample size of the control group.
110-
#' @param alpha Numeric. The significance level for the hypothesis test. Default is 0.05.
111-
#' @param nsim Integer. The number of simulations to perform. Default is 10,000.
112-
#'
113-
#' @return Numeric. The estimated power based on the simulations.
114-
#'
115-
#' @keywords internal
139+
#' @title Power Calculation for Difference of Means (DOM) Hypothesis Test
140+
#'
141+
#' @description Computes the statistical power for testing the difference of means (DOM) between two groups using Monte Carlo simulations. The power is estimated based on specified sample sizes, means, standard deviations, and significance level.
142+
#'
143+
#' @param seed Integer. Seed for reproducibility.
144+
#' @param mu_test Numeric. Mean of the test group.
145+
#' @param mu_control Numeric. Mean of the control group.
146+
#' @param sigma_test Numeric. Standard deviation of the test group.
147+
#' @param sigma_control Numeric. Standard deviation of the control group.
148+
#' @param N_test Integer. Sample size of the test group.
149+
#' @param N_control Integer. Sample size of the control group.
150+
#' @param lb Numeric. Lower bound for the equivalence margin.
151+
#' @param ub Numeric. Upper bound for the equivalence margin.
152+
#' @param alpha Numeric. Significance level (default = 0.05).
153+
#' @param nsim Integer. Number of simulations (default = 10,000).
154+
#'
155+
#' @return Numeric. Estimated power (probability between 0 and 1).
116156
power_dom <- function(seed, mu_test, mu_control, sigma_test, sigma_control,
117157
N_test, N_control, lb, ub, alpha = 0.05, nsim = 10000) {
118158
set.seed(seed)

README.Rmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ devtools::install_github("smartdata-analysis-and-statistics/SimTOST")
4040

4141
## Vignettes
4242

43-
The main features of this package is `sampleSize` function which can be used to calculate sample size for individual and multiple endpoints. Various worked examples are available as [vignettes](https://smartdata-analysis-and-statistics.github.io/SimTOST), with an introduction provided at [Introduction](https://smartdata-analysis-and-statistics.github.io/SimTOST/articles/intropkg.html).
43+
The main features of this package is `sampleSize` function which can be used to calculate sample size for individual and multiple endpoints. Various worked examples are available as [vignettes](https://smartdata-analysis-and-statistics.github.io/SimTOST/), with an introduction provided at [Introduction](https://smartdata-analysis-and-statistics.github.io/SimTOST/articles/intropkg.html).
4444

4545

4646
| **Vignette** | **Design** | **Number of Arms** | **Number of Endpoints** |

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ devtools::install_github("smartdata-analysis-and-statistics/SimTOST")
4343
The main features of this package is `sampleSize` function which can be
4444
used to calculate sample size for individual and multiple endpoints.
4545
Various worked examples are available as
46-
[vignettes](https://smartdata-analysis-and-statistics.github.io/SimTOST),
46+
[vignettes](https://smartdata-analysis-and-statistics.github.io/SimTOST/),
4747
with an introduction provided at
4848
[Introduction](https://smartdata-analysis-and-statistics.github.io/SimTOST/articles/intropkg.html).
4949

man/SimTOST.Rd

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)