diff --git a/.Rbuildignore b/.Rbuildignore index 90147d2..0fd963f 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -49,3 +49,4 @@ testthat-problems\.rds ^README\.html$ ^codecov\.yml$ Rplots\.pdf +^\.lintr$ diff --git a/.github/workflows/rhub.yaml b/.github/workflows/rhub.yaml new file mode 100644 index 0000000..74ec7b0 --- /dev/null +++ b/.github/workflows/rhub.yaml @@ -0,0 +1,95 @@ +# R-hub's generic GitHub Actions workflow file. It's canonical location is at +# https://github.com/r-hub/actions/blob/v1/workflows/rhub.yaml +# You can update this file to a newer version using the rhub2 package: +# +# rhub::rhub_setup() +# +# It is unlikely that you need to modify this file manually. + +name: R-hub +run-name: "${{ github.event.inputs.id }}: ${{ github.event.inputs.name || format('Manually run by {0}', github.triggering_actor) }}" + +on: + workflow_dispatch: + inputs: + config: + description: 'A comma separated list of R-hub platforms to use.' + type: string + default: 'linux,windows,macos' + name: + description: 'Run name. You can leave this empty now.' + type: string + id: + description: 'Unique ID. You can leave this empty now.' + type: string + +jobs: + + setup: + runs-on: ubuntu-latest + outputs: + containers: ${{ steps.rhub-setup.outputs.containers }} + platforms: ${{ steps.rhub-setup.outputs.platforms }} + + steps: + # NO NEED TO CHECKOUT HERE + - uses: r-hub/actions/setup@v1 + with: + config: ${{ github.event.inputs.config }} + id: rhub-setup + + linux-containers: + needs: setup + if: ${{ needs.setup.outputs.containers != '[]' }} + runs-on: ubuntu-latest + name: ${{ matrix.config.label }} + strategy: + fail-fast: false + matrix: + config: ${{ fromJson(needs.setup.outputs.containers) }} + container: + image: ${{ matrix.config.container }} + + steps: + - uses: r-hub/actions/checkout@v1 + - uses: r-hub/actions/platform-info@v1 + with: + token: ${{ secrets.RHUB_TOKEN }} + job-config: ${{ matrix.config.job-config }} + - uses: r-hub/actions/setup-deps@v1 + with: + token: ${{ secrets.RHUB_TOKEN }} + job-config: ${{ matrix.config.job-config }} + - uses: r-hub/actions/run-check@v1 + with: + token: ${{ secrets.RHUB_TOKEN }} + job-config: ${{ matrix.config.job-config }} + + other-platforms: + needs: setup + if: ${{ needs.setup.outputs.platforms != '[]' }} + runs-on: ${{ matrix.config.os }} + name: ${{ matrix.config.label }} + strategy: + fail-fast: false + matrix: + config: ${{ fromJson(needs.setup.outputs.platforms) }} + + steps: + - uses: r-hub/actions/checkout@v1 + - uses: r-hub/actions/setup-r@v1 + with: + job-config: ${{ matrix.config.job-config }} + token: ${{ secrets.RHUB_TOKEN }} + - uses: r-hub/actions/platform-info@v1 + with: + token: ${{ secrets.RHUB_TOKEN }} + job-config: ${{ matrix.config.job-config }} + - uses: r-hub/actions/setup-deps@v1 + with: + job-config: ${{ matrix.config.job-config }} + token: ${{ secrets.RHUB_TOKEN }} + - uses: r-hub/actions/run-check@v1 + with: + job-config: ${{ matrix.config.job-config }} + token: ${{ secrets.RHUB_TOKEN }} diff --git a/DESCRIPTION b/DESCRIPTION index a91a90f..d7560f9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: rpact Title: Confirmatory Adaptive Clinical Trial Design and Analysis -Version: 4.0.1.9247 -Date: 2024-08-15 +Version: 4.0.1.9248 +Date: 2024-08-21 Authors@R: c( person( given = "Gernot", diff --git a/NAMESPACE b/NAMESPACE index e1e1fbd..af7ab57 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -104,6 +104,7 @@ export(getSampleSizeCounts) export(getSampleSizeMeans) export(getSampleSizeRates) export(getSampleSizeSurvival) +export(getSimulationCounts) export(getSimulationEnrichmentMeans) export(getSimulationEnrichmentRates) export(getSimulationEnrichmentSurvival) diff --git a/R/class_summary.R b/R/class_summary.R index ff3312e..0759a7a 100644 --- a/R/class_summary.R +++ b/R/class_summary.R @@ -13,8 +13,8 @@ ## | ## | Contact us for information about our services: info@rpact.com ## | -## | File version: $Revision: 8087 $ -## | Last changed: $Date: 2024-08-15 16:34:30 +0200 (Do, 15 Aug 2024) $ +## | File version: $Revision: 8111 $ +## | Last changed: $Date: 2024-08-20 14:20:14 +0200 (Di, 20 Aug 2024) $ ## | Last changed by: $Author: pahlke $ ## | @@ -1641,20 +1641,19 @@ SummaryFactory <- R6::R6Class("SummaryFactory", return(header) } -.addAlphaAndBetaToHeader <- function(header, design, designPlan, ..., endOfRecord = FALSE, powerEnabled = NA) { - header <- .concatenateSummaryText(header, paste0( - ifelse(design$sided == 1, "one-sided", "two-sided"), - ifelse(design$kMax == 1, "", " overall") - )) +.addAlphaAndBetaToHeader <- function(header, design, designPlan, ..., endOfRecord = FALSE, powerEnabled = NA, sep = ", ") { if (is.na(powerEnabled)) { powerEnabled <- .isTrialDesignInverseNormalOrGroupSequential(design) && (is.null(designPlan) || (!.isSimulationResults(designPlan) && !identical("power", designPlan[[".objectType"]]))) } header <- .concatenateSummaryText(header, - paste0("significance level ", round(100 * design$alpha, 2), "%", + paste0( + ifelse(design$sided == 1, "one-sided", "two-sided"), + ifelse(design$kMax == 1, "", " overall"), + " significance level ", round(100 * design$alpha, 2), "%", ifelse(!powerEnabled && endOfRecord, ".", "")), - sep = " " + sep = sep ) if (powerEnabled) { header <- .concatenateSummaryText(header, diff --git a/R/f_design_general_utilities.R b/R/f_design_general_utilities.R index 3fe8219..2852d15 100644 --- a/R/f_design_general_utilities.R +++ b/R/f_design_general_utilities.R @@ -13,8 +13,8 @@ ## | ## | Contact us for information about our services: info@rpact.com ## | -## | File version: $Revision: 8087 $ -## | Last changed: $Date: 2024-08-15 16:34:30 +0200 (Do, 15 Aug 2024) $ +## | File version: $Revision: 8104 $ +## | Last changed: $Date: 2024-08-19 10:30:01 +0200 (Mo, 19 Aug 2024) $ ## | Last changed by: $Author: pahlke $ ## | @@ -27,7 +27,7 @@ NULL } .getDefaultDesign <- function(..., - type = c("sampleSize", "power", "simulation", "analysis", "characteristics"), + type = c("sampleSize", "power", "simulation", "simulationCounts", "analysis", "characteristics"), ignore = c()) { type <- match.arg(type) @@ -54,7 +54,7 @@ NULL twoSidedPower <- .getOptionalArgument("twoSidedPower", ...) if (is.null(twoSidedPower)) { - if (type %in% c("power", "simulation") && sided == 2) { + if (type %in% c("power", "simulation", "simulationCounts") && sided == 2) { twoSidedPower <- TRUE } else { twoSidedPower <- C_TWO_SIDED_POWER_DEFAULT diff --git a/R/f_design_group_sequential.R b/R/f_design_group_sequential.R index c7ca127..0e59247 100644 --- a/R/f_design_group_sequential.R +++ b/R/f_design_group_sequential.R @@ -13,9 +13,9 @@ ## | ## | Contact us for information about our services: info@rpact.com ## | -## | File version: $Revision: 7742 $ -## | Last changed: $Date: 2024-03-22 13:46:29 +0100 (Fr, 22 Mrz 2024) $ -## | Last changed by: $Author: pahlke $ +## | File version: $Revision: 8112 $ +## | Last changed: $Date: 2024-08-20 15:44:53 +0200 (Di, 20 Aug 2024) $ +## | Last changed by: $Author: wassmer $ ## | #' @include f_core_constants.R @@ -38,9 +38,9 @@ NULL #' Given a sequence of information rates (fixing the correlation structure), and #' decisionMatrix with either 2 or 4 rows and kMax = length(informationRates) columns, #' this function calculates a probability matrix containing, for two rows, the probabilities:\cr -#' P(Z_1 <- l_1), P(l_1 <- Z_1 < u_1, Z_2 < l_1),..., P(l_kMax-1 <- Z_kMax-1 < u_kMax-1, Z_kMax < l_l_kMax)\cr -#' P(Z_1 <- u_1), P(l_1 <- Z_1 < u_1, Z_2 < u_1),..., P(l_kMax-1 <- Z_kMax-1 < u_kMax-1, Z_kMax < u_l_kMax)\cr -#' P(Z_1 <- Inf), P(l_1 <- Z_1 < u_1, Z_2 < Inf),..., P(l_kMax-1 <- Z_kMax-1 < u_kMax-1, Z_kMax < Inf)\cr +#' P(Z_1 < l_1), P(l_1 < Z_1 < u_1, Z_2 < l_2),..., P(l_kMax-1 < Z_kMax-1 < u_kMax-1, Z_kMax < l_l_kMax)\cr +#' P(Z_1 < u_1), P(l_1 < Z_1 < u_1, Z_2 < u_2),..., P(l_kMax-1 < Z_kMax-1 < u_kMax-1, Z_kMax < u_l_kMax)\cr +#' P(Z_1 < Inf), P(l_1 < Z_1 < u_1, Z_2 < Inf),..., P(l_kMax-1 < Z_kMax-1 < u_kMax-1, Z_kMax < Inf)\cr #' with continuation matrix\cr #' l_1,...,l_kMax\cr #' u_1,...,u_kMax\cr @@ -423,6 +423,10 @@ getGroupSequentialProbabilities <- function(decisionMatrix, informationRates) { .getDesignGroupSequentialKMax1 <- function(design) { design$criticalValues <- .getOneMinusQNorm(design$alpha / design$sided) design$alphaSpent[1] <- design$alpha + design$.setParameterType("typeOfDesign", C_PARAM_NOT_APPLICABLE) + if (!identical(design$typeOfDesign, C_DEFAULT_TYPE_OF_DESIGN)) { + warning("'typeOfDesign' (", design$typeOfDesign, ") will be ignored because design is fixed", call. = FALSE) + } return(invisible(design)) } diff --git a/R/f_simulation_base_count_data.R b/R/f_simulation_base_count_data.R index 3eec4ef..b0e9b33 100644 --- a/R/f_simulation_base_count_data.R +++ b/R/f_simulation_base_count_data.R @@ -13,9 +13,9 @@ ## | ## | Contact us for information about our services: info@rpact.com ## | -## | File version: $Revision: 8052 $ -## | Last changed: $Date: 2024-07-18 11:19:40 +0200 (Do, 18 Jul 2024) $ -## | Last changed by: $Author: pahlke $ +## | File version: $Revision: 8112 $ +## | Last changed: $Date: 2024-08-20 15:44:53 +0200 (Di, 20 Aug 2024) $ +## | Last changed by: $Author: wassmer $ ## | .getInformationCountData <- function(lambda1, @@ -101,18 +101,14 @@ #' @inheritParams param_accrualTime_counts #' @inheritParams param_accrualIntensity_counts #' @inheritParams param_followUpTime_counts -#' @inheritParams param_maxNumberOfSubjects #' @inheritParams param_overdispersion_counts #' @inheritParams param_directionUpper #' @inheritParams param_allocationRatioPlanned -#' @inheritParams param_plannedSubjects -#' @inheritParams param_minNumberOfSubjectsPerStage -#' @inheritParams param_maxNumberOfSubjectsPerStage -#' @inheritParams param_conditionalPowerSimulation +#' @inheritParams param_maxNumberOfSubjects_counts #' @inheritParams param_maxNumberOfIterations -#' @inheritParams param_calcSubjectsFunction #' @inheritParams param_seed #' @inheritParams param_three_dots +#' @inheritParams param_calcSubjectsFunction #' @inheritParams param_showStatistics #' #' @details @@ -156,8 +152,10 @@ #' #' @template return_object_simulation_results #' @template how_to_get_help_for_generics +#' +#' @template examples_get_simulation_counts #' -#' @keywords internal +#' @export #' getSimulationCounts <- function(design = NULL, ..., @@ -183,7 +181,7 @@ getSimulationCounts <- function(design = NULL, directionUpper <- TRUE } if (is.null(design)) { - design <- .getDefaultDesign(..., type = "simulation") + design <- .getDefaultDesign(..., type = "simulationCounts") .warnInCaseOfUnknownArguments( functionName = "getSimulationCounts", ignore = .getDesignArgumentsToIgnoreAtUnknownArgumentCheck( @@ -192,7 +190,7 @@ getSimulationCounts <- function(design = NULL, ) ) } else { - .assertIsTrialDesign(design) + .assertIsTrialDesignGroupSequential(design) .warnInCaseOfUnknownArguments( functionName = "getSimulationCounts", ignore = c("showStatistics"), ... @@ -426,7 +424,7 @@ getSimulationCounts <- function(design = NULL, dfStartStop$output[, "recruitTime"] <= plannedCalendarTime[k] & dfStartStop$output[, "stopCalendar"] <= plannedCalendarTime[k], ] - if (length(kthStageWithEvents) > 0 && nrow(kthStageWithEvents) > 0) { + if (length(kthStageWithEvents) > 0 && is.matrix(kthStageWithEvents) && nrow(kthStageWithEvents) > 0) { tab <- table(kthStageWithEvents[, "id"]) idx <- as.integer(names(tab)) counts[idx] <- as.vector(tab) diff --git a/R/parameter_descriptions.R b/R/parameter_descriptions.R index 6167266..54cb04a 100644 --- a/R/parameter_descriptions.R +++ b/R/parameter_descriptions.R @@ -13,9 +13,9 @@ ## | ## | Contact us for information about our services: info@rpact.com ## | -## | File version: $Revision: 7941 $ -## | Last changed: $Date: 2024-05-28 08:44:36 +0200 (Di, 28 Mai 2024) $ -## | Last changed by: $Author: pahlke $ +## | File version: $Revision: 8112 $ +## | Last changed: $Date: 2024-08-20 15:44:53 +0200 (Di, 20 Aug 2024) $ +## | Last changed by: $Author: wassmer $ ## | #' Parameter Description: "..." @@ -344,7 +344,11 @@ NULL #' @keywords internal NULL - +#' Parameter Description: plannedMaxSubjects for Counts +#' @param plannedMaxSubjects \code{plannedMaxSubjects > 0} needs to be specified. +#' @name param_maxNumberOfSubjects_counts +#' @keywords internal +NULL ## ## Analysis diff --git a/inst/doc/rpact_getting_started.html b/inst/doc/rpact_getting_started.html index 1f24082..9010801 100644 --- a/inst/doc/rpact_getting_started.html +++ b/inst/doc/rpact_getting_started.html @@ -12,7 +12,7 @@ - + Getting started with rpact @@ -239,7 +239,7 @@

