Skip to content

Commit

Permalink
update documentation & function names
Browse files Browse the repository at this point in the history
  • Loading branch information
tdebray123 committed Nov 9, 2024
1 parent 3545c2e commit 0b88528
Show file tree
Hide file tree
Showing 21 changed files with 65 additions and 48 deletions.
4 changes: 2 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ importFrom(Rcpp, evalCpp)
exportPattern("^[[:alpha:]]+")
S3method(plot,simss)
S3method(print,simss)
export(N_Mielke)
export(estSampleSize)
export(sampleSize_Mielke)
export(sampleSize)
export(get_par)
export(plot.simss)
importFrom(data.table,.SD)
34 changes: 17 additions & 17 deletions R/estSampleSize.R → R/SampleSize.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#' @param sigma_list list of sigma vectors, each element corresponds to a comparator with a sigma vector of size number of endpoints.
#' @param cor_mat matrix specifying the correlation matrix between endpoints, used along with sigma_list to calculate the varcov list in case it is not provided.
#' @param sigmaB number between subject variance only for 2x2 design.
#' @param Eper vector of size 2, effect of period on c(0,1).
#' @param Eco vector of size 2, carry over effect of arm c(Reference, Treatment).
#' @param Eper Vector of length 2, specifying the period effect in `dtype = "2x2"` design, applied to c(Period 0, Period 1).
#' @param Eco Vector of length 2, specifying the carry-over effect for each arm in `dtype = "2x2"` design, applied to c(Reference, Treatment).
#' @param rho Correlation parameter applied uniformly across all endpoint pairs, used with sigma_list to calculate varcov if cor_mat or varcov_list are not provided.
#' @param TAR vector of allocation rates with allocation rates of the arm, default is equivalent rate.
#' @param arm_names Optional vector with the treatment names. If not supplied, it will be derived from mu_list.
Expand Down Expand Up @@ -81,7 +81,7 @@
#' FDA = c("AUClast", "Cmax"))
#'
#'# Run the simulation
#'estSampleSize(power = 0.9, # target power
#'sampleSize(power = 0.9, # target power
#' alpha = 0.05,
#' mu_list = mu_list,
#' sigma_list = sigma_list,
Expand All @@ -99,14 +99,8 @@
#' seed = 1234)
#'
#' @export
estSampleSize <- function(mu_list,
varcov_list=NA,
sigma_list=NA,
cor_mat=NA,
sigmaB =NA,
Eper = c(0,0),
Eco = c(0,0),
rho=0,
sampleSize <- function(mu_list, varcov_list=NA, sigma_list=NA, cor_mat=NA,
sigmaB =NA, Eper = c(0,0), Eco = c(0,0), rho=0,
TAR=NA,
arm_names=NA,
ynames_list=NA,
Expand Down Expand Up @@ -458,14 +452,20 @@ estSampleSize <- function(mu_list,
}


if(dtype=="parallel"){
if(length(arm_names)!=length(dropout)){
warning("Incorrect number of dropout supplied (One needed for each arm),so it will be assigned a dropout=0")
if (dtype == "parallel") {
if (length(arm_names) != length(dropout)) {
warning("The number of dropout values provided does not match the number of arms specified in 'arm_names'. A default dropout rate of 0 will be assigned to each arm.")
dropout <- rep(0,length(arm_names))
}
if(is.null(names(dropout))){
names(dropout) <- arm_names}
}else{
if (is.null(names(dropout))) {
names(dropout) <- arm_names
}

# Check if dtype is "parallel" and Eper or Eco are non-default
if ((any(Eper != c(0, 0)) || any(Eco != c(0, 0)))) {
warning("Eper and Eco are only applicable for dtype = '2x2'. Non-default values for Eper or Eco will be ignored in parallel design.")
}
} else {
if(length(dropout)!=2){
warning("Incorrect number of dropout supplied (One needed for each sequence),so it will be assigned a dropout=0")
dropout <- rep(0,2)
Expand Down
2 changes: 1 addition & 1 deletion R/SimTOST-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
#' @title Sample Size Estimation via Simulation
#' @references
#' Mielke, J., Jones, B., Jilma, B. & König, F. Sample Size for Multiple Hypothesis Testing in Biosimilar Development. \emph{Statistics in Biopharmaceutical Research} 10, 39–49 (2018).
#' @seealso \link{estSampleSize}
#' @seealso \link{sampleSize}
"_PACKAGE"
2 changes: 1 addition & 1 deletion R/get_par.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#' @title Parameter Configuration for Endpoints and Comparators
#' @description Constructs and returns a list of key parameters (mean vectors, variance-covariance matrices, and allocation rates) required for input into the `estSampleSize` function. This function ensures that the parameters for each endpoint and comparator are consistent, properly named, and formatted.
#' @description Constructs and returns a list of key parameters (mean vectors, variance-covariance matrices, and allocation rates) required for input into the `sampleSize` function. This function ensures that the parameters for each endpoint and comparator are consistent, properly named, and formatted.
#'
#' @param mu_list A list of mean (\eqn{\mu}) vectors. Each element in the list represents a comparator, with the corresponding \eqn{\mu} vector having a length equal to the number of endpoints.
#' @param varcov_list A list of variance-covariance matrices. Each element corresponds to a comparator, with a matrix of size \eqn{(n \times n)}, where \eqn{n} is the number of endpoints.
Expand Down
13 changes: 11 additions & 2 deletions R/N_one_ep.r → R/sampleSize_Mielke.R
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,18 @@ power_dom <- function(seed, mu_test, mu_control, sigma_test, sigma_control,
#' \item{"power.a"}{Achieved power with the estimated sample size.}
#' \item{"SS"}{Required sample size per sequence to achieve the target power.}
#' }
#'
#' @examples
#' # Example 1 from Mielke
#' sampleSize_Mielke(power = 0.8, Nmax = 1000, m = 5, k = 5, rho = 0,
#' sigma = 0.3, true.diff = log(1.05), equi.tol = log(1.25),
#' design = "parallel", alpha = 0.05, adjust = "no",
#' seed = 1234, nsim = 100)
#'
#' @export
N_Mielke <- function(power, Nmax, m, k, rho, sigma, true.diff, equi.tol,
design, alpha, adjust="no", seed = NULL, nsim = 10000) {
sampleSize_Mielke <- function(power, Nmax, m, k, rho, sigma, true.diff,
equi.tol, design, alpha, adjust = "no",
seed = NULL, nsim = 10000) {

if (!is.null(seed)) {
set.seed(seed)
Expand Down
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ devtools::install_github("smartdata-analysis-and-statistics/SimTOST")

## Example

The main features of this package is `estSampleSize` function which can be used to calculate sample size for individual and multiple endpoints.
The main features of this package is `sampleSize` function which can be used to calculate sample size for individual and multiple endpoints.

The example of using the functionality of this package can be found in these vignettes:

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ devtools::install_github("smartdata-analysis-and-statistics/SimTOST")

## Example

The main features of this package is `estSampleSize` function which can be used
The main features of this package is `sampleSize` function which can be used
to calculate sample size for individual and multiple endpoints.

The example of using the functionality of this package can be found in
Expand Down
2 changes: 1 addition & 1 deletion man/SimTOST.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/get_par.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/power_Mielke.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/power_dom.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/print.simss.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions man/estSampleSize.Rd → man/sampleSize.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 12 additions & 4 deletions man/N_Mielke.Rd → man/sampleSize_Mielke.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/sign_Mielke.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/testthat/test-error_armnames.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# # Same treatment allocation rate
# TAR = c(1,1,1) # we assume same allocation rate in both arms
#
# expect_error(SimTOST::estSampleSize( mu_list = mu_list,
# expect_error(SimTOST::sampleSize( mu_list = mu_list,
# sigma_list = sigma_list,
# power = 0.9,
# dtype = "parallel",
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-error_dif_mu_cov_tar.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ test_that("differences across lenght of mu, varcov and tar", {
# Same treatment allocation rate
TAR = c(1,1) # we assume same allocation rate in both arms

expect_error(SimTOST::estSampleSize( mu_list = mu_list,
expect_error(SimTOST::sampleSize( mu_list = mu_list,
sigma_list = sigma_list,
varcov_list = NA,
TAR=TAR,
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-error_length_mu_sd.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ test_that("error difference lenght of mu and sigma", {
# Same treatment allocation rate
TAR = c(1,1,1) # we assume same allocation rate in both arms

expect_error(SimTOST::estSampleSize( mu_list = mu_list,
expect_error(SimTOST::sampleSize( mu_list = mu_list,
sigma_list = sigma_list,
varcov_list = NA,
power = 0.9,
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-error_log_dom.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# # Same treatment allocation rate
# TAR = c(1,1,1) # we assume same allocation rate in both arms
#
# expect_error(SimTOST::estSampleSize( mu_list = mu_list,
# expect_error(SimTOST::sampleSize( mu_list = mu_list,
# sigma_list = sigma_list,
# varcov_list = NA,
# TAR=TAR,
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-error_logf_rom_2x2.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# # Same treatment allocation rate
# TAR = c(1,1,1) # we assume same allocation rate in both arms
#
# expect_error(SimTOST::estSampleSize( mu_list = mu_list,
# expect_error(SimTOST::sampleSize( mu_list = mu_list,
# sigma_list = sigma_list,
# varcov_list = NA,
# TAR=TAR,
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-error_no_mu.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ test_that("error no mu_list provided", {
# Same treatment allocation rate
TAR = c(1,1,1) # we assume same allocation rate in both arms

expect_error(SimTOST::estSampleSize( mu_list = mu_list,
expect_error(SimTOST::sampleSize( mu_list = mu_list,
sigma_list = sigma_list,
varcov_list = NA,
power = 0.9,
Expand Down

0 comments on commit 0b88528

Please sign in to comment.