Skip to content

Commit a642850

Browse files
committed
Update vignettes and documentation
1 parent aae96ec commit a642850

File tree

4 files changed

+48
-37
lines changed

4 files changed

+48
-37
lines changed

R/SampleSize.R

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,22 +71,26 @@
7171
#' lequi.tol <- c(AUCinf = 0.8, AUClast = 0.8, Cmax = 0.8)
7272
#' uequi.tol <- c(AUCinf = 1.25, AUClast = 1.25, Cmax = 1.25)
7373
#'
74-
#' # arms to be compared
74+
#' # Arms to be compared
7575
#' list_comparator <- list(EMA = c("SB2", "EUREF"),
7676
#' FDA = c("SB2", "USREF"))
7777
#'
78-
#'# Endpoints to be compared
79-
#'list_y_comparator <- list(EMA = c("AUCinf", "Cmax"),
80-
#' FDA = c("AUClast", "Cmax"))
78+
#' # Endpoints to be compared
79+
#' list_y_comparator <- list(EMA = c("AUCinf", "Cmax"),
80+
#' FDA = c("AUClast", "Cmax"))
8181
#'
82-
#'# Run the simulation
83-
#'sampleSize(power = 0.9, alpha = 0.05, mu_list = mu_list,
84-
#' sigma_list = sigma_list, lequi.tol = lequi.tol,
85-
#' uequi.tol = uequi.tol, list_comparator = list_comparator,
86-
#' list_y_comparator = list_y_comparator, adjust = "no",
87-
#' dtype = "parallel", ctype = "ROM", vareq = FALSE,
88-
#' lognorm = TRUE, ncores = 1, nsim = 50, seed = 1234)
82+
#' # Equivalence boundaries for each comparison
83+
#' lequi_lower <- c(AUCinf = 0.80, AUClast = 0.80, Cmax = 0.80)
84+
#' lequi_upper <- c(AUCinf = 1.25, AUClast = 1.25, Cmax = 1.25)
8985
#'
86+
#'# Run the simulation
87+
#' sampleSize(power = 0.9, alpha = 0.05, mu_list = mu_list,
88+
#' sigma_list = sigma_list, list_comparator = list_comparator,
89+
#' list_y_comparator = list_y_comparator,
90+
#' list_lequi.tol = list("EMA" = lequi_lower, "FDA" = lequi_lower),
91+
#' list_uequi.tol = list("EMA" = lequi_upper, "FDA" = lequi_upper),
92+
#' adjust = "no", dtype = "parallel", ctype = "ROM", vareq = FALSE,
93+
#' lognorm = TRUE, ncores = 1, nsim = 50, seed = 1234)
9094
#' @export
9195
sampleSize <- function(mu_list, varcov_list = NA, sigma_list = NA, cor_mat = NA,
9296
sigmaB =NA, Eper, Eco, rho = 0, TAR = NULL,

man/sampleSize.Rd

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

vignettes/sampleSize_crossover.Rmd

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ knitr::opts_chunk$set(echo = TRUE)
2020
knitr::opts_chunk$set(comment = "#>", collapse = TRUE)
2121
options(rmarkdown.html_vignette.check_title = FALSE) #title of doc does not match vignette title
2222
doc.cache <- T #for cran; change to F
23-
24-
library(dplyr)
2523
```
2624

2725

@@ -43,7 +41,6 @@ sigma <- c(AUC = 0.25, Cmax = 0.3)
4341
lequi_lower <- c(AUC = log(0.80), Cmax = log(0.80))
4442
lequi_upper <- c(AUC = log(1.25), Cmax = log(1.25))
4543
46-
4744
ss <- sampleSize(power = 0.8, alpha = 0.05,
4845
mu_list = list("R" = mu_r, "T" = mu_t),
4946
sigma_list = list("R" = sigma, "T" = sigma),
@@ -55,7 +52,7 @@ ss <- sampleSize(power = 0.8, alpha = 0.05,
5552
adjust = "no", ncores = 1, nsim = 10000, seed = 1234)
5653
ss
5754
```
58-
The total sample size is `r ss$response %>% pull(n_total)` subjects.
55+
The total sample size is `r ss$response$n_total` subjects.
5956

6057

6158

vignettes/sampleSize_parallel.Rmd

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ knitr::opts_chunk$set(echo = TRUE)
2020
knitr::opts_chunk$set(comment = "#>", collapse = TRUE)
2121
options(rmarkdown.html_vignette.check_title = FALSE) #title of doc does not match vignette title
2222
doc.cache <- T #for cran; change to F
23-
24-
library(dplyr)
2523
```
2624

2725

@@ -69,11 +67,14 @@ ss <- sampleSize(power = 0.8, alpha = 0.05,
6967
adjust = "no", ncores = 1, nsim = 10000, seed = 1234)
7068
ss
7169
```
72-
For 80\% power, a total of `r ss$response %>% pull(n_total)` would be required.
70+
For 80\% power, a total of `r ss$response$n_total` would be required.
7371

7472

7573
# Multiple Correlated Co-Primary Endpoints
76-
In the second example, we have $k=m=5$, $\sigma = 0.3$ and $\rho = 0.8$. Again, we can estimate the sample size using the functions provided by @mielke_sample_2018:
74+
In the second example, we have $k=m=5$, $\sigma = 0.3$ and $\rho = 0.8$. This example is also adapted from @mielke_sample_2018, who employed a difference-of-means test on the log scale. The sample size calculation can again be conducted using two approaches, both of which are illustrated below.
75+
76+
## Approach 1: Using sampleSize_Mielke
77+
In the first approach, we calculate the required sample size for 80% power using the [sampleSize_Mielke()](../reference/sampleSize_Mielke.html) function. This method directly follows the approach described in @mielke_sample_2018, assuming a difference-of-means test on the log-transformed scale with specified parameters.
7778

7879
```{r, eval = TRUE}
7980
ssMielke <- sampleSize_Mielke(power = 0.8, Nmax = 1000, m = 5, k = 5, rho = 0.8,
@@ -83,20 +84,25 @@ ssMielke <- sampleSize_Mielke(power = 0.8, Nmax = 1000, m = 5, k = 5, rho = 0.8,
8384
nsim = 10000)
8485
ssMielke
8586
```
86-
For 80\% power, `r ssMielke["SS"]` subjects per sequence (`r ssMielke["SS"] * 2` in total) would have been required.
87+
For 80\% power, `r ssMielke["SS"]` subjects per sequence (`r ssMielke["SS"] * 2` in total) would be been required.
8788

88-
We can perform the same analysis using [sampleSize()](../reference/sampleSize.html). In this case, we provide estimates for $\mu$ and $\sigma$ on the original scale, assuming they follow a normal distribution on the log scale (`lognorm = TRUE`). Instead of testing the difference of log-transformed means, we now test the ratio of the (untransformed) means.
89+
## Approach 2: Using sampleSize
90+
Alternatively, the sample size calculation can be performed using the [sampleSize()](../reference/sampleSize.html) function. This method assumes that effect sizes are normally distributed on the log scale and uses a difference-of-means test (`ctype = "DOM"`) with user-specified values for `mu_list`, `sigma_list`, and the correlation `rho`.
91+
92+
```{r}
93+
mu_r <- c(AUC = log(1.00), Cmax = log(1.00))
94+
mu_t <- c(AUC = log(1.02), Cmax = log(1.03))
95+
sigma <- c(AUC = 0.25, Cmax = 0.3)
96+
lequi_lower <- c(AUC = log(0.80), Cmax = log(0.80))
97+
lequi_upper <- c(AUC = log(1.25), Cmax = log(1.25))
8998
90-
```{r, eval = TRUE}
9199
ss <- sampleSize(power = 0.8, alpha = 0.05,
92-
mu_list = list("R" = rep(1.00, 5),
93-
"T" = rep(1.05, 5)),
94-
sigma_list = list("R" = rep(0.3, 5),
95-
"T" = rep(0.3, 5)),
100+
mu_list = list("R" = mu_r, "T" = mu_t),
101+
sigma_list = list("R" = sigma, "T" = sigma),
96102
rho = 0.8, # high correlation between the endpoints
97-
lequi.tol = rep(0.8, 5),
98-
uequi.tol = rep(1.25, 5),
99-
dtype = "parallel", ctype = "ROM", lognorm = TRUE,
103+
list_lequi.tol = list("T_vs_R" = lequi_lower),
104+
list_uequi.tol = list("T_vs_R" = lequi_upper),
105+
dtype = "parallel", ctype = "DOM", lognorm = FALSE,
100106
adjust = "no", ncores = 1, k = 5, nsim = 10000, seed = 1234)
101107
ss
102108
```

0 commit comments

Comments
 (0)