Getting started with rpact

Friedrich Pahlke and Gernot Wassmer

-

2024-08-15

+

2024-08-19

diff --git a/man/getGroupSequentialProbabilities.Rd b/man/getGroupSequentialProbabilities.Rd index c26d10a..d2fe9f1 100644 --- a/man/getGroupSequentialProbabilities.Rd +++ b/man/getGroupSequentialProbabilities.Rd @@ -24,9 +24,9 @@ Calculates probabilities in the group sequential setting. Given a sequence of information rates (fixing the correlation structure), and decisionMatrix with either 2 or 4 rows and kMax = length(informationRates) columns, this function calculates a probability matrix containing, for two rows, the probabilities:\cr -P(Z_1 <- l_1), P(l_1 <- Z_1 < u_1, Z_2 < l_1),..., P(l_kMax-1 <- Z_kMax-1 < u_kMax-1, Z_kMax < l_l_kMax)\cr -P(Z_1 <- u_1), P(l_1 <- Z_1 < u_1, Z_2 < u_1),..., P(l_kMax-1 <- Z_kMax-1 < u_kMax-1, Z_kMax < u_l_kMax)\cr -P(Z_1 <- Inf), P(l_1 <- Z_1 < u_1, Z_2 < Inf),..., P(l_kMax-1 <- Z_kMax-1 < u_kMax-1, Z_kMax < Inf)\cr +P(Z_1 < l_1), P(l_1 < Z_1 < u_1, Z_2 < l_2),..., P(l_kMax-1 < Z_kMax-1 < u_kMax-1, Z_kMax < l_l_kMax)\cr +P(Z_1 < u_1), P(l_1 < Z_1 < u_1, Z_2 < u_2),..., P(l_kMax-1 < Z_kMax-1 < u_kMax-1, Z_kMax < u_l_kMax)\cr +P(Z_1 < Inf), P(l_1 < Z_1 < u_1, Z_2 < Inf),..., P(l_kMax-1 < Z_kMax-1 < u_kMax-1, Z_kMax < Inf)\cr with continuation matrix\cr l_1,...,l_kMax\cr u_1,...,u_kMax\cr diff --git a/man/getSimulationCounts.Rd b/man/getSimulationCounts.Rd index fedc6bb..13b5f93 100644 --- a/man/getSimulationCounts.Rd +++ b/man/getSimulationCounts.Rd @@ -38,6 +38,8 @@ that a warning will be displayed if unknown arguments are passed.} \item{plannedCalendarTime}{For simulating count data, the time points where an analysis is planned to be performed. Should be a vector of length \code{kMax}} +\item{plannedMaxSubjects}{\code{plannedMaxSubjects > 0} needs to be specified.} + \item{lambda1}{A numeric value or vector that represents the assumed rate of a homogeneous Poisson process in the active treatment group, there is no default.} @@ -169,4 +171,28 @@ There you can find, e.g., \code{plot.AnalysisResults} and obtain the specific help documentation linked above by typing \code{?plot.AnalysisResults}. } -\keyword{internal} +\examples{ +# Fixed sample size design with two groups +getSimulationCounts( + plannedMaxSubjects = 200, + plannedCalendarTime = 8, + theta = 1.8, + lambda2 = 0.2, + maxNumberOfIterations = 1000, + fixedExposureTime = 6, + accrualTime = 3, + overdispersion = 2) +\dontrun{ +# Group sequential design alpha spending function design with O'Brien and +# Fleming type boundaries: Power and test characteristics for N = 1976, +# under variable exposure time with uniform recruitment over 1.25 months, +# study time (accrual + followup) = 4 (lambda1, lambda2, and overdispersion +# as specified, no futility stopping): +getPowerCounts(design = getDesignGroupSequential( + kMax = 3, alpha = 0.025, beta = 0.2, typeOfDesign = "asOF"), + lambda1 = seq(0.08, 0.09, 0.0025), lambda2 = 0.125, + overdispersion = 5, directionUpper = FALSE, maxNumberOfSubjects = 1976, + followUpTime = 2.75, accrualTime = 1.25) +} + +}