Skip to content

Commit 275826d

Browse files
author
Thomas Debray
committed
Revise documentation
1 parent da3ae30 commit 275826d

File tree

5 files changed

+55
-48
lines changed

5 files changed

+55
-48
lines changed

DESCRIPTION

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Authors@R: c(
66
family = "Debray",
77
email = "[email protected]",
88
role = c("aut", "cre"),
9-
comment= c(ORCID = "0000-0002-1790-2719")),
9+
comment = c(ORCID = "0000-0002-1790-2719")),
1010
person(given = "Johanna",
1111
family = "Munoz",
1212
email = "[email protected]",
@@ -30,25 +30,25 @@ Authors@R: c(
3030
person("Biogen Inc", role = c("cph", "fnd"))
3131
)
3232
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.
33-
License: Apache License 2.0
33+
License: Apache License (== 2.0)
3434
Encoding: UTF-8
3535
Roxygen: list(markdown = TRUE)
3636
RoxygenNote: 7.3.2
3737
Imports:
3838
MASS,
39-
matrixcalc,
40-
parallel,
39+
Rcpp (>= 1.0.13),
4140
data.table,
42-
Rcpp (>= 1.0.13)
41+
matrixcalc,
42+
parallel
4343
Suggests:
44+
PowerTOST,
45+
ggplot2,
46+
kableExtra,
4447
knitr,
4548
rmarkdown,
4649
testthat (>= 3.0.0),
47-
tinytest,
48-
ggplot2,
49-
kableExtra,
5050
tibble,
51-
PowerTOST
51+
tinytest
5252
VignetteBuilder: knitr
5353
Config/testthat/edition: 3
5454
LinkingTo: Rcpp, RcppArmadillo

R/SampleSize.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
#' @param seed Integer. Seed for reproducibility.
3636
#' @param ncores Integer. Number of processing cores for parallel computation. Defaults to \code{1}. Set to \code{NA} for automatic detection (\code{ncores - 1}).
3737
#' @param optimization_method Character. Sample size optimization method: \code{"fast"} (default, root-finding algorithm) or \code{"step-by-step"}.
38-
#' @param lower Integer. Minimum sample size (\code{N}) for search range (default = 2).
39-
#' @param upper Integer. Maximum sample size (\code{N}) for search range (default = 500).
38+
#' @param lower Integer. Minimum sample size for search range (default = 2).
39+
#' @param upper Integer. Maximum sample size for search range (default = 500).
4040
#' @param step.power Numeric. Initial step size for sample size search, defined as \code{2^step.power}. Used when \code{optimization_method = "fast"}.
4141
#' @param step.up Logical. If \code{TRUE} (default), search increments upward from \code{lower}; if \code{FALSE}, decrements downward from \code{upper}. Used when \code{optimization_method = "fast"}.
4242
#' @param pos.side Logical. If \code{TRUE}, finds the smallest integer \code{i} closest to the root such that \code{f(i) > 0}. Used when \code{optimization_method = "fast"}.

R/utils.R

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -318,29 +318,33 @@ test_studies <- function(nsim, n, comp, param, param.d, arm_seed, ncores){
318318

319319

320320

321-
#' @title uniroot.integer.mod
322-
#' @description Optimizer Uniroot integer modified from the ssanv function package https://github.com/cran/ssanv/blob/master/R/uniroot.integer.R
321+
#' @title Optimizer for Uniroot Integer (Modified)
323322
#'
324-
#' @param f function for which a root is needed
325-
#' @param power target power value
326-
#' @param lower minimum allowable root
327-
#' @param upper maximum allowable root
328-
#' @param step.power initial step size is 2^step.power
329-
#' @param step.up if TRUE steps up from 'lower', if FALSE steps down from 'upper'
330-
#' @param pos.side if TRUE finds integer, i, closest to the root such that f(i) >0
331-
#' @param maxiter maximum number of iterations
332-
#' @param ... additional arguments to 'f'.
323+
#' @description A modified integer-based root-finding algorithm for determining the sample size required to achieve a target power.
324+
#' This function extends the uniroot integer search method to handle cases with stepwise power searches while considering constraints on search limits.
333325
#'
334-
#' @return a list with the following elements:
335-
#' root= the integer on the correct side of the root
336-
#' f.root = value of f at root (output= main output with final power, output.test= output table with test at endpoint level)
337-
#' iter = number of times f was evaluated
338-
#' table.iter = data.frame with the estimated N and power at each iteration
339-
#' table.test = data.frame with the test at endpoint level for a given N and each simulation draw
326+
#' @param f Function for which a root is needed.
327+
#' @param power Numeric. Target power value.
328+
#' @param lower Integer. Minimum allowable root value.
329+
#' @param upper Integer. Maximum allowable root value.
330+
#' @param step.power Numeric. Initial step size defined as \code{2^step.power}.
331+
#' @param step.up Logical. If \code{TRUE}, the search increments from \code{lower}; if \code{FALSE}, it decrements from \code{upper}.
332+
#' @param pos.side Logical. If \code{TRUE}, finds the closest integer \code{i} such that \code{f(i) > 0}.
333+
#' @param maxiter Integer. Maximum number of iterations allowed.
334+
#' @param ... Additional arguments passed to \code{f}.
335+
#'
336+
#' @return A list containing:
337+
#' \describe{
338+
#' \item{\code{root}}{The integer value closest to the root on the correct side.}
339+
#' \item{\code{f.root}}{Value of \code{f} at the estimated root.}
340+
#' \item{\code{iter}}{Number of function evaluations performed.}
341+
#' \item{\code{table.iter}}{A data frame showing estimated sample size (\code{N}) and corresponding power at each iteration.}
342+
#' \item{\code{table.test}}{A data frame containing endpoint-level test results for each simulation and corresponding \code{N}.}
343+
#' }
340344
#'
341345
#' @keywords internal
342-
343346
uniroot.integer.mod <-function (f, power, lower = lower, upper = upper, step.power=step.power, step.up=step.up, pos.side=pos.side, maxiter = maxiter,...) {
347+
# Function adapted from ssanv https://github.com/cran/ssanv/blob/master/R/uniroot.integer.R
344348
iter <- 0
345349
table.test<-data.frame()
346350
if (!is.numeric(lower) || !is.numeric(upper) || lower >= upper)

man/sampleSize.Rd

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

man/uniroot.integer.mod.Rd

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

0 commit comments

Comments
 (0)