diff --git a/CRAN-SUBMISSION b/CRAN-SUBMISSION index 149d8c9..1159fe3 100644 --- a/CRAN-SUBMISSION +++ b/CRAN-SUBMISSION @@ -1,3 +1,3 @@ Version: 0.1.0 -Date: 2022-10-04 13:40:57 UTC -SHA: 4b7c4ca4b9938b7f463f0e5cdda0f615c02b2d18 +Date: 2022-10-24 15:38:45 UTC +SHA: ac55a7f7e2e5f95cecbf60d64ecba12435523788 diff --git a/README.md b/README.md index c1c6c98..4b7ed4b 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ + # mtdesign @@ -8,7 +9,6 @@ status](https://www.r-pkg.org/badges/version/mtdesign)](https://CRAN.R-project.org/package=mtdesign) [![Test Coverage](https://raw.githubusercontent.com/openpharma/mtdesign/_xml_coverage_reports/data/main/badge.svg)](https://github.com/openpharma/mtdesign/blob/_xml_coverage_reports/data/main/coverage.xml) - ## Introduction @@ -34,7 +34,7 @@ You can install the development version of `mtdesign` from ## Set up vignette environment -```r +``` r # By policy, on CRAN, use only two cores, no matter how many are available. if (requireNamespace("parallel", quietly = TRUE)) { maxCores <- parallel::detectCores() @@ -51,7 +51,7 @@ interest but those with a response rate of at least 25% are worthy of further development. A Simon’s 2-stage design to seek an efficacy signal with a significance level of 5% and a power of 80% is required. -```r +``` r library(mtdesign) library(knitr) library(dplyr) @@ -72,7 +72,7 @@ simonDesign %>% ``` | nTotal | nStage1 | rTotal | rFutility | Type1 | Type2 | PETNull | AveSizeNull | Criterion | -| -----: | ------: | -----: | --------: | ----: | ----: | ------: | ----------: | :-------- | +|-------:|--------:|-------:|----------:|------:|------:|--------:|------------:|:----------| | 17 | 9 | 2 | 0 | 0.047 | 0.188 | 0.63 | 12.0 | optimal | | 16 | 12 | 2 | 0 | 0.043 | 0.199 | 0.54 | 13.8 | minimax | @@ -83,7 +83,7 @@ the power level achieved is 100% - 18.8% = 81.2%. The power curves for both designs are easily plotted. -```r +``` r powerPlot(simonDesign) ``` @@ -92,7 +92,7 @@ powerPlot(simonDesign) Obtaining the equivalent Mander & Thompson designs requires only a small change to the calls. -```r +``` r manderDesign <- obtainDesign( p0 = 0.05, p1 = 0.25, @@ -107,14 +107,13 @@ manderDesign %>% ``` | nTotal | nStage1 | rTotal | rFutility | rSuccess | Type1 | Type2 | PETNull | PETAlt | AveSizeNull | AveSizeAlt | Criterion | -| -----: | ------: | -----: | --------: | -------: | ----: | ----: | ------: | -----: | ----------: | ---------: | :---------- | +|-------:|--------:|-------:|----------:|---------:|------:|------:|--------:|-------:|------------:|-----------:|:------------| | 17 | 9 | 2 | 0 | 2 | 0.047 | 0.19 | 0.64 | 0.47 | 11.9 | NA | optimalNull | | 16 | 12 | 2 | 0 | 2 | 0.043 | 0.20 | 0.56 | 0.64 | 13.8 | NA | minimaxNull | | 17 | 9 | 2 | 0 | 2 | 0.047 | 0.19 | 0.64 | 0.47 | 11.9 | NA | optimalAlt | | 16 | 12 | 2 | 0 | 2 | 0.043 | 0.20 | 0.56 | 0.64 | 13.8 | NA | minimaxAlt | -```r - +``` r powerPlot(manderDesign) ``` @@ -128,7 +127,7 @@ stage design is 0/9 2/17. That’s close to n1 = 8, n = 16. Is there a (slightly) sub-optimal design that has n1 = 8, n = 16? -```r +``` r x <- createGrid(p0 = 0.05, p1 = 0.25, alpha = 0.05, beta = 0.2, mander = FALSE) y <- x %>% filter(nStage1 == 8, nTotal == 16) @@ -147,7 +146,7 @@ if (nrow(z) == 0) { No, there isn’t. How close can we get? -```r +``` r z1 <- y %>% augmentGrid() bestSize <- z1 %>% @@ -162,13 +161,12 @@ bestSize %>% ``` | nTotal | nStage1 | rTotal | rFutility | Type1 | Type2 | PETNull | AveSizeNull | -| -----: | ------: | -----: | --------: | ----: | ----: | ------: | ----------: | +|-------:|--------:|-------:|----------:|------:|------:|--------:|------------:| | 16 | 8 | 2 | 0 | 0.039 | 0.229 | 0.66 | 10.7 | Best sub-optimal design with required significance level -```r - +``` r bestPower <- z1 %>% filter(Type2 < Beta) %>% slice_min(Type1) @@ -182,7 +180,7 @@ bestPower %>% ``` | nTotal | nStage1 | rTotal | rFutility | Type1 | Type2 | PETNull | AveSizeNull | -| -----: | ------: | -----: | --------: | ----: | ----: | ------: | ----------: | +|-------:|--------:|-------:|----------:|------:|------:|--------:|------------:| | 16 | 8 | 1 | 0 | 0.151 | 0.127 | 0.66 | 10.7 | Best sub-optimal design with required power @@ -198,7 +196,7 @@ level. The power curve for each of these designs can be compared with that for the globally optimal design. -```r +``` r plotData1 <- simonDesign %>% filter(Criterion == "optimal") %>% bind_rows(list(bestSize, bestPower)) @@ -211,15 +209,15 @@ powerPlot(plotData1) The `mtdesign` package consists of three main functions: -* `createGrid` creates the grid (of nStage1, rFutility, nTotal and - rTotal for Simon’s design or nStage1, rFutility, rSuccess, nTotal and - rTotal for a Mander & Thompson design) over which the brute force - search for the required design(s) is conducted -* `augmentGrid`takes a grid created by `createGrid` and adds columns for - probability of early termination, Type 1 error, Type 2 error and - expected sample size to it. -* `obtainDesign` takes an augmented grid and identifies the optimal and - minimax designs +- `createGrid` creates the grid (of nStage1, rFutility, nTotal and + rTotal for Simon’s design or nStage1, rFutility, rSuccess, nTotal + and rTotal for a Mander & Thompson design) over which the brute + force search for the required design(s) is conducted +- `augmentGrid`takes a grid created by `createGrid` and adds columns + for probability of early termination, Type 1 error, Type 2 error and + expected sample size to it. +- `obtainDesign` takes an augmented grid and identifies the optimal + and minimax designs ## Error and warning messages and logging @@ -244,13 +242,13 @@ attempt to speed up the evaluation of candidate designs. The `augmentGrid` function allows users some control over the parallelisation process: -* The `parallel` parameter defaults to `TRUE` and defines whether or not - paralellisation is to be used. -* The `cores` parameter specifies how many cores are to be used. The - default value, `NA` tells `mtdesign` to use all available (as defined - by `parallel::detectCores()`), cores. -* The `minChunkSize` determines the smallest grid of candidate designs - that will trigger paralellisation. The default value is `100000`. +- The `parallel` parameter defaults to `TRUE` and defines whether or + not paralellisation is to be used. +- The `cores` parameter specifies how many cores are to be used. The + default value, `NA` tells `mtdesign` to use all available (as + defined by `parallel::detectCores()`), cores. +- The `minChunkSize` determines the smallest grid of candidate designs + that will trigger paralellisation. The default value is `100000`. The `parallel` package is required for parallelisation. If parallelisation is both needed (ie the grid size exceeds `minChunkSize`) @@ -264,7 +262,7 @@ more rows, a warning is produced. If, when installing or using the `mtdesign` package, you get an error regarding a syntax error in an`.hpp` file, similar to the following -```r +``` r .../BH/include/boost/math/tools/fraction.hpp:84:48: error: ‘long double’ is not a class, struct, or union type using value_type = typename T::value_type; ``` @@ -272,10 +270,10 @@ the issue is most likely a mismatch between the g++ compiler being used and the headers supplied by the `BH` package. There are only two solutions that I know of: -* Upgrade g++ -* Downgrade the version of the `BH` package you are using. The - appropriate package version depends on the version of the g++ compiler - you are using. +- Upgrade g++ +- Downgrade the version of the `BH` package you are using. The + appropriate package version depends on the version of the g++ + compiler you are using. ## References @@ -283,8 +281,8 @@ solutions that I know of: