Skip to content

Commit

Permalink
CRAN ready
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-imbi committed Apr 3, 2023
1 parent b44bb83 commit 9468012
Show file tree
Hide file tree
Showing 14 changed files with 152 additions and 53 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
Package: OptimalGoldstandardDesigns
Type: Package
Title: Design parameter optimization for gold-standard non-inferiority trials
Version: 0.2.0
Author: Jan Meis
Maintainer: Jan Meis <meis@imbi.uni-heidelberg.de>
Version: 1.0.0
Authors@R: c(person("Jan", "Meis", role = c("aut", "cre"), email="meis@imbi.uni-heidelberg.de", comment = c(ORCID = "0000-0001-5407-7220")))
Description: This package contains methods to calculate optimal design parameters
for one- and two-stage three-arm group-sequential gold-standard
non-inferiority trial designs
Expand All @@ -30,6 +29,7 @@ Suggests:
future.apply
Config/testthat/edition: 3
RoxygenNote: 7.2.3
Roxygen: list(markdown = TRUE)
Collate:
'pmv_upper_smaller_slower_fix.R'
'conditional_probability_functions.R'
Expand Down
4 changes: 2 additions & 2 deletions R/conditional_probability_functions.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Calculate the conditional mean of a multivariate normal distribution
#'
#' See e.g. chapter 8.1.2 in The Matrix Cookbook [1].
#' See e.g. Chapter 8.1.2 in [The Matrix Cookbook](https://www.math.uwaterloo.ca/~hwolkowi/matrixcookbook.pdf).
#'
#' @template x_a
#' @template mu_a
Expand All @@ -21,7 +21,7 @@ conditional_mean <- function(x_a, mu_a, mu_b, Sigma) {

#' Calculate the conditional mean of a multivariate normal distribution
#'
#' See e.g. chapter 8.1.2 in The Matrix Cookbook [1].
#' See e.g. Chapter 8.1.2 in [The Matrix Cookbook](https://www.math.uwaterloo.ca/~hwolkowi/matrixcookbook.pdf).
#'
#' @template x_a
#' @template mu_a
Expand Down
2 changes: 1 addition & 1 deletion R/global_constants.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ projection[["TP12_TC12"]] <- rbind(
projection_components[[1]][["TC"]],
projection_components[[2]][["TC"]]
)
.skip_slow_test <- TRUE
# .skip_slow_test <- TRUE
54 changes: 40 additions & 14 deletions R/optimization_methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#' @template varC
#' @param binding_futility (logical) controls if futility boundaries are binding.
#' @param always_both_futility_tests (logical) if true, both futility tests are performed after the first stage. If false,
#' a 'completely sequential' testing procedure is employed (see Appendix of paper).
#' a 'completely sequential' testing procedure is employed (see [Appendix of paper](https://doi.org/10.1002/sim.9630)).
#' @template round_n
#' @template lambda
#' @template kappa
Expand All @@ -39,12 +39,9 @@
#' @importFrom nloptr nloptr
#' @importFrom mvtnorm Miwa
#' @details
#' TODO: Documentation is still work in progross...
#'
#' This function calculates optimal design parameters for a two-stage three-arm gold-standard
#' non-inferiority trial. Run \code{vignette("mathematical_details", package = "OptimalGoldstandardDesigns")}
#' to see details about the test statistics and testing procedure corresponding to this design.
#'
#' non-inferiority trial. Run \code{vignette("Introduction", package = "OptimalGoldstandardDesigns")}
#' to see some examples related to the associated paper [(Meis et al., 2023)](https://doi.org/10.1002/sim.9630).
#'
#' Parameters which can be optimized are the allocation ratios for all groups and stages and the
#' futility and efficacy boundaries of the first stage. The allocation ratios are
Expand All @@ -64,7 +61,11 @@
#'
#'
#' The design is optimized with respect to the objective criterion given by the parameter
#' \code{objective}. By default, ...
#' \code{objective}. The default objective function is described in the
#' Subsection *Optimizing group sequential gold-standard designs* in Section 2
#' of [the associated paper](https://doi.org/10.1002/sim.9630). Additionally,
#' this objective includes a term to penalize the maximum sample size of a trial,
#' which can be controlled by the parameter `nu` (default is `nu=0`).
#'
#' Designs are calculated to fulfill the following constraints: the family-wise type I error
#' rate is controlled at \code{alpha} under any combination of the two null hypotheses
Expand All @@ -83,7 +84,23 @@
#'
#'
#' @examples
#' D <- optimize_design_twostage(nloptr_opts = list(maxeval = 1, algorithm = "NLOPT_LN_SBPLX"))
#' \dontrun{
#' optimize_design_twostage(
#' beta = 0.2,
#' alternative_TP = 0.4,
#' alternative_TC = 0,
#' Delta = 0.2,
#' print_progress = FALSE,
#' binding_futility = TRUE,
#' lambda = .9,
#' kappa = 1
#' )
#' }
#' @references
#' Meis, J, Pilz, M, Herrmann, C, Bokelmann, B, Rauch, G, Kieser, M. Optimization of the two-stage group
#' sequential three-arm gold-standard design for non-inferiority trials. *Statistics in Medicine.* 2023;
#' 42(4): 536– 558. [doi:10.1002/sim.9630](https://doi.org/10.1002/sim.9630).
#'
optimize_design_twostage <-
function(cT2 = NULL,
cP1 = NULL,
Expand Down Expand Up @@ -404,11 +421,9 @@ optimize_design_twostage <-
#' @export
#' @importFrom nloptr nloptr
#' @details
#' TODO: Documentation is still work in progross...
#'
#' This function calculates optimal design parameters for a two-stage three-arm gold-standard
#' non-inferiority trial. Run \code{vignette("mathematical_details", package = "OptimalGoldstandardDesigns")}
#' to see details about the test statistics and testing procedure corresponding to this design.
#' non-inferiority trial. Run \code{vignette("Introduction", package = "OptimalGoldstandardDesigns")}
#' to see some examples related to the associated paper [(Meis et al., 2023)](https://doi.org/10.1002/sim.9630).
#'
#'
#' Parameters which can be optimized are the allocation ratios for all groups and stages and the
Expand All @@ -429,7 +444,8 @@ optimize_design_twostage <-
#'
#'
#' The design is optimized with respect to the objective criterion given by the parameter
#' \code{objective}. By default, ...
#' \code{objective}. By default, this is the overall sample size plus an optional
#' penalty for the placebo group sample size, controlled by the parameter `kappa`.
#'
#' Designs are calculated to fulfill the following constraints: the family-wise type I error
#' rate is controlled at \code{alpha} under any combination of the two null hypotheses
Expand All @@ -448,7 +464,17 @@ optimize_design_twostage <-
#'
#'
#' @examples
#' D <- optimize_design_twostage(nloptr_opts = list(maxeval = 1, algorithm = "NLOPT_LN_SBPLX"))
#' \dontrun{
#' optimize_design_onestage(
#' alpha = .025,
#' beta = .2,
#' alternative_TP = .4,
#' alternative_TC = 0,
#' Delta = .2,
#' print_progress = FALSE
#' )
#' }
#'
optimize_design_onestage <-
function(cP1 = NULL,
cC1 = NULL,
Expand Down
2 changes: 1 addition & 1 deletion man/conditional_Sigma.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/conditional_mean.Rd

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

23 changes: 15 additions & 8 deletions man/optimize_design_onestage.Rd

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

34 changes: 25 additions & 9 deletions man/optimize_design_twostage.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_design_helper_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ test_that(
"Covariance matrix calculation is correct and works as expected.",
{
skip_on_cran()
skip_if(.skip_slow_test, "Slow test skipped.")
# skip_if(.skip_slow_test, "Slow test skipped.")
set.seed(123)
D <- list()
D$n <- list()
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test_design_twostage_binding.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
skip_on_cran()
skip_if(.skip_slow_test, "Slow test skipped.")
# skip_if(.skip_slow_test, "Slow test skipped.")
D <- optimize_design_twostage(print_progress = FALSE,
binding_futility = TRUE)
test_that(
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test_design_twostage_binding_sequential.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
skip_on_cran()
skip_if(.skip_slow_test, "Slow test skipped.")
# skip_if(.skip_slow_test, "Slow test skipped.")
D <- optimize_design_twostage(
always_both_futility_tests = FALSE,
binding_futility = TRUE,
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test_design_twostage_nonbinding.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
skip_on_cran()
skip_if(.skip_slow_test, "Slow test skipped.")
# skip_if(.skip_slow_test, "Slow test skipped.")
D <- optimize_design_twostage(print_progress = FALSE)

test_that(
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test_schloemer_comparison.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
skip_on_cran()
skip_if(.skip_slow_test, "Slow test skipped.")
# skip_if(.skip_slow_test, "Slow test skipped.")
# Compare results with work from Patrick Schloemer
library(mvtnorm)
library(mnormt)
Expand Down
Loading

0 comments on commit 9468012

Please sign in to comment.