-
Notifications
You must be signed in to change notification settings - Fork 4
92_boundsPostprob #104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
92_boundsPostprob #104
Changes from 65 commits
Commits
Show all changes
92 commits
Select commit
Hold shift + click to select a range
4f8d4c8
Merge remote-tracking branch 'origin/HEAD'
audreyyeoCH dff2ff6
delete helpers
audreyyeoCH 37561fc
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] ab9ba06
clean
audreyyeoCH ab51030
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] 008502d
clean
audreyyeoCH 3bc1cf1
"clean+"
audreyyeoCH 34a2313
empty
audreyyeoCH 0cd95a7
examples and test there
audreyyeoCH 51db59a
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] df9a7ca
clean
audreyyeoCH bc6dac2
Mergen"
audreyyeoCH bd327cc
NAMESPACE stuff
audreyyeoCH e25e4fd
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] c6ec5cc
empty
audreyyeoCH fe22df6
add rmarkdown to DESCRIPTIOPM
audreyyeoCH f1a2978
Merge branch 'main' into 94_helpers.R
audreyyeoCH 95a6080
clean
audreyyeoCH cc665fc
Merge branch 'main' into 92_boundsPostprob
audreyyeoCH 670558d
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] 4f3c785
Merge remote-tracking branch 'origin/HEAD'
audreyyeoCH 947e1cb
Merge branch 'main' of github.com:Genentech/phase1b
audreyyeoCH 9d8a2b3
Merge branch 'main' into 92_boundsPostprob
audreyyeoCH 42595d7
Merge branch 'main' of github.com:Genentech/phase1b
audreyyeoCH 62611fa
Merge branch 'main' into 94_helpers.R
audreyyeoCH a29fd0f
should pass CMD checks
audreyyeoCH b9c7abd
Merge branch '94_helpers.R'
audreyyeoCH fe3f37f
see if CMD checks pass now
audreyyeoCH 155571b
Merge branch '92_boundsPostprob'
audreyyeoCH 9b94bba
Merge branch 'main' into 92_boundsPostprob
audreyyeoCH 1b7d9c1
clean
audreyyeoCH 150f243
Update examples/boundsPostprob.R
audreyyeoCH 40afb1a
clean
audreyyeoCH bbb8c26
added ggplot2 in vignette
audreyyeoCH 4bd29d1
empty
audreyyeoCH 284c817
Merge branch 'main' into 92_boundsPostprob
audreyyeoCH d8ce79c
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] 98fac80
found postL
audreyyeoCH ed627cb
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] e7ba41c
Merge branch 'main' into 92_boundsPostprob
audreyyeoCH 0b2e6ad
changed params in bounds example
audreyyeoCH 25a5b01
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] 710d404
clean
audreyyeoCH ce5f140
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] 3668897
clean
audreyyeoCH c59c148
clean
audreyyeoCH b748246
made it flexible for beta mixture priors
audreyyeoCH 78fb8a5
Merge branch 'main' into 92_boundsPostprob
audreyyeoCH c1f312b
made it flexible for beta mixture priors
audreyyeoCH 68a4cd2
Merge branch '92_boundsPostprob' of github.com:Genentech/phase1b into…
audreyyeoCH 9f90ee8
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] d11cce4
Update R/boundsPostprob.R
audreyyeoCH bee517e
Update tests/testthat/test-boundsPostProb.R
audreyyeoCH 9e6047f
Update examples/boundsPostprob.R
audreyyeoCH e21363f
Update R/boundsPostprob.R
audreyyeoCH 6754609
Update R/boundsPostprob.R
audreyyeoCH 6293025
Update R/boundsPostprob.R
audreyyeoCH a21a776
Update R/boundsPostprob.R
audreyyeoCH 515e021
Update tests/testthat/test-boundsPostProb.R
audreyyeoCH 772d191
Update tests/testthat/test-boundsPostProb.R
audreyyeoCH 929bdfa
Update R/boundsPostprob.R
audreyyeoCH cd923d8
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] 3075a55
clean
audreyyeoCH 2c0d0bc
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] 75693d7
assert weights to different position
audreyyeoCH 23973c7
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] 601c844
empty commit to make sure cmd checks pass for merge
audreyyeoCH ca82fc1
clean
audreyyeoCH d27b545
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] f9ac9fa
ocProdprod.Rd rebuilt
audreyyeoCH 297c0b2
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] 431291e
see if man/ocPredprob.Rd blanks out
audreyyeoCH 1a12b88
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] b18ccdd
did anything change from restarting session
audreyyeoCH 733e791
Merge branch '92_boundsPostprob' of github.com:Genentech/phase1b into…
audreyyeoCH 3b35b0f
did anything change from restarting session
audreyyeoCH 791e2e5
checking again
audreyyeoCH 4060b7f
that did not work
audreyyeoCH 85790ac
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] 75045a2
clean
audreyyeoCH 3f2aabf
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] 847839b
clean
audreyyeoCH dfc536e
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] 612c10f
clean
audreyyeoCH 685d990
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] aaad040
rebuild
audreyyeoCH 319dd16
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] 54cbf18
clean
audreyyeoCH 1c7c8e8
Merge branch '92_boundsPostprob' of github.com:Genentech/phase1b into…
audreyyeoCH 431b119
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] c1a4605
clean
audreyyeoCH 563b8da
Merge branch '92_boundsPostprob' of github.com:Genentech/phase1b into…
audreyyeoCH File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,78 @@ | ||
#' Decision cutpoints for boundary (based on posterior probability) | ||
#' | ||
#' This function is used to identify the efficacy and futility | ||
#' boundaries based on posterior probabilities, i.e.: | ||
#' Efficacy boundary: find minimum x (xU) where Pr(P>p0|x,n,a,b) >= tU and | ||
#' Futility boundary: find maximum x (xL) where Pr(P>p1|x,n,a,b) <= tL | ||
#' boundaries based on the following rules: | ||
#' Efficacy boundary: find minimum x (xU) where Pr(RR > p1 |x, n, a, b) >= tU and | ||
#' Futility boundary: find maximum x (xL) where Pr(RR < p0 | x, n, a, b) >= tL | ||
#' | ||
#' @param nvec a vector of number of patients | ||
#' @param p0 the efficacy threshold parameter in the postprob function | ||
#' @param p1 the futility threshold parameter in the postprob function | ||
#' (default = p0) | ||
#' @param tL futility boundary probability threshold | ||
#' @param tU efficacy boundary probability threshold | ||
#' @param a the alpha parameter of the beta prior of treatment group | ||
#' @param b the beta parameter of the beta prior of treatment group | ||
#' @return A matrix where for each sample size in \code{nvec}, this function | ||
#' returns the maximum number of responses that meet the futility | ||
#' threshold (xL), its corresponding response rate (pL), posterior probability | ||
#' (postL), upper bound of one sided 95% CI for the response rate based on an | ||
#' exact binomial test (UciL), and the same boundary parameters for efficacy: | ||
#' the minimal number of responses that meet the efficacy threshold (xU), | ||
#' the corresponding response rate (pU), posterior probability (postU) and | ||
#' the lower bound of one sided 95% CI for the response rate based on exact | ||
#' binomial test (LciU). | ||
#' | ||
#' @importFrom stats binom.test | ||
#' @inheritParams postprob | ||
#' @inheritParams ocPostprob | ||
#' @typed looks : numeric | ||
#' A vector of number of patients in each look. | ||
#' @return A matrix for each same size in `looks`. For each sample size, the following is returned: | ||
#' - `xL` : the maximum number of responses that meet the futility threshold. | ||
#' - `pL` : response rate corresponding to `xL`. | ||
#' - `postL`: posterior probability corresponding to `xL`, i.e. Pr(RR < p0 | xL, n, a, b). | ||
#' - `pL_upper_ci` : upper bound of one sided 95% CI for the response rate `pL` based on an | ||
#' exact binomial test. | ||
#' - `xU` : the minimal number of responses that meet the efficacy threshold. | ||
#' - `pU` : response rate corresponding to `xU`. | ||
#' - `postU` : posterior probability corresponding to `xU`, i.e. Pr(RR > p1 |xU, n, a, b). | ||
#' - `pU_lower_ci` : lower bound of one sided 95% CI for the response rate `pU` based on exact | ||
#' binomial test. | ||
#' | ||
#' @example examples/boundsPostprob.R | ||
#' @export | ||
#' @keywords graphics | ||
boundsPostprob <- function(nvec, p0, p1 = p0, tL, tU, a, b) { | ||
z <- matrix(NA, length(nvec), 6) | ||
dimnames(z) <- list(nvec, c( | ||
"xL", "pL", "postL", | ||
"xU", "pU", "postU" | ||
)) | ||
boundsPostprob <- function(looks, p0, p1 = p0, tL, tU, parE, weights) { | ||
assert_numeric(looks) | ||
assert_number(p0, lower = 0, upper = 1) | ||
assert_number(p1, lower = 0, upper = 1) | ||
assert_number(tL, lower = 0, upper = 1) | ||
assert_number(tU, lower = 0, upper = 1) | ||
assert_numeric(parE, min.len = 2, any.missing = FALSE) | ||
z <- matrix(NA, nrow = length(looks), ncol = 8) | ||
znames <- c( | ||
"xL", "pL", "postL", "UciL", | ||
"xU", "pU", "postU", "LciU" | ||
"xL", "pL", "postL", "pL_upper_ci", | ||
"xU", "pU", "postU", "pU_lower_ci" | ||
) | ||
z <- matrix(NA, length(nvec), length(znames)) | ||
dimnames(z) <- list(nvec, znames) | ||
dimnames(z) <- list(looks, znames) | ||
k <- 0 | ||
for (n in nvec) { | ||
parE <- t(parE) | ||
if (missing(weights)) { | ||
weights <- rep(1, nrow(parE)) | ||
} | ||
assert_numeric(weights, min.len = 0, len = nrow(par), finite = TRUE) | ||
for (n in looks) { | ||
k <- k + 1 | ||
# initialize so will return NA if 0 or n in "continue" region | ||
xL <- NA | ||
xU <- NA | ||
for (x in 0:n) { | ||
postp <- postprob(x, n, p1, parE = c(a, b)) | ||
if (postp <= tL) { | ||
postp_fut <- 1 - postprob(x, n, p0, parE, weights) # futility look | ||
if (postp_fut >= tL) { # Rule is P(RR < p0) > tL | ||
postL <- postp_fut | ||
xL <- x | ||
} | ||
if (p0 != p1) { | ||
postp <- postprob(x, n, p0, parE = c(a, b)) | ||
} | ||
if (postp >= tU) { | ||
postp_eff <- postprob(x, n, p1, parE, weights) # efficacy look | ||
if (postp_eff >= tU) { # Rule is P(RR > p1) > tU | ||
postU <- postp_eff | ||
xU <- x | ||
# done: leave innermost for loop | ||
break | ||
} | ||
} | ||
# calculate posterior probabilities at boundaries | ||
postL <- postprob(xL, n, p1, parE = c(a, b)) | ||
postU <- postprob(xU, n, p0, parE = c(a, b)) | ||
# calculate lower CI at boundaries | ||
UciL <- ifelse(!is.na(xL), stats::binom.test(xL, n, alt = "less")$conf.int[2], NA) | ||
LciU <- ifelse(!is.na(xU), stats::binom.test(xU, n, alt = "greater")$conf.int[1], NA) | ||
z[k, ] <- c(xL, xL / n, postL, UciL, xU, xU / n, postU, LciU) | ||
pL_upper_ci <- ifelse(!is.na(xL), stats::binom.test(xL, n, alt = "less")$conf.int[2], NA) | ||
pU_lower_ci <- ifelse(!is.na(xU), stats::binom.test(xU, n, alt = "greater")$conf.int[1], NA) | ||
z[k, ] <- c( | ||
xL, | ||
xL / n, | ||
postL, | ||
pL_upper_ci, | ||
xU, | ||
xU / n, | ||
postU, | ||
pU_lower_ci | ||
) | ||
} | ||
return(round(data.frame(nvec, z), 4)) | ||
round(data.frame(looks, z), 4) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,26 @@ | ||
## 40 pts trial with interim looks after each 10 pts., | ||
## efficacy decision if more than 90% probability to be above 20% ORR, | ||
## futility decision if less than 10% probability to be above 20% ORR, | ||
## with uniform prior (i.e. beta(1, 1)) on the ORR: | ||
# 40 pts trial with interim looks after each 10 pts., | ||
# Efficacy decision if more than 80% probability to be above 20% ORR, | ||
# Futility decision if more than 60% probability to be below 15% ORR, | ||
# with uniform prior (i.e. beta(1, 1)) on the ORR: | ||
boundsPostprob( | ||
nvec = c(10, 20, 30, 40), p0 = 0.20, | ||
tL = 0.10, tU = 0.90, a = 1, b = 1 | ||
looks = c(10, 20, 30, 40), | ||
p0 = 0.15, | ||
p1 = 0.20, | ||
tL = 0.60, | ||
tU = 0.80, | ||
parE = c(1, 1) | ||
) | ||
|
||
# 40 pts trial with interim looks at 7 and 20 pts. | ||
# Efficacy decision if more than 80% probability to be above 20% ORR, | ||
# Futility decision if more than 60% probability to be below 15% ORR, | ||
# with mixed prior and weights: | ||
boundsPostprob( | ||
looks = c(7, 20, 40), | ||
p0 = 0.15, | ||
p1 = 0.20, | ||
tL = 0.60, | ||
tU = 0.80, | ||
parE = rbind(c(1, 19), c(2, 10)), | ||
weights = c(0.2, 0.8) | ||
) | ||
## From this we see e.g. that at the third IA at 30 pts, we would stop for futility | ||
## if 5 or less patients responded, and for efficacy if 9 or more pts responded. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.