-
Notifications
You must be signed in to change notification settings - Fork 2
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
96 bounds predprob #105
Open
audreyyeoCH
wants to merge
64
commits into
main
Choose a base branch
from
96_boundsPredprob
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
96 bounds predprob #105
Changes from all commits
Commits
Show all changes
64 commits
Select commit
Hold shift + click to select a range
4f8d4c8
Merge remote-tracking branch 'origin/HEAD'
audreyyeoCH d4f13d0
examples and test
audreyyeoCH 7e605bf
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] bc25aeb
Merge branch 'main' into 96_boundsPredprob
audreyyeoCH 3aa565b
clean
audreyyeoCH 7e50f1c
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] d3a54b7
Merge branch 'main' into 96_boundsPredprob
audreyyeoCH 75b676e
it works
audreyyeoCH a5134f0
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] dd94883
Merge branch 'main' into 96_boundsPredprob
audreyyeoCH 1b7df26
some syntax changes
audreyyeoCH bdcf2a3
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] e180429
clean
audreyyeoCH 942e0f7
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] 23a06f3
clean
audreyyeoCH 9ffba4c
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] f6faec2
clean
audreyyeoCH 93e054c
Merge branch 'main' into 96_boundsPredprob
audreyyeoCH 3d7daf5
fix conflicts
audreyyeoCH cefe1a9
clean
audreyyeoCH aee5fb6
clean
audreyyeoCH e585093
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] eba4d49
clean
audreyyeoCH e4864b5
test case with pred prob passes with missing weights argument
audreyyeoCH 945a2b9
clean
audreyyeoCH d9cc2e3
resolve conflict when rebasing feature off main
audreyyeoCH 73b3d65
fixing conflicts
audreyyeoCH eca1581
fixing conflicts
audreyyeoCH 74e160d
conclude merge
audreyyeoCH a2194d7
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] e42ce48
clean
audreyyeoCH f544973
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] db70515
clean
audreyyeoCH ea185a8
clean
audreyyeoCH 9e42113
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] 0e94535
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] c990774
clean
audreyyeoCH 49d2847
Merge branch 'main' into 96_boundsPredprob
audreyyeoCH bb749b9
clean
audreyyeoCH fc3bd8e
clean
audreyyeoCH 7ab498b
clean
audreyyeoCH 053547d
clean
audreyyeoCH f416788
empty
audreyyeoCH abe8a2c
empty
audreyyeoCH 855dc8e
added plotBounds(boundsPredprob()) examples
audreyyeoCH a133d92
added plotBounds(boundsPredprob()) examples and plotBounds(
audreyyeoCH ed3aea6
Update R/boundsPredprob.R
audreyyeoCH 17fbce4
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] 2d1ed94
clean
audreyyeoCH 09a3744
make sure helper functions are written with all input arguments
audreyyeoCH 5dce59e
clean
audreyyeoCH 07359b7
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] 9db05d7
clean
audreyyeoCH ea10141
clean
audreyyeoCH 47d5155
clean
audreyyeoCH 4110893
RR documentation
audreyyeoCH cdcc320
clean
audreyyeoCH c661bdf
clean
audreyyeoCH 5083088
clean
audreyyeoCH 69f7ae9
Update examples/boundsPredprob.R
audreyyeoCH d7d04ef
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] 8776035
debugging on parE issue with giving correct results and other documen…
audreyyeoCH 9b912bd
[skip style] [skip vbump] Restyle files
github-actions[bot] 258ae08
clean
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 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 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,74 +1,105 @@ | ||
#' Decision cutpoints for boundary (based on predictive probability) | ||
#' Decision cutpoints for boundary (based on predictive probability) for Decision 1 rule. | ||
#' | ||
#' @description `r lifecycle::badge("experimental")` | ||
#' | ||
#' This function is used to identify the efficacy boundary and futility | ||
#' boundary based on predictive probabilities, i.e.: | ||
#' Efficacy boundary: find minimum x (xU) where | ||
#' Pr(Pr(P > p | x, Y) >= tT | x) > phiU, | ||
#' Futility boundary: find maximum x (xL) where | ||
#' Pr(Pr(P > p | x, Y) >= tT | x) < phiL | ||
#' boundary based on rules in @details. | ||
#' | ||
#' @param nvec a vector of number of patients | ||
#' @param Nmax maximum number of patients at the end of the trial | ||
#' (default: maximum of \code{nvec}) | ||
#' @param p threshold on the response rate | ||
#' @param tT threshold on the posterior probability to be above p | ||
#' @param phiL futility boundary predictive probability threshold | ||
#' @param phiU efficacy boundary predictive probability threshold | ||
#' @param a the alpha parameter of a beta prior of treatment group | ||
#' @param b the beta parameter of a 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), predictive probability | ||
#' (ppL) and posterior probability (postL), the 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), predictive probability | ||
#' (ppL) and posterior probability (postU), the lower bound of one sided | ||
#' 95% CI for the response rate based on exact binomial test (LciU). | ||
#' @inheritParams predprob | ||
#' @inheritParams ocPredprob | ||
#' @inheritParams boundsPostprob | ||
#' @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`. | ||
#' - `predL` : predictive probability corresponding to `xL` | ||
#' - `postL`: posterior probability corresponding to `xL`. | ||
#' - `pL_upper_ci` : upper bound of one sided 95% CI for the response rate based on an | ||
#' exact binomial test. | ||
#' - `xU` : the minimal number of responses that meet the efficacy threshold. | ||
#' - `pU` : response rate corresponding to `xU`. | ||
#' - `predU` : predictive probability corresponding to `xU`. | ||
#' - `postU`: posterior probability corresponding to `xU`. | ||
#' - `pU_lower_ci` : lower bound of one sided 95% CI for the response rate based on exact | ||
#' binomial test. | ||
#' | ||
#' @importFrom stats binom.test | ||
#' | ||
#' @details see also `predprob()` | ||
#' The following rules are Decision 1 rules: | ||
#' Efficacy boundary: find minimum x (xU) where | ||
#' Pr(Pr(RR > p0 | data) >= tT | x) >= phiU, | ||
#' Futility boundary: find maximum x (xL) where | ||
#' Pr(Pr(RR > p0 | data) >= tT | x) =< phiL | ||
#' | ||
#' @example examples/boundsPredprob.R | ||
#' @export | ||
#' @keywords graphics | ||
boundsPredprob <- function(nvec, Nmax = max(nvec), p, tT, phiL, phiU, a, b) { | ||
boundsPredprob <- function(looks, Nmax = max(looks), p0, tT, phiL, phiU, parE = c(1, 1), weights) { | ||
assert_numeric(looks, any.missing = FALSE) | ||
assert_number(p0, lower = 0, upper = 1) | ||
assert_number(tT, lower = 0, upper = 1) | ||
assert_number(phiL, lower = 0, upper = 1) | ||
assert_number(phiU, lower = 0, upper = 1) | ||
assert_numeric(parE, min.len = 2, any.missing = FALSE) | ||
znames <- c( | ||
audreyyeoCH marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"xL", "pL", "ppL", "postL", "UciL", | ||
"xU", "pU", "ppU", "postU", "LciU" | ||
"xL", "pL", "predL", "postL", "pL_upper_ci", | ||
"xU", "pU", "predU", "postU", "pU_lower_ci" | ||
) | ||
z <- matrix(NA, length(nvec), length(znames)) | ||
dimnames(z) <- list(nvec, znames) | ||
z <- matrix(NA, length(looks), length(znames)) | ||
dimnames(z) <- list(looks, znames) | ||
k <- 0 | ||
for (n in nvec) { | ||
if (missing(weights)) { | ||
weights <- rep(1, nrow(t(parE))) | ||
} | ||
assert_numeric(weights, min.len = 0, len = nrow(parE), finite = TRUE) | ||
for (n in looks) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If |
||
k <- k + 1 | ||
# initialize so will return NA if 0 or n in "continue" region | ||
xL <- NA | ||
xU <- NA | ||
for (x in 0:n) { | ||
pp <- predprob(x, n, Nmax, p, tT, parE = c(a, b))$result | ||
if (pp <= phiL) { | ||
predprob <- predprob( | ||
x = x, | ||
n = n, | ||
Nmax = max(looks), | ||
p = p0, | ||
thetaT = tT, | ||
parE = parE, | ||
weights = weights | ||
)$result | ||
if (predprob <= phiL) { # Futility look, Rule Pr(Pr( RR > p0 | x, Y) >= tT | x) =< phiL | ||
xL <- x | ||
predL <- predprob | ||
} | ||
if (pp >= phiU) { | ||
if (predprob >= phiU) { # Efficacy look, Rule Pr(Pr( RR > p0 | x, Y) >= tT | x) >= phiU, | ||
xU <- x | ||
# done: leave innermost for loop | ||
predU <- predprob | ||
break | ||
} | ||
} | ||
# reset xU to NA if phiU=1 and n<Nmax | ||
# reset xU to NA if phiU = 1 and n < Nmax | ||
if (n < Nmax && phiU == 1) { | ||
xU <- NA | ||
} | ||
# calculate predictive and posterior probabilities at boundaries | ||
ppL <- predprob(xL, n, Nmax, p, tT, parE = c(a, b))$result | ||
ppU <- predprob(xU, n, Nmax, p, tT, parE = c(a, b))$result | ||
postL <- postprob(xL, n, p, parE = c(a, b)) | ||
postU <- postprob(xU, n, p, parE = c(a, b)) | ||
postL <- postprob(x = xL, n = n, p = p0, parE = parE, weights = weights, log.p = FALSE) | ||
postU <- postprob(x = xU, n = n, p = p0, parE = parE, weights = weights, log.p = FALSE) | ||
# 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, ppL, postL, UciL, xU, xU / n, ppU, 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, | ||
predL, | ||
postL, | ||
pL_upper_ci, | ||
xU, | ||
xU / n, | ||
predU, | ||
postU, | ||
pU_lower_ci | ||
) | ||
} | ||
return(round(data.frame(nvec, z), 4)) | ||
round(data.frame(looks, z), 4) | ||
} |
This file contains 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 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 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 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 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,12 +1,33 @@ | ||
## 40 pts trial with interim looks after each 10 pts., | ||
## final efficacy decision if more than 80% probability to be above 20% ORR, | ||
## final futility decision otherwise. | ||
## Interim efficacy decision if more than 90% predictive probability reach this, | ||
## interim futility decision if less than 10% predictive probability. | ||
## Uniform prior (i.e. beta(1, 1)) on the ORR: | ||
# 40 pts trial with interim looks after each 10 patients. | ||
# Final efficacy decision if more than 80% probability to be above 20% ORR, | ||
# Final futility decision otherwise. | ||
# Interim efficacy decision if more than 90% predictive probability reach this or | ||
# Efficacy look Pr(Pr(RR > p0 | x, Y) >= tT | x) >= phiU, | ||
# Interim futility decision if less than 10% predictive probability or | ||
# Futility look Pr(Pr(RR > p0 | x, Y) >= tT | x) =< phiL | ||
# Uniform prior (i.e. beta(1, 1)) on the ORR: | ||
boundsPredprob( | ||
nvec = c(10, 20, 30, 40), p = 0.20, tT = 0.80, | ||
phiL = 0.10, phiU = 0.90, a = 1, b = 1 | ||
looks = c(10, 20, 30, 40), | ||
p0 = 0.20, | ||
tT = 0.80, | ||
phiL = 0.60, | ||
phiU = 0.90 | ||
) | ||
|
||
# 25 pts trial with interim looks at 7 and 15 pts. | ||
# Efficacy decision if more than 80% probability to be above 20% ORR, | ||
# Final futility decision otherwise. | ||
# Interim efficacy decision if more than 90% predictive probability reach this or | ||
# Efficacy look Pr(Pr(RR > p0 | x, Y) >= tT | x) >= phiU, | ||
# Interim futility decision if less than 60% predictive probability or | ||
# Futility look Pr(Pr(RR > p0 | x, Y) >= tT | x) =< phi | ||
# with mixed prior and weights: | ||
boundsPredprob( | ||
looks = c(7, 15, 25), | ||
p0 = 0.20, | ||
tT = 0.80, | ||
phiL = 0.60, | ||
phiU = 0.90, | ||
parE = cbind(c(1, 1), c(3, 10)), | ||
weights = c(0.2, 0.8) | ||
) | ||
## From this we see e.g. that at the first IA at 10 pts, we would stop for futility | ||
## if no patient responded, and for efficacy if 4 or more pts responded. |
This file contains 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 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 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you mention Decision 1 rule, better have a section in
@details
which references the definition of the Decision 1 ruleThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Has this been added already?