Skip to content

Commit

Permalink
82_Design-ocRctPredProbDist (#83)
Browse files Browse the repository at this point in the history
Co-authored-by: 27856297+dependabot-preview[bot]@users.noreply.github.com <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: Daniel Sabanes Bove <daniel.sabanes_bove@roche.com>
Co-authored-by: Daniel Sabanes Bove <danielinteractive@users.noreply.github.com>
  • Loading branch information
4 people authored May 21, 2024
1 parent 10ea9d1 commit 9a25b76
Show file tree
Hide file tree
Showing 14 changed files with 864 additions and 47 deletions.
6 changes: 0 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,3 @@ coverage.*
.vscode/
.rds
node_modules

tests/testthat/junit-result.xml

tests/unit_testing_results.rds

tests/testthat/testthat-problems.rds
7 changes: 4 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
# R specific hooks: https://github.com/lorenzwalthert/precommit
repos:
- repo: https://github.com/lorenzwalthert/precommit
rev: v0.4.0
rev: v0.4.2
hooks:
- id: style-files
args: [--style_pkg=styler, --style_fun=tidyverse_style]
- id: roxygenize
additional_dependencies:
- devtools
- shiny
- checkmate
- openpharma/roxytypes
Expand Down Expand Up @@ -64,7 +65,7 @@ repos:
design/.*
)$
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: check-added-large-files
args: ["--maxkb=200"]
Expand All @@ -89,6 +90,6 @@ repos:
files: '\.Rhistory|\.RData|\.Rds|\.rds$'
# `exclude: <regex>` to allow committing specific files.
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.39.0
rev: v0.40.0
hooks:
- id: markdownlint
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Suggests:
testthat (>= 3.0.0)
Imports:
checkmate,
devtools,
lifecycle
VignetteBuilder:
knitr
Expand Down
1 change: 1 addition & 0 deletions R/ocRctPostprobDist.R
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ h_get_oc_rct <- function(all_sizes, Nmax, nActive, nControl, decision) {
assert_numeric(nActive, any.missing = FALSE, len = length(all_sizes))
assert_numeric(nControl, any.missing = FALSE, len = length(all_sizes))
assert_true(all(nActive + nControl == all_sizes))
assert_true(Nmax >= max(all_sizes))

tmp <- h_get_oc(
all_sizes = all_sizes,
Expand Down
24 changes: 17 additions & 7 deletions design/design-doc_ocRctPostprobDist.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ looks_nnrE <- looks$nnrE
looks_nnrF <- looks$nnrF
h_get_decisionDist_rct(
nnr = input$nn,
nnr = input$nnE,
nnrE = looks$nnrE,
nnrF = looks$nnrF,
pE = input$pE,
Expand All @@ -206,7 +206,9 @@ h_get_decisionDist_rct(
tU = input$tU,
deltaE = input$deltaE,
deltaF = input$deltaF,
relativeDelta = TRUE
relativeDelta = TRUE,
randRatio = 1,
Nmax = 30
)
```
# helper also works when `relativeDelta = FALSE`
Expand All @@ -217,7 +219,7 @@ looks_nnrE <- looks$nnrE
looks_nnrF <- looks$nnrF
h_get_decisionDist_rct(
nnr = input$nn,
nnr = input$nnE,
nnrE = looks$nnrE,
nnrF = looks$nnrF,
pE = input$pE,
Expand All @@ -228,7 +230,9 @@ h_get_decisionDist_rct(
tU = input$tU,
deltaE = input$deltaE,
deltaF = input$deltaF,
relativeDelta = FALSE
relativeDelta = FALSE,
randRatio = 1,
Nmax = 30
)
```
# h_get_oc_rct
Expand Down Expand Up @@ -311,7 +315,7 @@ new_RctPostprobDist <- function(nnE,
if (sim < 50000) {
warning("Advise to use sim >= 50000 to achieve convergence")
}
decision <- all_sizes <- vector(length = sim)
decision <- all_sizes <- nActive <- nControl <- vector(length = sim)
nnE <- sort(nnE)
nnF <- sort(nnF)
nn <- sort(unique(c(nnF, nnE)))
Expand Down Expand Up @@ -353,7 +357,13 @@ new_RctPostprobDist <- function(nnE,
nActive[k] <- tmp$nActive
nControl[k] <- tmp$nControl
}
oc <- h_get_oc_rct(all_sizes = all_sizes, nnr = nnr, Nmax = Nmax, nActive = nActive, nControl = nControl, decision = decision)
oc <- h_get_oc_rct(
all_sizes = all_sizes,
Nmax = Nmax,
nActive = nActive,
nControl = nControl,
decision = decision
)
list(
oc = oc,
ExpectedN = mean(all_sizes),
Expand All @@ -375,7 +385,7 @@ new_RctPostprobDist <- function(nnE,
```{r}
set.seed(2000)
new_RctPostprobDist(
nnE = input$nn,
nnE = input$nnE,
pE = input$pE,
pS = input$pS,
deltaE = input$deltaE,
Expand Down
Loading

0 comments on commit 9a25b76

Please sign in to comment.