Skip to content

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 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
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 May 17, 2024
dff2ff6
delete helpers
audreyyeoCH May 21, 2024
37561fc
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] May 21, 2024
ab9ba06
clean
audreyyeoCH May 24, 2024
ab51030
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] May 24, 2024
008502d
clean
audreyyeoCH May 24, 2024
3bc1cf1
"clean+"
audreyyeoCH May 24, 2024
34a2313
empty
audreyyeoCH May 24, 2024
0cd95a7
examples and test there
audreyyeoCH May 26, 2024
51db59a
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] May 26, 2024
df9a7ca
clean
audreyyeoCH May 26, 2024
bc6dac2
Mergen"
audreyyeoCH May 26, 2024
bd327cc
NAMESPACE stuff
audreyyeoCH May 26, 2024
e25e4fd
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] May 26, 2024
c6ec5cc
empty
audreyyeoCH May 27, 2024
fe22df6
add rmarkdown to DESCRIPTIOPM
audreyyeoCH May 27, 2024
f1a2978
Merge branch 'main' into 94_helpers.R
audreyyeoCH May 27, 2024
95a6080
clean
audreyyeoCH May 27, 2024
cc665fc
Merge branch 'main' into 92_boundsPostprob
audreyyeoCH May 27, 2024
670558d
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] May 27, 2024
4f3c785
Merge remote-tracking branch 'origin/HEAD'
audreyyeoCH May 27, 2024
947e1cb
Merge branch 'main' of github.com:Genentech/phase1b
audreyyeoCH May 28, 2024
9d8a2b3
Merge branch 'main' into 92_boundsPostprob
audreyyeoCH May 31, 2024
42595d7
Merge branch 'main' of github.com:Genentech/phase1b
audreyyeoCH Jun 2, 2024
62611fa
Merge branch 'main' into 94_helpers.R
audreyyeoCH Jun 2, 2024
a29fd0f
should pass CMD checks
audreyyeoCH Jun 2, 2024
b9c7abd
Merge branch '94_helpers.R'
audreyyeoCH Jun 3, 2024
fe3f37f
see if CMD checks pass now
audreyyeoCH Jun 3, 2024
155571b
Merge branch '92_boundsPostprob'
audreyyeoCH Jun 6, 2024
9b94bba
Merge branch 'main' into 92_boundsPostprob
audreyyeoCH Jun 6, 2024
1b7d9c1
clean
audreyyeoCH Jun 11, 2024
150f243
Update examples/boundsPostprob.R
audreyyeoCH Jun 11, 2024
40afb1a
clean
audreyyeoCH Jun 11, 2024
bbb8c26
added ggplot2 in vignette
audreyyeoCH Jun 12, 2024
4bd29d1
empty
audreyyeoCH Jun 25, 2024
284c817
Merge branch 'main' into 92_boundsPostprob
audreyyeoCH Jun 25, 2024
d8ce79c
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Jun 25, 2024
98fac80
found postL
audreyyeoCH Jun 26, 2024
ed627cb
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Jun 26, 2024
e7ba41c
Merge branch 'main' into 92_boundsPostprob
audreyyeoCH Jun 26, 2024
0b2e6ad
changed params in bounds example
audreyyeoCH Jun 27, 2024
25a5b01
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Jun 27, 2024
710d404
clean
audreyyeoCH Sep 23, 2024
ce5f140
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Sep 23, 2024
3668897
clean
audreyyeoCH Sep 23, 2024
c59c148
clean
audreyyeoCH Sep 23, 2024
b748246
made it flexible for beta mixture priors
audreyyeoCH Sep 24, 2024
78fb8a5
Merge branch 'main' into 92_boundsPostprob
audreyyeoCH Sep 24, 2024
c1f312b
made it flexible for beta mixture priors
audreyyeoCH Sep 24, 2024
68a4cd2
Merge branch '92_boundsPostprob' of github.com:Genentech/phase1b into…
audreyyeoCH Sep 24, 2024
9f90ee8
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Sep 25, 2024
d11cce4
Update R/boundsPostprob.R
audreyyeoCH Sep 26, 2024
bee517e
Update tests/testthat/test-boundsPostProb.R
audreyyeoCH Sep 26, 2024
9e6047f
Update examples/boundsPostprob.R
audreyyeoCH Sep 26, 2024
e21363f
Update R/boundsPostprob.R
audreyyeoCH Sep 26, 2024
6754609
Update R/boundsPostprob.R
audreyyeoCH Sep 26, 2024
6293025
Update R/boundsPostprob.R
audreyyeoCH Sep 26, 2024
a21a776
Update R/boundsPostprob.R
audreyyeoCH Sep 26, 2024
515e021
Update tests/testthat/test-boundsPostProb.R
audreyyeoCH Sep 26, 2024
772d191
Update tests/testthat/test-boundsPostProb.R
audreyyeoCH Sep 26, 2024
929bdfa
Update R/boundsPostprob.R
audreyyeoCH Sep 26, 2024
cd923d8
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Sep 26, 2024
3075a55
clean
audreyyeoCH Sep 26, 2024
2c0d0bc
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Sep 26, 2024
75693d7
assert weights to different position
audreyyeoCH Sep 26, 2024
23973c7
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Sep 26, 2024
601c844
empty commit to make sure cmd checks pass for merge
audreyyeoCH Sep 26, 2024
ca82fc1
clean
audreyyeoCH Sep 27, 2024
d27b545
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Sep 27, 2024
f9ac9fa
ocProdprod.Rd rebuilt
audreyyeoCH Sep 27, 2024
297c0b2
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Sep 27, 2024
431291e
see if man/ocPredprob.Rd blanks out
audreyyeoCH Sep 27, 2024
1a12b88
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Sep 27, 2024
b18ccdd
did anything change from restarting session
audreyyeoCH Sep 27, 2024
733e791
Merge branch '92_boundsPostprob' of github.com:Genentech/phase1b into…
audreyyeoCH Sep 27, 2024
3b35b0f
did anything change from restarting session
audreyyeoCH Sep 27, 2024
791e2e5
checking again
audreyyeoCH Sep 27, 2024
4060b7f
that did not work
audreyyeoCH Sep 27, 2024
85790ac
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Sep 27, 2024
75045a2
clean
audreyyeoCH Sep 30, 2024
3f2aabf
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Sep 30, 2024
847839b
clean
audreyyeoCH Sep 30, 2024
dfc536e
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Sep 30, 2024
612c10f
clean
audreyyeoCH Sep 30, 2024
685d990
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Sep 30, 2024
aaad040
rebuild
audreyyeoCH Sep 30, 2024
319dd16
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Sep 30, 2024
54cbf18
clean
audreyyeoCH Sep 30, 2024
1c7c8e8
Merge branch '92_boundsPostprob' of github.com:Genentech/phase1b into…
audreyyeoCH Sep 30, 2024
431b119
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
dependabot-preview[bot] Sep 30, 2024
c1a4605
clean
audreyyeoCH Sep 30, 2024
563b8da
Merge branch '92_boundsPostprob' of github.com:Genentech/phase1b into…
audreyyeoCH Sep 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 54 additions & 48 deletions R/boundsPostprob.R
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)
}
4 changes: 2 additions & 2 deletions R/ocPostprob.R
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,11 @@ h_get_oc <- function(all_sizes, Nmax, decision) {
#'
#' Stop criteria for Efficacy :
#'
#' `Pr(truep > p1) > tU`
#' `Pr(RR > p1) > tU`
#'
#' Stop criteria for Futility :
#'
#' `Pr(truep < p0) > tL`
#' `Pr(RR < p0) > tL`
#'
#' Resulting operating characteristics include the following:
#'
Expand Down
32 changes: 24 additions & 8 deletions examples/boundsPostprob.R
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.
79 changes: 49 additions & 30 deletions man/boundsPostprob.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/ocPostprob.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading