diff --git a/R/ocPostprob.R b/R/ocPostprob.R index a1f6baf7..5384c77c 100644 --- a/R/ocPostprob.R +++ b/R/ocPostprob.R @@ -1,114 +1,263 @@ #' @include postprob.R NULL -#' Calculate operating characteristics for posterior probability method +#' Generating random distance in given looks for sample sizes for Efficacy and Futility. #' -#' The trial is stopped for efficacy if the posterior probability to be -#' above p1 is larger than tU, and stopped for futility if the posterior -#' probability to be below p0 is larger than tL. +#' A helper function for `ocPostprob` to generate random distance's wiggle room around looks `nn`. +#' Numeric looks `nn` must be of minimum two elements and will generate `length(nn)-1` distances. #' -#' Returned operating characteristics in a matrix include: -#' ExpectedN: expected number of patients in the trials -#' PrStopEarly: probability to stop the trial early (before reaching the +#' @typed nn : number or numeric +#' the union of `nnE` and `nnF` (if futility analysis or looks exists) supplied. +#' +#' @return A numeric with `length(nn)-1` elements. +#' +#' @keywords internal +#' +h_get_distance <- function(nn) { + assert_numeric(nn, unique = TRUE, sorted = TRUE, min.len = 1) + dist0 <- floor(min(nn - c(0, nn[-length(nn)])) / 2) + assert_numeric(dist0, sorted = TRUE) + sample(-dist0:dist0, + size = length(nn) - 1, + replace = TRUE, + prob = 2^(-abs(-dist0:dist0) / 2) + ) +} + +#' Generating looks from random distance +#' +#' A helper function for `ocPostprob` that applies the numeric element of `dist` to looks `nn`. +#' +#' @typed dist : numeric or logical +#' distance for random looks around the look locations in `nn`, +#' where `dist`is generated from `h_get_distance` in a numeric of at least one element. +#' If `NULL`, only one location look will be set at `nnE` or `nnF`. +#' @typed nnE : numeric +#' sample size or sizes where study can be stopped for Efficacy decision. If different for Futility decision, +#' specify in `nnF`. +#' @typed nnF : numeric +#' sample size or sizes where study can be stopped for Futility decision if different from Efficacy decision. +#' +#' @return Uses distance from `h_get_distance` to add to looks, creating wiggled looks: +#' - `nnrE` is the result for Efficacy looks with random distance added. +#' - `nnrF` is the result for Futility looks with random distance added. +#' +#' @keywords internal +#' +h_get_looks <- function(dist, nnE, nnF) { + assert_numeric(nnE) + assert_numeric(nnF) + nn <- unique(c(nnE, nnF)) + assert_numeric(nn) + assert_numeric(dist) + nnr <- nn + c(dist, 0) + list( + nnrE = nnr[nn %in% nnE], + nnrF = nnr[nn %in% nnF] + ) +} + +#' Generating random decision and sample size looks. +#' +#' A helper function for `ocPostprob` to generate numeric of decisions `decisions` and random looks `all_sizes`. +#' +#' @inheritParams h_get_looks +#' @typed nnr : numeric +#' union of `nnE`and `nnF`. +#' @typed response : numeric +#' a numeric of Bernoulli successes based on `size_look`. +#' @typed truep : number +#' assumed true response rate or true rate (scenario). +#' @typed p0 : number +#' lower Futility threshold of response rate. +#' @typed p1 : number +#' upper Efficacy threshold of response rate. +#' @typed tL : number +#' posterior probability threshold for being below `p0`. +#' @typed tU : number +#' posterior probability threshold for being above `p1`. +#' @typed parE : numeric +#' alpha and beta parameters for the prior on the treatment proportion. +#' Default set at alpha = 1, beta = 1, or uniform prior. +#' +#' @return A list of the following objects : +#' - `decision` : resulting numeric of decision, one of `TRUE` for Go, `FALSE` for Stop, `NA` for Gray zone. +#' - `all_sizes` : resulting numeric of look size, anything below maximum +#' look size is an indicated interim, Futility or Efficacy or both. +#' +#' @keywords internal +#' +h_get_decision <- function(nnr, response, truep, p0, p1, parE = c(1, 1), nnE, nnF, tL, tU) { + index_look <- 1 + assert_numeric(nnr) + size_look <- nnr[index_look] + all_sizes <- decision <- NA + response <- stats::rbinom(max(nnr), size = 1, truep) + assert_numeric(response, lower = 0, upper = 1) + while (is.na(decision) && index_look <= length(nnr)) { + if (size_look %in% nnF) { + qL <- 1 - postprob(x = sum(response[1:size_look]), n = size_look, p = p0, parE = parE) + assert_number(qL, lower = 0, upper = 1) + decision <- ifelse(qL >= tL, FALSE, NA) + } + if (size_look %in% nnE) { + qU <- postprob(x = sum(response[1:size_look]), n = size_look, p = p1, parE = parE) + assert_number(qU, lower = 0, upper = 1) + decision <- ifelse(qU < tU, decision, TRUE) + } + all_sizes <- size_look + index_look <- index_look + 1 + size_look <- nnr[index_look] + } + list( + decision = decision, + all_sizes = all_sizes + ) +} + +#' Creating list for operating characteristics. +#' +#' Generates operating characteristics. +#' +#' @inheritParams h_get_looks +#' @inheritParams h_get_decision +#' @typed nnrE : numeric +#' looks with random distance, if applied on `nnE`. +#' @typed nnrF : numeric +#' looks with random distance, if applied on `nnF`. +#' @typed all_sizes : numeric +#' sample sizes of all looks simulated `length(sim)` times if `dist` applied. +#' @typed decision : numeric +#' Go, Stop or Gray Zone decisions of all looks simulated `length(sim)` times. +#' +#' @return A list of results containing : +#' +#' - `ExpectedN`: expected number of patients in the trials +#' - `PrStopEarly`: probability to stop the trial early (before reaching the #' maximum sample size) -#' PrEarlyEff: probability to decide for efficacy early -#' PrEarlyFut: probability to decide for futility early -#' PrEfficacy: probability to decide for efficacy -#' PrFutility: probability to decide for futility -#' PrGrayZone: probability of no decision at the end ("gray zone") -#' -#' @param nn vector of look locations for efficacy -#' (if futility looks should be different, please specify also \code{nnF}) -#' @param p true rate (scenario) -#' @param p0 lower efficacy threshold -#' @param p1 upper efficacy threshold -#' @param tL probability threshold for being below p0 -#' @param tU probability threshold for being above p1 -#' @param parE beta parameters for the prior on the treatment proportion -#' @param ns number of simulations -#' @param nr generate random look locations? (not default) -#' @param d distance for random looks around the look locations in \code{nn} -#' @param nnF vector of look locations for futility -#' (default: same as efficacy) +#' - `PrEarlyEff`: probability of Early Go decision +#' - `PrEarlyFut`: probability of for Early Stop decision +#' - `PrEfficacy`: probability of Go decision +#' - `PrFutility`: probability of Stop decision +#' - `PrGrayZone`: probability between Go and Stop ,"Evaluate" or Gray decision zone +#' +#' @keywords internal +#' +h_get_oc <- function(all_sizes, nnr, decision, nnrE, nnrF) { + sim <- length(all_sizes) + assert_logical(decision, len = sim) + assert_numeric(all_sizes) + assert_numeric(nnrE, lower = 0, upper = max(nnrE)) + assert_numeric(nnrF, lower = 0, upper = max(nnrF)) + data.frame( + ExpectedN = mean(all_sizes, na.rm = TRUE), + PrStopEarly = mean(all_sizes < max(nnrF), na.rm = TRUE), + PrEarlyEff = sum(decision * (all_sizes < max(nnrE)), na.rm = TRUE) / sim, + PrEarlyFut = sum((1 - decision) * (all_sizes < max(nnrF)), na.rm = TRUE) / sim, + PrEfficacy = sum(decision, na.rm = TRUE) / sim, + PrFutility = sum(1 - decision, na.rm = TRUE) / sim, + PrGrayZone = sum(is.na(decision)) / sim + ) +} + +#' Operating Characteristics for Posterior Probability method +#' +#' @description `r lifecycle::badge("experimental")` +#' +#' Calculate operating characteristics for posterior probability method. +#' +#' It is assumed that the true response rate is `truep`. +#' The trial is stopped for Efficacy if the posterior probability to be +#' above `p1` is larger than `tU`, and stopped for Futility if the posterior +#' probability to be below `p0` is larger than `tL`: +#' +#' Stop criteria for Efficacy : +#' +#' `P_E(p > p1) > tU` +#' +#' Stop criteria for Futility : +#' +#' `P_E(p < p0) > tL` +#' +#' Resulting operating characteristics include the following: +#' +#' - `ExpectedN`: expected number of patients in the trials +#' - `PrStopEarly`: probability to stop the trial early (before reaching the +#' maximum sample size) +#' - `PrEarlyEff`: probability of Early Go decision +#' - `PrEarlyFut`: probability of for Early Stop decision +#' - `PrEfficacy`: probability of Go decision +#' - `PrFutility`: probability of Stop decision +#' - `PrGrayZone`: probability between Go and Stop ,"Evaluate" or Gray decision zone +#' +#' @inheritParams h_get_looks +#' @inheritParams h_get_decision +#' @typed sim : number +#' number of simulations. +#' @typed wiggle : logical +#' generate random look locations (not default). +#' if `TRUE`, optional to specify `dist` (see @details). +#' @typed randomdist : logical +#' Random distance added to looks. if `NULL`, and `wiggle = TRUE`, function will +#' generate and add a random distance within range of the closest looks. +#' #' @return A list with the following elements: -#' oc: matrix with operating characteristics (see Details section) -#' Decision: vector of the decisions made in the simulated trials -#' (\code{TRUE} for success, \code{FALSE} for failure, \code{NA} for no -#' decision) -#' SampleSize: vector of the sample sizes in the simulated trials -#' nn: vector of look locations that was supplied -#' nnE: vector of efficacy look locations -#' nnF: vector of futility look locations -#' params: multiple parameters +#' +#' - `oc`: matrix with operating characteristics (see @details section) +#' - `nn`: vector of look locations that was supplied +#' - `nnE`: vector of Efficacy look locations +#' - `nnF`: vector of Futility look locations +#' - `params`: multiple parameters +#' +#' @details +#' `ExpectedN` is an average of the simulated sample sizes. +#' If `wiggle = TRUE`, one can specify `dist`, though the algorithm will generate it if `dist = NULL`. +#' If `nnF = NULL`, no Futility or decision to Stop will be analysed. Note that `nnF = c(0)` is equivalent. +#' As default, `nnF` is set to the identical looks of `nnE`, and if `wiggle = TRUE`, all looks are the same, e.g. +#' `nnE = nnF` when wiggle and distance is applied. #' #' @example examples/ocPostprob.R #' @export -ocPostprob <- function(nn, p, p0, p1, tL, tU, parE = c(1, 1), - ns = 10000, nr = FALSE, d = NULL, nnF = nn) { - # Calculate operating characteristics via simulation - # nn: vector of look locations - # s: decision reject H0 (TRUE) or fail to reject (FALSE) - # during trial if continuing (NA) - - ## copy nn to nnE: - nnE <- sort(nn) - nnF <- sort(nnF) - s <- rep(NA, ns) - n <- s +ocPostprob <- function(nnE, truep, p0, p1, tL, tU, parE = c(1, 1), + sim = 50000, wiggle = FALSE, randomdist = NULL, nnF = nnE) { nn <- sort(unique(c(nnF, nnE))) - nL <- length(nn) - Nstart <- nn[1] - Nmax <- nn[nL] - if (nr && is.null(d)) { - # set parameter d for randomly generating look locations - d <- floor(min(nn - c(0, nn[-nL])) / 2) + assert_number(sim, lower = 1, finite = TRUE) + if (sim < 50000) { + warning("Advise to use sim >= 50000 to achieve convergence") } - nnr <- nn - nnrE <- nnE - nnrF <- nnF - for (k in 1:ns) { - # simulate a clinical trial ns times - if (nr && (d > 0)) { - # randomly generate look locations - dd <- sample(-d:d, - size = nL - 1, replace = TRUE, - prob = 2^(c(-d:0, rev(-d:(-1))) / 2) - ) - nnr <- nn + c(dd, 0) - - nnrE <- nnr[nn %in% nnE] - nnrF <- nnr[nn %in% nnF] - } - x <- stats::rbinom(Nmax, 1, p) - j <- 1 - i <- nnr[j] - while (is.na(s[k]) && (j <= length(nnr))) { - if (i %in% nnrF) { - qL <- 1 - postprob(x = sum(x[1:i]), n = i, p = p0, parE = parE) - s[k] <- ifelse(qL >= tL, FALSE, NA) - } - - if (i %in% nnrE) { - qU <- postprob(x = sum(x[1:i]), n = i, p = p1, parE = parE) - s[k] <- ifelse(qU < tU, s[k], TRUE) - } - - n[k] <- i - j <- j + 1 - i <- nnr[j] + decision <- vector(length = sim) + all_sizes <- vector(length = sim) + for (k in seq_len(sim)) { + if (length(nn) != 1 && wiggle && is.null(randomdist)) { + dist <- h_get_distance(nn = nn) + nnr <- h_get_looks(dist = dist, nnE = nnE, nnF = nnF) + nnrE <- nnr$nnrE + nnrF <- nnr$nnrF + } else { + nnrE <- nnE + nnrF <- nnF } + nnr <- unique(c(nnrE, nnrF)) + tmp <- h_get_decision( + nnr = nnr, response = response, + truep = truep, p0 = p0, p1 = p1, + parE = c(1, 1), nnE = nnrE, + nnF = nnrF, tL = tL, tU = tU + ) + decision[k] <- tmp$decision + all_sizes[k] <- tmp$all_sizes } - oc <- cbind( - ExpectedN = mean(n), PrStopEarly = mean(n < Nmax), - PrEarlyEff = sum(s * (n < Nmax), na.rm = TRUE) / ns, - PrEarlyFut = sum((1 - s) * (n < Nmax), na.rm = TRUE) / ns, - PrEfficacy = sum(s, na.rm = TRUE) / ns, - PrFutility = sum(1 - s, na.rm = TRUE) / ns, - PrGrayZone = sum(is.na(s) / ns) - ) - return(list( - oc = oc, Decision = s, SampleSize = n, - nn = nn, nnE = nnE, nnF = nnF, + oc <- h_get_oc(all_sizes = all_sizes, nnr = nnr, decision = decision, nnrE = nnrE, nnrF = nnrF) + list( + oc = oc, + Decision = decision, + SampleSize = all_sizes, + union_nn = nnr, + input_nnE = nnE, + input_nnF = nnF, + wiggled_Eff_n = nnrE, + wiggled_Fut_n = nnrF, + wiggle_dist = dist, params = as.list(match.call(expand.dots = FALSE)) - )) + ) } diff --git a/R/plotOc.R b/R/plotOc.R index 2e5c7caf..c4765cdd 100644 --- a/R/plotOc.R +++ b/R/plotOc.R @@ -13,7 +13,7 @@ #' @keywords graphics plotOc <- function(z) { ## plot function for oc.predprob or oc.postprob, or the dist versions of them - graphics::barplot(table(z$Decision, z$SampleSize) / z$params$ns, beside = TRUE) + graphics::barplot(table(z$Decision, z$SampleSize) / z$params$sim, beside = TRUE) ## get the parameter parDat <- lapply(z$params, deparse) diff --git a/examples/ocPostprob.R b/examples/ocPostprob.R index 22580644..23074841 100644 --- a/examples/ocPostprob.R +++ b/examples/ocPostprob.R @@ -1,40 +1,44 @@ -# operating characteristics for posterior probability method - -# design details (example) -# multiple looks @ 10, 20, 30 patietns -# True response rate of the treatment group=40% -# stop for futility: P(response rate < 20% )> 60% -# s top for efficacy: P(response rate > 30% )> 80% -# prior of treatment arm parE= Beta(1,1) -res1 <- ocPostprob( - nn = c(10, 20, 30), p = 0.4, p0 = 0.2, p1 = 0.3, tL = 0.6, tU = 0.8, - parE = c(1, 1), ns = 1000 +# For three looks of 10, 20 and 30 we have the following assumptions : +# True response rate of the treatment group = 40% +# The following are the Go and Stop rules respectively : +# Look for Efficacy: P(response rate > 30% )> 80% +# Look for Futility: P(response rate < 20% )> 60% +# Prior of treatment arm parE= Beta(1,1). +res <- ocPostprob( + nnE = c(10, 20, 30), truep = 0.40, p0 = 0.20, p1 = 0.30, tL = 0.60, tU = 0.80, parE = c(1, 1), + sim = 50000, wiggle = TRUE, randomdist = NULL, nnF = c(10, 20, 30) ) -res1$oc -# this call will generate d (distance for random looks around the look locations) -# based on "floor(min(nn - c(0,nn[-length(nn)]))/2)" as d is missing: -res2 <- ocPostprob( - nn = c(10, 20, 30), p = 0.4, p0 = 0.2, p1 = 0.3, tL = 0.6, tU = 0.8, - parE = c(1, 1), ns = 1000, nr = TRUE +res$oc + +# We specify the distance in this example. +res <- ocPostprob( + nnE = c(10, 20, 30), truep = 0.40, p0 = 0.20, p1 = 0.30, tL = 0.60, tU = 0.80, parE = c(1, 1), + sim = 50000, wiggle = TRUE, randomdist = c(-1, 3), nnF = c(10, 20, 30) +) + +res$oc + +# Here, nnE = nnF, and no wiggle room is allowed. Random distance also not supplied. +res <- ocPostprob( + nnE = c(10, 20, 30), truep = 0.40, p0 = 0.20, p1 = 0.30, tL = 0.60, tU = 0.80, parE = c(1, 1), + sim = 50000, wiggle = FALSE, randomdist = NULL, nnF = c(10, 20, 30) ) -res2$oc -# now d is specified: -res3 <- ocPostprob( - nn = c(10, 20, 30), p = 0.4, p0 = 0.2, p1 = 0.3, tL = 0.6, tU = 0.8, - parE = c(1, 1), ns = 1000, nr = TRUE, d = 5 +res$oc + +# Here, we only have one Futility and Efficacy look or stop. +res <- ocPostprob( + nnE = c(10), truep = 0.40, p0 = 0.20, p1 = 0.30, tL = 0.60, tU = 0.80, parE = c(1, 1), + sim = 50000, wiggle = FALSE, randomdist = NULL, nnF = 10 ) -res3$oc - -# finally, we can also have separate specification of efficacy and -# futility analyses. E.g. here have futility decisions only at the final analysis: -res4 <- ocPostprob( - nn = c(10, 20, 30), p = 0.4, p0 = 0.2, p1 = 0.3, tL = 0.6, tU = 0.8, - parE = c(1, 1), ns = 1000, nr = TRUE, d = 5, - nnF = c(30) + +res$oc + +# Here, we only have one Futility but many Efficacy looks or stop. +res <- ocPostprob( + nnE = c(10, 20, 30), truep = 0.40, p0 = 0.20, p1 = 0.30, tL = 0.60, tU = 0.80, parE = c(1, 1), + sim = 50000, wiggle = FALSE, randomdist = NULL, nnF = 10 ) -res4$oc -# compared to res3, we see that there is no early futility stopping anymore, -# and the overall probability for stopping for futility (which is the type II error here) -# is much lower. + +res$oc diff --git a/examples/plotOc.R b/examples/plotOc.R index 35a75cfd..930ca464 100644 --- a/examples/plotOc.R +++ b/examples/plotOc.R @@ -1,6 +1,9 @@ # get operating character result from oc.postprob -res1 <- ocPostprob(nn = c(10, 20, 30), p = 0.4, p0 = 0.2, p1 = 0.3, tL = 0.6, tU = 0.8, parE = c(1, 1), ns = 10000) +res1 <- ocPostprob( + nnE = c(10, 20, 30), truep = 0.4, p0 = 0.2, + p1 = 0.3, tL = 0.6, tU = 0.8, parE = c(1, 1), sim = 50000 +) res1$oc plotOc(res1) diff --git a/examples/postprobBeta.R b/examples/postprobBeta.R new file mode 100644 index 00000000..996ab7ee --- /dev/null +++ b/examples/postprobBeta.R @@ -0,0 +1,10 @@ +# Example taken from Lee & Liu (2006) +# We observed 16 successes out of 23 patients # should we write this in the documentation +# We set a threshold of 0.60 +# Assume a beta(0.6,0.4) prior for P_E +# Posterior will be a beta(16.6,22.8), Pr(P_E > p | data) = 0.8358808 + + +# Example taken from Lee and Liu (2006) +postprobBeta(x = 16, n = 23, p = 0.60, a = 0.6, b = 0.4) +# Interpretation : The probability 16 of 23 successes is greater than 60 % threshold is approximately 84 % diff --git a/inst/WORDLIST b/inst/WORDLIST index 93b9b0a5..b8b4f97e 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -1,4250 +1,174 @@ - -x - - -q -s - - -k - - -K -o -x - - - - - - -bqnY -E -v -D - - -h -m - - - -kJ - - -KRKo - - - - -TB -R - -K -q - -Y - - -R - - - -L -T - -F -J -P -u - - - - -V - - -u -r - -z - - -Y - - - - - - - - - - - -bp -OS - - -F - - -Q - - - - - - -c - -L - - -m - - -e - - - - -X - - -jZ - - - - - - -W -X - - -qFk - -F -R - - - -V - -M -g - - - - - -c -y - -V - - - -y -gR - - - - -B -k - -p - -vZ - - - -g -R - -p - -b -e - - - -l - - -v -n - - - - -K - - -e -m - -iJ - -T - -e -i -O - -H - - -n - -n - - - - - - -s - -t - -d - - -R - -Z - -I - -T - - - -X - -w -t - -X - - - - - - -e -i - -k - - - -S - - - - - - -B -p - - -q - - -G - - - -f - - - -B - - -e -l - - - - - - - - - - - -R - - - - -O - -Gs -r - - -xO - -y - - -O - - - - - - - -j - -V - - - - -W - - -r - -oS - -iJ - -i - - - -T - - -O - - -GcY -Uc -K -V - - - -h -Z - -R - - -T - - - -x - - - -YO - - -e - - -Jt -k -ZS - - - - - - -w - -F - -p - - - - - - -x - -x - - -t - - - - - -j -W - -U -Rw - -M -Qp - - -i - -S - - - -Y - - -u -xL - -Ckg - - -I - -M - - - - -g - - - - - - - - - - - - - -K - -U - - - -Gt - -G -q - -x - -f - -a -b - -ZOm - -F -t - - - - -O - - - - - - - - - - - - - - -K - - - - -xk - - -p - -qs - -K -KS - -G - - - - -C -m -P - -q - -C - - - -f - - -z - -p - -zO - - - - -R - - - - -a - - - -W - -JT -Q - -U -G - - - -iz -o - - - - - - - - - - -M - -l - - - - -c -q - -T - -W - - -K - - -D - - - - - - - - -Ft - - -VjM - - - -Jq -l - -aC -y -p - -j -k - - - - -i - - - - -W - -f - - -dx -C -Cj -H -K -k - -O -ha - - - -ll - - - -U - -e - - - - - -G -S - -K - - -W - -R - - -G -UO - -F - - - -B - - - -Q - - -Z - - - -f - - - -U - - -t - - -T - -H - - -vo - -Ya -P - -u - - - - -Y - -xvZ - -jJ - -K -VX -Z - - -F - - -BY -S - - - -od - -L - -R - - - -J - - -H -U - - - -XJ - - -L -s - -Oc - - - -P - - -cR -Z - -Z - - - -G -O - - - -i - - -V - - -C -J -M - - - - -E -MB - - - - - -W - - -w - - -dM -I - -d - - - -z -K - -H -j -Pk - - - - - -G -fMu - -I -O -Z - - -e - - - - - - - -GN - - - - - - - - - -f -H - -t -Uq - - -G -N -V - - -G -Rte - -M - -B -Q -sf - -k -u - - -j - - -b -I - - - -w - -w -f -A -G - -MOT -jS - - - - -H - -n - - -iB -w - - - - - - -g - - - -R - - - -v -ZT - -e - - -m - - - -c - - - - - - - -o -v - - -n - - - - - - -UAS - -z - - -M - -O - - -I - -R - - - - - - - -C -o -W - -IR - - - -a -H - - -N -w - - - -F - - -T - - - -Z - - - -M - - - - - -H - - -l - -hn - -e -J - - - - - -u -u -z - - -i - - - - -g -h - -QP -m -re -Q - - -Gs - -F - - - -R -J - - -J - - - - -g - -ib - - - -O - - - -n - - - -h - - -J -G - - -B -e - - - - - -U - -J - -vz - - - - -m -F -Mz - - - - -N - -nL -e - - -CL - - - - -E -w - -j - - - - - - -Q - -t - -m - - - - -D - - - -y - -d - -R -Xs - -s - -K - -q - -T - - -h -nfQ - - - - -J -L - -j - - - - - - -t - - - -C - - -P - -A -zY - -bS - -G -MfU -G - -Q - - - - - - -l -ne -' - -r - - - -M - - - - - -wi - - - - - -dtU - -VH -G - - -oo - - - - - - - - -g - - - - -U -B - - - - - - - - - - - -J - - - - - - - -HQ - - - - - -FaX - - - -Z - -ry - - - - - -p -m - -Xk - - - - - - - - -i -J - -a'O -a -a -A -aeZ -a -A -a -a -A -ai -aa -aaa -aaaaaa -aabd -aaYdirq -abb -abc -Abg -aC -acbad -adadad -adbbd -addon -aDHizNhDJidFZhNydEahOaDH -AE -aec -aElaqrq -aF -afbdd -afc -afd -afe -ag -aG -aH -ahR -aj -Aj -AJ -aJT -ak -akb -akShbueb -akt -aku -aL -alignRight -aM -aN -antialiased -aO -Ao -aoCDkp -Aoi -aoptions -ap -aPJ +analysed apriori -apX -aq -Aq -AQ -AQAAQBAJ -AQlV -aqtLsS -aqU -Aqz -aR -Arial -arrowrefresh -arrowreturn -arrowreturnthick -arrowstop -arrowthick -arrowthickstop -asc -ashqn -Asok -aSSObE -atD -attr -aU -Aucp -autocomplete -autocorr -autohide -autohiding -aV -aW -AWi -AwYdU -axsl -axc -axQa -ay -aY -aYV -AyyO -aZ -aZmHuanZOZgIuvbGiNeomCnaxxap -aZr -B'kd -b'N -B -b -BMB -B -bu -B -b -ba bA -backface -BAEAAAAALAAAAAABAAEAAAIBRAA -BAkBAAEALAAAAAAoACgAAAKVDI -BAkBAAEALAAAAAAoACgAAAKVjB -BAkBAAEALAAAAAAoACgAAAKWBIKpYe -BAkBAAEALAAAAAAoACgAAAKXjI -baM -barcode +ba BayesRobust bB -Bb -bbb bbeta -BbeZfMxsexY bbP -bc bC -Bc -bcbcbc -bcC -BCCC -bCL -bcO -bd +bc bD -bdbdbd bE beps betadiff bF -bfHwv -bg bG -BG -bgColorActive -bgColorContent -bgColorDefault -bgColorError -bgColorHeader -bgColorHighlight -bgColorHover -bgColorOverlay -bgColorShadow -bgImgOpacityActive -bgImgOpacityContent -bgImgOpacityDefault -bgImgOpacityError -bgImgOpacityHeader -bgImgOpacityHighlight -bgImgOpacityHover -bgImgOpacityOverlay -bgImgOpacityShadow -bgTextureActive -bgTextureContent -bgTextureDefault -bgTextureError -bgTextureHeader -bgTextureHighlight -bgTextureHover -bgTextureOverlay -bgTextureShadow bgttheta -bh bH -BHFZNr -BHk -Bhm -bhU +bh bI -bIG -bIk Binom Biometrics -Biostatistics -biQ -bj -Bj -BJ -bjQ -bjR -bkj -BKd bL -blambda bLambda -blockquote -bm +blambda bmatrix -Bml -bmtXP bmu -BMvaUEmJRd -Bn -BN -BniGFae -bo -bO -BOc boldsymbol -bomega bOmega -bootswatch -borderColorActive -borderColorContent -borderColorDefault -borderColorError -borderColorHeader -borderColorHighlight -borderColorHover -Bov -bp -bphi +bomega bPhi +bphi bpi -BPo -bpsi bPsi -bq -bQ -Bq -BQ -bqJ -BQM -bQrY -br +bpsi bR -Branson -BRr -bs +br bS +bs bsig -bsl -bt bT -Bt -BT +bt btau -btc -btheta bTheta -btn -buttonpane -buttonset -bv +btheta bV -Bv -bw bW -Bw -BW -BwQ -BWR -BWwIBtc +bw bX -Bxp bY -bz bZ -BZ -c'J -C -C -cFU -c -c -c -C -c -cA +bz calulation -caR -CArial -cb -cB -cba -CBDDA -cC -ccc -CCC -cccccc -cd -CDEFGHIJSTUVWXYZcdefghijstuvwxyz cdf -ce -cecece -ceN -cF -cG -CgM -cHuBUXKGKXlKjn -ci -cICCmoqCe -circlesmall -cj -cjg -cK -ckIOqqJ -cL -clearfix -clipPath -closethick -clR -cn -cN -cn -codrops -Codrops -colgroup comparator conjugacy -Consolas -cornerRadius -cornerRadiusShadow -cov Cov -cp -cP -cpg -cpYf -cq -cQ -CQ -cQFr -cqU -cqVeuOSvfOW -cqW -cR -CRC -CreateDate -CreatorTool -cRJ -cRRS -cS -Csans -css -cT -cUjT -CUr +cov cutB cutW -cV -Cv -cW -cwv -cx -CXmO -CxW -cy -cY -Cy -cYR -cYy -cz -Cz -cZI -d -D -d -D -d -D -d -d -d -d -Dm -D -da -dadada -dataTable -datatables -dataTables -DataTables -datepicker -datetime -db -dBe -dbetabinom -DCBCBC -dcc -DCC -dcL -dD -DD -dDalQWPVOsQWtRnuwXaFTj -ddd -DDD -dddddd -de -dE -DEb decisian -dede -DejaVu deltaE deltaF -deltaFu DeltaFu +deltaFu deltaW -DerivedFrom -desc det -Df -DF -dff -dfn -dfw -dg -dG -Dg -Dh -di -diag -dIbY diffience -DiHWMcYJah -DiJti -dirR -dismissable -dismissible -DisV -dItwjYKBgo -divoptions -dJ -dK -Dk -DK -dl -Dl -dM -dnN -documentID -DocumentID doi -doJ -dolby DoR -dp dP -Dp -dq -dQ -DQ -dR -draggable -DrF -dRL -dropdown -dropup -ds -DS -DSS -dt -dT -DTTT -dtU -du -dU -Dunson -DV -dw dW -DWV +dw dX -DX -dxeo -DXImageTransform -dxJ -dXj -DXJT -dy dY -dygraph -dygraphs -dYV -DyV dZ -E'Y -e -e -Eo -E -EH -e -E -EiZ -eb -e -e -ea -eaeaea -EaX -eB -Eb -EB -ebcccc -ebD -EBDADA -ebebeb -eBTfu -ec -eC -ecb -ECEC -ecec -eCG -edec -edf -edqqWQAAIfkECQEAAQAsAAAAACgAKAAAApSMgZnGfaqcg -ee -eE -Ee -EE -EEeV -EEE -eee -eeeeee -eEH -eeR -ef -eF -EF -EFWOT -eg -Eg -eH -ehA -Ei -EI -EIe -eiFKX -eiMYWT -ej -eJ -EJ -EJI -Ejk -EJn -ek -eK -ek -ekpObkpOlppWUqZiqr -eKy -El -EL -ElU -eM -eM -eN -endColorstr -eNnP -eNVcojuFGfqnZqSebuS -eo -eO -Eo -EO -eot -ep -Ep -ephx -epP eq -eQ -Eq -EQ -EQ -EQJJ -Eqz -eR -eRi -ERp -eRx -eS estunated -ESU -et -eT -eu -Eue -eUQT -eur -EUu -EUUM -EUV -eV -EV -ew -Ew -eWqNfHuMjXCPkIGNileOiImVmCOEmoSfn -eX -exMb -exO ExpectedN ExpectedNactive ExpectedNcontrol -extlink -ey -eY -eyQTU -eYQU -eYVc -Eyy -ez -eZ -EZ -ez -ezuAw -F -F -f -f -fu -F -f -F -f -F -f -fYF -f -F -Fg -F -f -FAAACH -facetime -faf -fafafa -fb -Fb -FB -fbf -fbfbfb -fc -Fc -FC -fcActive -fcContent -fcDefault -fcefa -fcError -fcf -FCFAFA -fcfafa -fcHeader -fcHighlight -fcHover -FCMt -fd -Fd -fdfdfd -fe -febc -fef -ffDefault -fff -FFF -ffffff -FFL -fg -FG -fgoSUI -Fgz -fh -fH -FHBCKoDeWKXqymPqGqxvJrXZbMx -fI -FI -fieldset -figcaption -fiW -fIX -Fj -fk -fK -FLr -fluz -fM -FmNI -Fmt -fn -fN -Fn -FN -FNWtcFWe -FNWtMFWW -fO -FO -FoCCH -focusable -fod -Fou -FoZ -Fp -FP -FPK -fq -fQ -Fq -FQ -fQN -fqr -fR frac -frDVpxZZc -FrRjs -FrX -fs -fS -Fs -FS -fsDefault -fsL -FSZ -fT -FTrl -fu -fU -Fu -FU -fullscreen -fv -FVFNDQVBFMi -FVfv -fW -FW -fwDefault -fwi -fwSk -FWZs -fx -Fx -FX -fy -fY -Fy -fyFa -fYI -FyV -fz -G'QJ -G -g -Gp -g -g -gd -G -g -GY -g -GF -GC -g -ga -gA -gb -gB -Gb -gBmS -gbp -GBqJ -gby -gC -Gc -gelman -Gelman generalizable -geometricPrecision geq -getbootstrap -GEZt -gf -gF -GF -Gfa -gFI -gg -GG -ggplot -ggs -gh -GH -GhV -gI -github -GJ -GjrRU -GJY -GJz -gk -gK -gkz -gL -glyphicon -glyphicons -Glyphicons -Gmh -gMWZ -gn -GN -gnM -gnWGfHNdjIqDWVqemH -gO -googleapis -GOQ -Gor -gQ -Gq -GQ -gR -GradientType -Grande -grayscale grayzone -gripsmall -gS -gsk -Gsponer -gu -gU -Gu -gv -gV -GV -gVw -gw -gW -Gw -GWEu -GWgw -GWi -gwO -gX -Gx -GxNso -gY -Gy -GY -gyHUkFj -gZ -Gz -GZ -h -h -h -Hx -h -h -hW -h -h -h -H -h -h -H -h -halflings -Halflings -halflingsregular -hb -hB -Hb -HB -Hbj -Hbja -hbk -hc -hcd -hd -Hd -HD -hdd -Hdd -hDt -HelveticaNeue -hF -hG -Hg -hgroup -hh hier -HIn -hiPKqWn -hJ -HJ -hjq -HJX -hk -hkh -hKK -hKU -hl -Hl -HLgd -Hm -hmaPL -HmHEb -hMVVcNl -hn -hN -Hn -HNP -hO -HOMM -hP -hpj -hQ -hR -hRa -href -hroptions -hrtableoptions -Hs -hT -HtH -Htt -http -https -hu -hU -Hu -HU -humO -hv -hV -HvAWhpiUdcwkpBH -hVQ -HVu -hw -hW -Hwt -hx -HX -HXhx -hY -Hy -hYBzkpuUh -HycXJHUXiGYIiMg -HyjJ hyoithesis hyperprior -HyR -hz -hZ -hz -hzbH -hzu -I'f -I'iG -I'o -i -i -I -iaIAa -i -I -irP -I -i -IC -iE -iAU -i -IQI -IF -I -icM -iF -i -i -iF -ia -iA -IAV -IABSty -ib -iB -Ib -IBK -ibp -IBS -ic -iC -IC -iconColorActive -iconColorContent -iconColorDefault -iconColorError -iconColorHeader -iconColorHighlight -iconColorHover -idff -ie -iE -Ie -iefix -iEV -iF -IFGiU -iFI -iframe -IFu -ig -iG -Ig -IG -IGZGKLnNpYtm -ih -Ih -IHDR -IHkQ -iI -iioKSXpUAAAh -iJ -Ij -IJk -IJUc -IjYJvjWKcnoGQpqyPlpOhr -ik -Ik -IkA -iko -il -iL -Il -ilYuWYpmTqKUgAAIfkECQEAAQAsAAAAACgAKAAAApiEH -iM -IM -IMA -img -Immz -IMUUE -iN increasement inefficacious -iNI -INp -instanceID -InstanceID integrations -Inu -inV -io -iO -iOG -Iol -iooAnx -ioOGhXGJboGAnXSBnoBwKYyfioubZJ -IOQ -iow -ip -ipc -iq -iQ -Iq -iqs -IQT -ir -iR -IR -irs -iS -isbn -IST -iT -itR -Itt -iu -iU -IU -IUU -iV -iVr -iw -iW -Iw -IW -IWk -Iy -IY -IYF -IYiy -iyt -iz -iZ -Iz -IZ -izF -izO -izw -jY -j -J -j -j -jE -J -j -juu -J -J -JA -JafV -javascript -jba -jC -Jc -JccR -Jd -jDQ -jDux -JE -Jes -jf -jF -jG -jh -Jh -JH -JHe -ji -JI -JiK -jIBr -JiF -JIU -Jj -JJ -JJi -jJn -JjZ -jk -jK -JK -JktP -jm -jM -Jm -JM -jmn -jmY -jN -Jn -JN -jNK -JnP -jo -jO -JOD -JOn -jp -jP -jpF -jPr -jps -JPU -jpy -jq -jQ -Jq -JQ -JqfRVLHU -jQi -JQM -JqS -JQS -jQuery -jqueryui -jR -jrAa -jROC -jrupsi -jrx -js -jS -JsJ -jSQ -JSQ -Jsw -jt -jT -Jt -JT -jts -ju -Ju -JU -jUc -jujm -jumbotron -JuRs -jUz -jV -Jv -jVVh -jw -jW -Jw -JW -jWI -jx -Jx -JX -Jxn -jXOKT -JXx -jXZ -jy -jY -Jy -JY -jz -jZ -Jz -JZjz -jzV -K -k -K -KW -K -K -k -ka -Ke -kd -k -KI -k -K -k -K -KGSr -k -ka -kA -Ka -KA -kAACH -kalX -kb -kB -kbd -KBlpVpbluCiXmMnZ -kC -KCC -kd -kdy -ke -kE -Ke -KE -kEI -keyframes -kf -kF -Kf -KF -KfuJ -kG -kGM -kh -kH -KH -KHFu -khu -KhZrKt -ki -KI -Kiuk -kj -kJ -Kj -KJ -kk -kK -KK -kkkx -KKl -kkQ -KKq -klw -kM -kmi -kN -ko -kO -Ko -KON -koO -kORTVrVhRlsnn -kOxTVrXNVlv -kp -kP -kQ -KQ -kR -kR -KRgm -KRY -kS -kT -KtkT -KTz -kU -KU -kUs -Kuv -kv -KV -kz -kZ -l'L -L -ln -l -L -LgW -l -L -l -lA -lAAACH -LaP -lccn LciU -Lcx -lCXjcW -LdCt -lDFk ldots -le -lE -Let -lEE -Leonhard leq -LEQ -LEZ -lf -lF -Lf -LF -LFd -lfG -lfM -LFWU -Lg -lGODlhAQABAIAAAAAAAP -lGODlhKAAoAIABAAAAAP -lh -Lh -LHo -lHY -li -lI -lifecycle -lightbulb -linearGradient Liu -lJ -Lj -ljZ -lKXe -lL -Lle -ller -lln -lm -LM -LmHS -LmKSllZmsoq -ln -lN -LNn -lno -lOyQRWET -lp -Lpj -lpLn -lq -LQ -lQAACH -lql -Lsh -lt -lT -Lt -lu -lUcBj -Lucida -lULTk -lv -lV -Lv -LV -lVX -lW -LW -lWK -lww -LX -ly -lY -LY -lYCMlJOXipGRr -Lymp -lz -lZ -Lz -LZl -m'G -M'RK -Mk -mfY -Mo -M -m -M -MrKK -M -M -m -mv -m -me -mYV -m -Maiq -MAs mathbb mathbf mathcal -mB -mBm mbox -MbR -MbU -mc -Mc -MCN -mCQ -md -mE -mEE -Menlo -MERCHANTABILITY -mEZT -mf -Mf -MF -MFH -MFY -MFZI -mG -MgH -mGhZOfeYSUh -mh -mH -Mh -mI -MIi -mIJ -minusthick -mj -mJ -Mj -MJ -MJQ -Mjy -Mjz -mk -Mkco -MKMy -MlB -mLD -mM -mmP -mmq -mMRae -mn -mN -MNg -mNn -MNSU -MNzb -mO -ModifyDate -monospace -mOT -moz -mq -MQ -MQdQd -mR -Mr -Msi -MsM -MSR -mSu -mT -Mtm -mU -multiparam -multitrace -mv -mV -mw -Mw -mwus -mx -MX -MXSFi -mY -mYF -mZ -Mz -MZ -N'zz -n -n -nE -N -njN -N -n -N -n -n -nM -n -n -na -nA -nav -navbar -NAVBAR -navlist -nb -nC -Nc -Nce -nCi -Ndd -nDW -ne -nE -necolas -Neue -Neuenschwander -NEv newcommand -newwin -Nf -NFaA -nG -Ng -Ngm -nh -nhHuui -nhHvw -nI -nj -nJ -NJR -nk -Nk -NK -NKI -nKw -nl -nL -NL -nlc -Nln -NlxXW -nlY -nm -nM -Nmp Nmax NmaxControl nn -nN -Nn -NNCuJ nnE nnF -nnf nnr -nnR -Nou -noa -nomtJjp -NONINFRINGEMENT -nowrap -nOY -noyraJ -NPd -nq -nQ -NQ -NQT -nR -NrwNRn -nrX -ns nS -Ns -nSd -nt -nT -Nt -NtpX -Ntrjy -nTx -nU -nUc -NUs -nw -nW -nWqq -nx -nX -Nx -NX -nxH -NxL -NXu -Nxyg -ny -Ny -Nyg -NYq -nz -nZ -nzPTdJZlR -nZxt -O -O -O -OJ -O -o -O -o -O -ou -o -o -oA -O -O -O -O -O -oa -Oblz oc -OcK -od -oE -Oe -oeN -oF -oF -offsetLeftShadow -offsetTopShadow -OFt -og -oG -Og -oI -OiB -oj -oJid -oK -okK -OKmF -ol -oL -Ol -OL -oLK -oLf -oln -oLvoxuJDkU -oM -omq -oN -onlinelibrary -OnvYP -oo -oO -Oo -OO -ooe -OONb -OOP -Ooq -OozeL -oP -opacityOverlay -opacityShadow -oPb -opentype -optgroup -optionswell -oq -oQ -Oq -OQ -oRj -os -oS -oSaWlu -osx -ot -Ot -oTo -Ott -oU -Ou -OU -ouks -Ouu -oV -ovC -oVe -OVWR -oVxY -oW -OwNnJ -oWV -OWW -oX -oy -oY -OY -OZ -oZY -p'W -P -P -P -P -P -PApl +ocPostProb params -parE -parseType parX parY -pb -pB -pbvwfWEMWBQ -pc -pD -pe pE -Pe -pF -pFG PFS -pG -PG -PGEBl -ph -Ph -pHgzJXTEeGlZuenpyPmpGQoKOWkYmSpaSnqKileI -phiFu PhiFu +phiFu phiL phiU -phZ -PiMu -pj -pJ -Pj -PJiYVzR -pjN -pjr -pKe -PkGf pL -plusthick -pM -pma -pN -Pn -PN -png -pNi -pNK -pO -pointmass PointMass +pointmass postL postprob postU -pP -ppd ppL PProbust PPs -pq -pQ -PQz -pR -pRCavZ -pre PrEarlyEff PrEarlyFut PrEfficacy -prev PrFutility PrGrayZone priori proabilities -progid -progressbar propto PrStopEarly pS -Ps -pT -pu pU -Puf -puiK -pUunBmtRXo -pv -PV -pVXI -pw -Pw -pwI -px -pX -Px py -pY -pyF -pyGMm -pyn -pYu -pyv pyz -pz -QI -q -q -qb -Qj -Q -ql -q -q -qa -qA -qb -qB -Qb -qc -qD -qdgoSTrqWSq -qE -Qe -Qee -QeY -qEznH -qf -Qf -qFk -qFO -qg -qG -Qg -qh -QH -qH -qi -qI -Qil -Qiw -Qj -QJ -Qjg -qk -QK -Qki -qKuv -ql -qL -qLVhBVeT -qm -Qm -qm -QmE -qn -Qn -QN -qNTWvRdQxP -Qo -QO -QPwq -qq -qQ -Qq -QQJAQABACwAAAAAKAAoAAACkoQRqRvnxuI -QQJAQABACwAAAAAKAAoAAACkYwNqXrdC -QQJAQABACwAAAAAKAAoAAAClYx -qQQ -qR -qrC -qrcode -qre -QRR -qs -qS -QS -qsex -QSRJ -qT -QTv -QTw -qu -qU -QU -QUfau -Qv -QV -qvaC -qvm -qw -Qw -QW -qwk -QwQ -Qwuu -qWv -qX -Qx -QX -qxik -qXjzn -qxLD -qxs -QxwX -qy -QY -QyT -qz -QZ -R -R -r -R -r -RY -R -r -r -rj -r -raj -RAn -rB -rc -Rc RCT -rdf -RDF -rdv -rE -readonly -rect refering renewcommand -rES -resizable -ResourceRef responder responders -ret -rf -rG -RG -rgba -rGERh -rGg -rgu -Rh -Rhh -Ri -rImrO -RIS -rj -rJ -RJ -rK -Rk -rl -RL -rLn -rM -RMjr -RMY -rn -rN -rnWepg -rO -Ro -RO -roK -Rp -RpO -rPT -rq -rQ -Rq -RQ -rQTR -rr -rR -RRg -rseztfXZjdIWIf -RTk -rtl -RTL -rU -rufF -RuRZaflZOil -RUu -rw -Rw -Rwn -rx -rX -rXd -RxG -Rxxzs -ry -rY -ryp -RYU -RYx -rz -rZ -Rz -s -s -s -se -SX -S -Sg -S -Smm -s -sa -sA -Saban -sabanes -samp SampleSize SampleSizeActive SampleSizeControl -sB -sbo -sc -scrollable -scrollbar -scrollBody -sd -se -sE -selectable -selectmenu seperate -sER -sF -sFjg -sFT -sg -sG -SG -SGy ShinyPhase -shinystan -shinyStan -sI -SIF -sj -Sj -sJR -sk -sl -sL -sLE -sLEUO -slmLUZ -sLw -sm -sM -sM -sN -sNN -snzf -sO -sortable -sOu -sp -sPj -SPK -springer -Springer -sQ -sQ -SQe -SQJ -sqr -squaresmall -sr -sR -src -SrN -sRx -ss -Ss -sT -stan -startColorstr -sTP -stRef -sType -sU -Su -SU -SUa -sublicense -Sud -SUi sumbetadiff summerize summerizes sumTable surivival -sV -Sv -SV -svg -svo -sVq -sw -sW -Sw -sx -Sx -Sx -sxk -sy -sY -SY -sy -sZ -SzNeowWBENtQd -T'J -t -t -T -twy -T -t -T -Tg -T -t -t -t -tableoptionswell -TableTools -tabpanel -tbody -tC -TCH -tci -td -te -TEQ -tex -textarea -textfield -textInput -textLength texttt -Tf -tfoot tFu -tg -Tg -tgg -TgRQ -th Thall -thead -themeroller thetaT -thicknessShadow -ThJ throshold -tI -Ti -Tibp -Tij -TIjQS -titlebar -Tj -TJ -TjEy -TjrU -tk -tl tL -tm -tnSeOZXhmn -tO todo -tooltip -tp -Tp -TP -tPY -tq -tQ -Tq -TQ -tR -transferthick -translateY -truetype -tSHGZO -TsiMAgswmNYrSgZdYrTX -TsL tT -Tt -TT -Ttc -ttf -TTNOocQ TtR -ttw -tu tU -Tui -tutKoNWkvA -TUUeY -tuy -tv -twbs -TWG -tx -tX -Tx -TxO -TYM -tympanus -tZ -Tz -tZH -tzr -u' -uI -U -UyEy -Ud -Ux -U -U -UMZ -U -Uz -U -U -U -uA -Ua -UA -uao -uAA -ub -Ub -UBh -UBm -uc -uC -UcA -ucC UciL -ud -Ud -uDD -ue -uE -Ue -UE -UeQ -UER -Uf -UF -ufODGjRfoiJ -uG -Ug -UG -uH -uhK -ui -uI -Ui -UI -uIf -Uir -uj -UJ -ujK -ujx -uk -uK -Uk -ukf -ukg -UkuvFtXpvWSzA -ul -ULs -uM -Umu -un -unb -unstyled -uNt -uo -uO -UO -UOi -uP -upaCZsq -Upqip -upr -uPVDZxQIR -upy -uQ -Uq -UQ -UQdE -UQqu -uqU -URXYc -usd USUBJID -usw -ut -UTq -uu -uU -UU -UUA -UUe -UUI -uuolffh -uUT -UUUUJ -uUVJ -uuzDmmHUBR -uv -uV -Uv -uVJN -uw -UW -ux -uX -Ux -UX -UXe -uxg -uxuQ -uy -Uy -uYb -uyU -uz -uZ -Uz -V -v -vo -v -Vw -vQ -v -v -v -V -va -VAAAOw VAD vanillaBayes vanillaPP -vc -Vcuuv -vD -Vdy -VE -VEB -Vehtari -Verdana -VexUHpzjymViHrFbiELsefVrn -vf -vF -VfH -VfP -VfZyfkJGkha -Vg -Vh -VH -vI -vix -vIP -VIR -Vj -VJK -vJRt -VJUg -vk -vK -VK -Vki -VkQ -vl -Vl -VL -vm -vM -VMe -vMk -vMSG -Vmv -vMvxRdHlbEFiEXfk -vN -VN -vO -Vo -VO -volkhov -Volkhov -Vp -VpZRedYcflIOLafaa -vq -vQ -Vq -VQ -vqB -vqOz -vQS -VqX -vR -VR -Vrk -VRR -vRXxV -vSM -vsN -vt -vT -vTW -vu -Vu -VU -VuC -vUWhWNkWFwxl -vUxNWWjV -vV -Vv -VV -vva -vvh -vvI -vVj -VvWZfeB -Vw -VW -vWi -vx -vX -Vx -VX -Vx -VxY -vy -Vy -VY -Vyb -Vyz -vZ -VZ -VzJ -W'q -Wv -w -WD -W -W -W -w -w -W -wa -wAwEAAAAh -wb -wB -Wb -WB -WBd -Wbz -Wd -WDQ -wE -webkit -wf -WF -WFl -wFr -wg -wG -WG -wgwo -wh -whitesmoke -WHuMhIl -Wi -WIJ -wiley -wiR -wj -Wj -WJ -WJP -wK -wkh -Wku -WKuZ -wl -WL -wM -WmA -wn -WN -wo -wO -Wo -woO -woff -wp -wP -Wp -wpQAAAh -wq -wQ -Wq -WQ -wR -Wr -WR -Wr -wrj -Wrvx -ws -wtI -WtI -WTk -wu -wU -wuq -wV -Wv -wv -wvQ -ww -wW -wWm -wWnS -Wwq -www -wWz -wx -wX -WXI -wY -Wy -wz -wZ -wzk -Xy -X -xY -xa -XLm -xj -X -x -X -Xm -X -xHss -XS -X -x -xd -x -xa -xA -Xa -Xah -xap -xb -xB -xbt -XBV -xBYEkYvFSM -xc -xC -XC -xcIGAdXqMfBNadoYrhH -xct -Xd -Xdie -XdsH -xex -XF -XfPkeLmm -XfY -xg -xG -Xg -xGG -Xgi -xGK -XgU -xh -xH -Xh -XHd -XHN -xhzzk -xI -xIb -xIU -xj -xJ -Xj -XJ -Xjqx -XJr -XJT -xjx -xjX -xjy -xk -xKF -XKfnt -xKI -xl xL -XL -xlF -xlink -xlV -XLVk -XlvKF -xm -Xm -XM -xmlns -xmp -XMP -xmpmeta -xmpMM -xmptk -xn -xN -Xn -XN -xo -xO -Xo -XO -xOc -xod -xoG -xOG -xoL -xOl -xp -xP -Xp -xpacket -xq -xQ -XR -xs xS -XsG -xSI -xt -xT -Xt -xTqlLGhtCosArKMpvfa -xu xU -Xu -XU -xV -xw -xW -XW -xwG -xwO -xWUW -xwX -xX -XXN -XxxFl -xy -xY -Xy -XY -Xyar -xyB -xyf -xYVua XYZ -xz -xZ -Xz -XZ -Xz -xza -xzb -xZF -xzi -Xzkh -xzoom -xzQ -XZXhNs -Y'v -yt -y -Y -YZ -y -yA -yaq -YARYxOZZD -yaYQzXO -yB -YBT -yc -yC -Yc -YC -yEE -yeL -yf -yF -Yf -YF -YFt -YFW -yg -yG -YG -yGJ -yH -YH -yHOGpWMyorblKlNp -yi -yI -Yi -YIG -YIGEhYuOUn -Yiw -yJcJyrkZWWpaR -yJJ -Yk -YK -yke -ykP -yl -yL -YL -ylW -ym -yM -Ym -YM -YM -yn -yN -Yn -yng -yNI -Ynj -YNKToqswUlvznigd -ynlcc -yNQ -YNU -YNy -yO -yO -YOb -yP -Yp -YP -ypoaUAAAIfkECQEAAQAsAAAAACgAKAAAApaEb -YPY -yQ -Yq -YQ -yQlZmZ -yR -yrq -yS -YS -ySj -yt -Yt -yti -yu -yU -Yu -YU -yulD -yUQX -YUZbJ -yv -yV -YV -YVd -yvi -yvkS -yvS -yW -YW -ywPH -yx -Yx -YX -YxJ -yXlJWmoHGhqp -YXP -Yxw -yy -yY -Yy -YY -YYZ -yZ -YZ -yZq -z -z -z -z -ZP -z -ZN -ZR -Z -Z -Z -Zu -Z -ZA -zb -zB -ZB -zC -ZC -zCC -zcG -Zd -ZDvp -ze -Zeh -zf -Zf -zff -zfix -zfo -zFwP -zg -zG -ZgRl -Zh -ZhzC -zi -zI -ZI -ZIa -ZIY -zj -Zj -ZJp -zk -zK -Zk -zka -zKGlLIhskiEPm -ZKK -zky -zl -zL -Zl -ZL -ZleFaptFrb -zm -zM -Zm -zn -zN -ZnINRNqosw -zo -Zo -ZO -zoEe -Zoj -zoomin -zoomout -ZOyma -zp -zP -Zp -ZP -Zpe -ZQ -zQfv -ZRb -ZrN -Zrs -zSUiRsQ -zt -Zt -ZT -Zt -zTi -Zth -ZTHyxL -ZTr -ZTs -Ztxo -ZtZ -zu -Zu -ZU -Zu -zUg -ZUK -ZUq -zV -Zv -zvm -zw -zW -Zw -ZW -zWtsmf -zX -Zx -ZX -ZxGR -ZXhWqbRa -ZXL -ZXlExa -ZXLUJ -zxxJ -zy -zYSj -zyxwvutsrqponmlkjihgfedcba -ZYXWVUTSRQPONMLKJIHGFEDCBA -zz -Zz -ZZ -ZzWT diff --git a/man/h_get_decision.Rd b/man/h_get_decision.Rd new file mode 100644 index 00000000..623bd861 --- /dev/null +++ b/man/h_get_decision.Rd @@ -0,0 +1,43 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/ocPostprob.R +\name{h_get_decision} +\alias{h_get_decision} +\title{Generating random decision and sample size looks.} +\usage{ +h_get_decision(nnr, response, truep, p0, p1, parE = c(1, 1), nnE, nnF, tL, tU) +} +\arguments{ +\item{nnr}{(\code{numeric}):\cr union of \code{nnE}and \code{nnF}.} + +\item{response}{(\code{numeric}):\cr a numeric of Bernoulli successes based on \code{size_look}.} + +\item{truep}{(\code{number}):\cr assumed true response rate or true rate (scenario).} + +\item{p0}{(\code{number}):\cr lower Futility threshold of response rate.} + +\item{p1}{(\code{number}):\cr upper Efficacy threshold of response rate.} + +\item{parE}{(\code{numeric}):\cr alpha and beta parameters for the prior on the treatment proportion. +Default set at alpha = 1, beta = 1, or uniform prior.} + +\item{nnE}{(\code{numeric}):\cr sample size or sizes where study can be stopped for Efficacy decision. If different for Futility decision, +specify in \code{nnF}.} + +\item{nnF}{(\code{numeric}):\cr sample size or sizes where study can be stopped for Futility decision if different from Efficacy decision.} + +\item{tL}{(\code{number}):\cr posterior probability threshold for being below \code{p0}.} + +\item{tU}{(\code{number}):\cr posterior probability threshold for being above \code{p1}.} +} +\value{ +A list of the following objects : +\itemize{ +\item \code{decision} : resulting numeric of decision, one of \code{TRUE} for Go, \code{FALSE} for Stop, \code{NA} for Gray zone. +\item \code{all_sizes} : resulting numeric of look size, anything below maximum +look size is an indicated interim, Futility or Efficacy or both. +} +} +\description{ +A helper function for \code{ocPostprob} to generate numeric of decisions \code{decisions} and random looks \code{all_sizes}. +} +\keyword{internal} diff --git a/man/h_get_distance.Rd b/man/h_get_distance.Rd new file mode 100644 index 00000000..2057d3e4 --- /dev/null +++ b/man/h_get_distance.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/ocPostprob.R +\name{h_get_distance} +\alias{h_get_distance} +\title{Generating random distance in given looks for sample sizes for Efficacy and Futility.} +\usage{ +h_get_distance(nn) +} +\arguments{ +\item{nn}{(\verb{number or numeric}):\cr the union of \code{nnE} and \code{nnF} (if futility analysis or looks exists) supplied.} +} +\value{ +A numeric with \code{length(nn)-1} elements. +} +\description{ +A helper function for \code{ocPostprob} to generate random distance's wiggle room around looks \code{nn}. +Numeric looks \code{nn} must be of minimum two elements and will generate \code{length(nn)-1} distances. +} +\keyword{internal} diff --git a/man/h_get_looks.Rd b/man/h_get_looks.Rd new file mode 100644 index 00000000..303add1f --- /dev/null +++ b/man/h_get_looks.Rd @@ -0,0 +1,29 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/ocPostprob.R +\name{h_get_looks} +\alias{h_get_looks} +\title{Generating looks from random distance} +\usage{ +h_get_looks(dist, nnE, nnF) +} +\arguments{ +\item{dist}{(\verb{numeric or logical}):\cr distance for random looks around the look locations in \code{nn}, +where \code{dist}is generated from \code{h_get_distance} in a numeric of at least one element. +If \code{NULL}, only one location look will be set at \code{nnE} or \code{nnF}.} + +\item{nnE}{(\code{numeric}):\cr sample size or sizes where study can be stopped for Efficacy decision. If different for Futility decision, +specify in \code{nnF}.} + +\item{nnF}{(\code{numeric}):\cr sample size or sizes where study can be stopped for Futility decision if different from Efficacy decision.} +} +\value{ +Uses distance from \code{h_get_distance} to add to looks, creating wiggled looks: +\itemize{ +\item \code{nnrE} is the result for Efficacy looks with random distance added. +\item \code{nnrF} is the result for Futility looks with random distance added. +} +} +\description{ +A helper function for \code{ocPostprob} that applies the numeric element of \code{dist} to looks \code{nn}. +} +\keyword{internal} diff --git a/man/h_get_oc.Rd b/man/h_get_oc.Rd new file mode 100644 index 00000000..53231d27 --- /dev/null +++ b/man/h_get_oc.Rd @@ -0,0 +1,36 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/ocPostprob.R +\name{h_get_oc} +\alias{h_get_oc} +\title{Creating list for operating characteristics.} +\usage{ +h_get_oc(all_sizes, nnr, decision, nnrE, nnrF) +} +\arguments{ +\item{all_sizes}{(\code{numeric}):\cr sample sizes of all looks simulated \code{length(sim)} times if \code{dist} applied.} + +\item{nnr}{(\code{numeric}):\cr union of \code{nnE}and \code{nnF}.} + +\item{decision}{(\code{numeric}):\cr Go, Stop or Gray Zone decisions of all looks simulated \code{length(sim)} times.} + +\item{nnrE}{(\code{numeric}):\cr looks with random distance, if applied on \code{nnE}.} + +\item{nnrF}{(\code{numeric}):\cr looks with random distance, if applied on \code{nnF}.} +} +\value{ +A list of results containing : +\itemize{ +\item \code{ExpectedN}: expected number of patients in the trials +\item \code{PrStopEarly}: probability to stop the trial early (before reaching the +maximum sample size) +\item \code{PrEarlyEff}: probability of Early Go decision +\item \code{PrEarlyFut}: probability of for Early Stop decision +\item \code{PrEfficacy}: probability of Go decision +\item \code{PrFutility}: probability of Stop decision +\item \code{PrGrayZone}: probability between Go and Stop ,"Evaluate" or Gray decision zone +} +} +\description{ +Generates operating characteristics. +} +\keyword{internal} diff --git a/man/ocPostprob.Rd b/man/ocPostprob.Rd index a60b2d55..92d6a9f4 100644 --- a/man/ocPostprob.Rd +++ b/man/ocPostprob.Rd @@ -2,114 +2,139 @@ % Please edit documentation in R/ocPostprob.R \name{ocPostprob} \alias{ocPostprob} -\title{Calculate operating characteristics for posterior probability method} +\title{Operating Characteristics for Posterior Probability method} \usage{ ocPostprob( - nn, - p, + nnE, + truep, p0, p1, tL, tU, parE = c(1, 1), - ns = 10000, - nr = FALSE, - d = NULL, - nnF = nn + sim = 50000, + wiggle = FALSE, + randomdist = NULL, + nnF = nnE ) } \arguments{ -\item{nn}{vector of look locations for efficacy -(if futility looks should be different, please specify also \code{nnF})} +\item{nnE}{(\code{numeric}):\cr sample size or sizes where study can be stopped for Efficacy decision. If different for Futility decision, +specify in \code{nnF}.} -\item{p}{true rate (scenario)} +\item{truep}{(\code{number}):\cr assumed true response rate or true rate (scenario).} -\item{p0}{lower efficacy threshold} +\item{p0}{(\code{number}):\cr lower Futility threshold of response rate.} -\item{p1}{upper efficacy threshold} +\item{p1}{(\code{number}):\cr upper Efficacy threshold of response rate.} -\item{tL}{probability threshold for being below p0} +\item{tL}{(\code{number}):\cr posterior probability threshold for being below \code{p0}.} -\item{tU}{probability threshold for being above p1} +\item{tU}{(\code{number}):\cr posterior probability threshold for being above \code{p1}.} -\item{parE}{beta parameters for the prior on the treatment proportion} +\item{parE}{(\code{numeric}):\cr alpha and beta parameters for the prior on the treatment proportion. +Default set at alpha = 1, beta = 1, or uniform prior.} -\item{ns}{number of simulations} +\item{sim}{(\code{number}):\cr number of simulations.} -\item{nr}{generate random look locations? (not default)} +\item{wiggle}{(\code{logical}):\cr generate random look locations (not default). +if \code{TRUE}, optional to specify \code{dist} (see @details).} -\item{d}{distance for random looks around the look locations in \code{nn}} +\item{randomdist}{(\code{logical}):\cr Random distance added to looks. if \code{NULL}, and \code{wiggle = TRUE}, function will +generate and add a random distance within range of the closest looks.} -\item{nnF}{vector of look locations for futility -(default: same as efficacy)} +\item{nnF}{(\code{numeric}):\cr sample size or sizes where study can be stopped for Futility decision if different from Efficacy decision.} } \value{ A list with the following elements: -oc: matrix with operating characteristics (see Details section) -Decision: vector of the decisions made in the simulated trials -(\code{TRUE} for success, \code{FALSE} for failure, \code{NA} for no -decision) -SampleSize: vector of the sample sizes in the simulated trials -nn: vector of look locations that was supplied -nnE: vector of efficacy look locations -nnF: vector of futility look locations -params: multiple parameters +\itemize{ +\item \code{oc}: matrix with operating characteristics (see @details section) +\item \code{nn}: vector of look locations that was supplied +\item \code{nnE}: vector of Efficacy look locations +\item \code{nnF}: vector of Futility look locations +\item \code{params}: multiple parameters +} } \description{ -The trial is stopped for efficacy if the posterior probability to be -above p1 is larger than tU, and stopped for futility if the posterior -probability to be below p0 is larger than tL. +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} + +Calculate operating characteristics for posterior probability method. + +It is assumed that the true response rate is \code{truep}. +The trial is stopped for Efficacy if the posterior probability to be +above \code{p1} is larger than \code{tU}, and stopped for Futility if the posterior +probability to be below \code{p0} is larger than \code{tL}: + +Stop criteria for Efficacy : + +\code{P_E(p > p1) > tU} + +Stop criteria for Futility : + +\code{P_E(p < p0) > tL} + +Resulting operating characteristics include the following: +\itemize{ +\item \code{ExpectedN}: expected number of patients in the trials +\item \code{PrStopEarly}: probability to stop the trial early (before reaching the +maximum sample size) +\item \code{PrEarlyEff}: probability of Early Go decision +\item \code{PrEarlyFut}: probability of for Early Stop decision +\item \code{PrEfficacy}: probability of Go decision +\item \code{PrFutility}: probability of Stop decision +\item \code{PrGrayZone}: probability between Go and Stop ,"Evaluate" or Gray decision zone +} } \details{ -Returned operating characteristics in a matrix include: -ExpectedN: expected number of patients in the trials -PrStopEarly: probability to stop the trial early (before reaching the -maximum sample size) -PrEarlyEff: probability to decide for efficacy early -PrEarlyFut: probability to decide for futility early -PrEfficacy: probability to decide for efficacy -PrFutility: probability to decide for futility -PrGrayZone: probability of no decision at the end ("gray zone") +\code{ExpectedN} is an average of the simulated sample sizes. +If \code{wiggle = TRUE}, one can specify \code{dist}, though the algorithm will generate it if \code{dist = NULL}. +If \code{nnF = NULL}, no Futility or decision to Stop will be analysed. Note that \code{nnF = c(0)} is equivalent. +As default, \code{nnF} is set to the identical looks of \code{nnE}, and if \code{wiggle = TRUE}, all looks are the same, e.g. +\code{nnE = nnF} when wiggle and distance is applied. } \examples{ -# operating characteristics for posterior probability method - -# design details (example) -# multiple looks @ 10, 20, 30 patietns -# True response rate of the treatment group=40\% -# stop for futility: P(response rate < 20\% )> 60\% -# s top for efficacy: P(response rate > 30\% )> 80\% -# prior of treatment arm parE= Beta(1,1) -res1 <- ocPostprob( - nn = c(10, 20, 30), p = 0.4, p0 = 0.2, p1 = 0.3, tL = 0.6, tU = 0.8, - parE = c(1, 1), ns = 1000 +# For three looks of 10, 20 and 30 we have the following assumptions : +# True response rate of the treatment group = 40\% +# The following are the Go and Stop rules respectively : +# Look for Efficacy: P(response rate > 30\% )> 80\% +# Look for Futility: P(response rate < 20\% )> 60\% +# Prior of treatment arm parE= Beta(1,1). +res <- ocPostprob( + nnE = c(10, 20, 30), truep = 0.40, p0 = 0.20, p1 = 0.30, tL = 0.60, tU = 0.80, parE = c(1, 1), + sim = 50000, wiggle = TRUE, randomdist = NULL, nnF = c(10, 20, 30) ) -res1$oc -# this call will generate d (distance for random looks around the look locations) -# based on "floor(min(nn - c(0,nn[-length(nn)]))/2)" as d is missing: -res2 <- ocPostprob( - nn = c(10, 20, 30), p = 0.4, p0 = 0.2, p1 = 0.3, tL = 0.6, tU = 0.8, - parE = c(1, 1), ns = 1000, nr = TRUE +res$oc + +# We specify the distance in this example. +res <- ocPostprob( + nnE = c(10, 20, 30), truep = 0.40, p0 = 0.20, p1 = 0.30, tL = 0.60, tU = 0.80, parE = c(1, 1), + sim = 50000, wiggle = TRUE, randomdist = c(-1, 3), nnF = c(10, 20, 30) ) -res2$oc -# now d is specified: -res3 <- ocPostprob( - nn = c(10, 20, 30), p = 0.4, p0 = 0.2, p1 = 0.3, tL = 0.6, tU = 0.8, - parE = c(1, 1), ns = 1000, nr = TRUE, d = 5 +res$oc + +# Here, nnE = nnF, and no wiggle room is allowed. Random distance also not supplied. +res <- ocPostprob( + nnE = c(10, 20, 30), truep = 0.40, p0 = 0.20, p1 = 0.30, tL = 0.60, tU = 0.80, parE = c(1, 1), + sim = 50000, wiggle = FALSE, randomdist = NULL, nnF = c(10, 20, 30) ) -res3$oc - -# finally, we can also have separate specification of efficacy and -# futility analyses. E.g. here have futility decisions only at the final analysis: -res4 <- ocPostprob( - nn = c(10, 20, 30), p = 0.4, p0 = 0.2, p1 = 0.3, tL = 0.6, tU = 0.8, - parE = c(1, 1), ns = 1000, nr = TRUE, d = 5, - nnF = c(30) + +res$oc + +# Here, we only have one Futility and Efficacy look or stop. +res <- ocPostprob( + nnE = c(10), truep = 0.40, p0 = 0.20, p1 = 0.30, tL = 0.60, tU = 0.80, parE = c(1, 1), + sim = 50000, wiggle = FALSE, randomdist = NULL, nnF = 10 ) -res4$oc -# compared to res3, we see that there is no early futility stopping anymore, -# and the overall probability for stopping for futility (which is the type II error here) -# is much lower. + +res$oc + +# Here, we only have one Futility but many Efficacy looks or stop. +res <- ocPostprob( + nnE = c(10, 20, 30), truep = 0.40, p0 = 0.20, p1 = 0.30, tL = 0.60, tU = 0.80, parE = c(1, 1), + sim = 50000, wiggle = FALSE, randomdist = NULL, nnF = 10 +) + +res$oc } diff --git a/man/plotOc.Rd b/man/plotOc.Rd index 67bef454..16389213 100644 --- a/man/plotOc.Rd +++ b/man/plotOc.Rd @@ -19,7 +19,10 @@ etc. and displays a bar plot of the operating characteristics \examples{ # get operating character result from oc.postprob -res1 <- ocPostprob(nn = c(10, 20, 30), p = 0.4, p0 = 0.2, p1 = 0.3, tL = 0.6, tU = 0.8, parE = c(1, 1), ns = 10000) +res1 <- ocPostprob( + nnE = c(10, 20, 30), truep = 0.4, p0 = 0.2, + p1 = 0.3, tL = 0.6, tU = 0.8, parE = c(1, 1), sim = 50000 +) res1$oc plotOc(res1) diff --git a/man/postprobBeta.Rd b/man/postprobBeta.Rd index 615155b8..58795e3a 100644 --- a/man/postprobBeta.Rd +++ b/man/postprobBeta.Rd @@ -30,3 +30,15 @@ with default set to be a uniform or beta(1,1). We observed \code{x} successes in n trials and so the posterior is \code{P_E | data ~ beta(a + x, b + n - x)}. } +\examples{ +# Example taken from Lee & Liu (2006) +# We observed 16 successes out of 23 patients # should we write this in the documentation +# We set a threshold of 0.60 +# Assume a beta(0.6,0.4) prior for P_E +# Posterior will be a beta(16.6,22.8), Pr(P_E > p | data) = 0.8358808 + + +# Example taken from Lee and Liu (2006) +postprobBeta(x = 16, n = 23, p = 0.60, a = 0.6, b = 0.4) +# Interpretation : The probability 16 of 23 successes is greater than 60 \% threshold is approximately 84 \% +} diff --git a/tests/testthat/test-dbetabinom.R b/tests/testthat/test-dbetabinom.R index e89a4eea..36901c65 100644 --- a/tests/testthat/test-dbetabinom.R +++ b/tests/testthat/test-dbetabinom.R @@ -61,7 +61,7 @@ test_that("dbetabinomMix gives the correct numeric result", { # pbetaMix ---- -test_that("pbetaMix cdf gives incrementally higher values with increase x support", { +test_that("The pbetaMix has incrementally higher cdf with increase x support", { is_lower <- pbetaMix( q = 0.3, par = rbind(c(0.2, 0.4)), diff --git a/tests/testthat/test-ocPostprob.R b/tests/testthat/test-ocPostprob.R new file mode 100644 index 00000000..d9b14c85 --- /dev/null +++ b/tests/testthat/test-ocPostprob.R @@ -0,0 +1,131 @@ +# h_get_distance ---- +test_that("h_get_distance gives an error with one element numeric", { + expect_equal(h_get_distance(10), integer(0)) +}) + +test_that("h_get_distance gives results within range", { + set.seed(1989) + nn <- c(10, 20, 30) + results <- h_get_distance(nn) + expect_numeric(results, lower = -min(nn) / 2, upper = 30, len = 2) +}) + +test_that("h_get_distance gives an error with non sorted argument", { + set.seed(1989) + expect_error(h_get_distance(c(30, 20, 10))) +}) + +# h_get_looks ---- +test_that("h_get_looks gives correct results if input is identical", { + dist <- c(0, 5) + results <- h_get_looks(dist = dist, nnE = c(10, 20, 30), nnF = c(10, 20, 30)) + expect_equal(results$nnrE, results$nnrF) +}) + +test_that("h_get_looks gives correct results if input is identical", { + dist <- c(0, 5) + results <- h_get_looks(dist = dist, nnE = c(10, 20, 30), nnF = c(10, 20, 30)) + expect_equal(results$nnrE, results$nnrF) +}) + +# h_get_decision ---- +test_that("get_decision will give GO decision in favourable conditions", { + tmp <- h_get_decision( + nnr = c(10, 20, 30), + truep = 0.5, + # Go criteria is P_E(p > p1) > tU, where P_E(truep > 0.30) > 0.8 + # Stop criteria is P_E(p < p0) > tL, where P_E(truep > 0.20) > 0.5 + p0 = 0.2, + p1 = 0.5, + tL = 0.2, + tU = 0.3, + nnE = c(10, 20, 30), + nnF = c(10, 20, 30) + ) + expect_equal(tmp$decision, TRUE) +}) + +# h_get_oc ---- +test_that("the probability results of get_oc are less than 1", { + oc <- h_get_oc( + all_sizes = sample(c(11, 14, 20), size = 10000, replace = TRUE), + decision = sample(c(NA, TRUE, FALSE), size = 10000, replace = TRUE), + nnrE = c(11, 14, 20), + nnrF = c(11, 14, 20) + ) + expect_true(oc$PrStopEarly && oc$PrFutility && oc$PrEarlyEff && oc$PrEfficacy < 1) +}) + +test_that("the ExpectedN is within range based on vector of looks", { + all_sizes <- sample(c(11, 14, 20), size = 10000, replace = TRUE) + oc <- h_get_oc( + all_sizes = all_sizes, + decision = sample(c(NA, TRUE, FALSE), size = 10000, replace = TRUE), + nnrE = c(11, 14, 20), + nnrF = c(11, 14, 20) + ) + expect_number(oc$ExpectedN, lower = min(all_sizes), upper = max(all_sizes)) +}) + +# ocPostprob ---- +test_that("the sum of Eff, Fut, Gray zone probabiliy is 1", { + set.seed(1989) + expect_warning(res1 <- ocPostprob( + nnE = 40, truep = 0.5, p0 = 0.45, p1 = 0.45, tL = 0.9, tU = 0.7, + parE = c(1, 1), sim = 10000 + ), "Advise to use sim >= 50000 to achieve convergence") + results <- sum(res1$oc[5:7]) + expect_equal(results, 1) +}) + +test_that("the PrFutility increases with increase futility looks", { + set.seed(1989) + expect_warning(res_fut <- ocPostprob( + nnE = c(10, 20, 30), truep = 0.40, p0 = 0.20, p1 = 0.30, tL = 0.60, tU = 0.80, parE = c(1, 1), + sim = 10000, wiggle = FALSE, randomdist = NULL, nnF = c(10, 20, 30) + ), "Advise to use sim >= 50000 to achieve convergence") + + res_fut$oc$PrFutility + expect_warning(res_one_fut <- ocPostprob( + nnE = c(10, 20, 30), truep = 0.40, p0 = 0.20, p1 = 0.30, tL = 0.60, tU = 0.80, parE = c(1, 1), + sim = 10000, wiggle = FALSE, randomdist = NULL, nnF = 10 + ), "Advise to use sim >= 50000 to achieve convergence") + res_one_fut$oc$PrFutility + expect_true(res_fut$oc$PrFutility > res_one_fut$oc$PrFutility) +}) + +test_that("the PrEfficacy increases with increase Efficacy looks", { + set.seed(1989) + expect_warning(res_eff <- ocPostprob( + nnE = c(30), truep = 0.40, p0 = 0.20, p1 = 0.30, tL = 0.60, tU = 0.80, parE = c(1, 1), + sim = 10000, wiggle = FALSE, randomdist = NULL, nnF = 30 + ), "Advise to use sim >= 50000 to achieve convergence") + + res_eff$oc$PrEfficacy + expect_warning(res_more_eff <- ocPostprob( + nnE = c(10, 20, 30), truep = 0.40, p0 = 0.20, p1 = 0.30, tL = 0.60, tU = 0.80, parE = c(1, 1), + sim = 10000, wiggle = FALSE, randomdist = NULL, nnF = c(10, 20, 30) + ), "Advise to use sim >= 50000 to achieve convergence") + res_more_eff$oc$PrEfficacy + expect_true(res_more_eff$oc$PrEfficacy > res_eff$oc$PrEfficacy) +}) + +# ocPostprob --- +test_that("ocPostprob gives results that are within range to stats::pbinom", { + set.seed(1989) + # Go criteria is P_E(truep >= 0.45) > 0.70 + # Stop criteria is P_E(truep <= 0.45) > 0.90 + res1 <- ocPostprob( + nnE = 40, truep = 0.5, p0 = 0.45, p1 = 0.45, tL = 0.9, tU = 0.7, + parE = c(1, 1), sim = 50000 + ) + # Pre-calculation indicate that : + # Go criteria: 20 out of 40, means >= 50% response rate + expect_equal(res1$oc$PrEfficacy, 0.56226) + p.go <- 1 - pbinom(q = 20 - 1, size = 40, prob = 0.5) + expect_true(abs(p.go - res1$oc$PrEfficacy) < 1e-3) + # Stop criteria: 13 out of 40, means <= 32.5% response rate. + expect_equal(res1$oc$PrFutility, 0.01998) + p.stop <- pbinom(q = 13, size = 40, prob = 0.5) + expect_true(abs(p.stop - res1$oc$PrFutility) < 1e-2) +}) diff --git a/tests/testthat/test-postprob.R b/tests/testthat/test-postprob.R index 13e1e54f..e9381886 100644 --- a/tests/testthat/test-postprob.R +++ b/tests/testthat/test-postprob.R @@ -11,7 +11,6 @@ test_that("postprobBeta gives incrementally higher values with increase x suppor expect_true(is_lower < is_higher) }) - # postprob --- test_that("postprob gives the correct number result", { # Example from Lee & Liu (2006) A predictive probability design for phase II cancer clinical trials diff --git a/vignettes/introduction.Rmd b/vignettes/introduction.Rmd index 103d09f5..85e85bb1 100644 --- a/vignettes/introduction.Rmd +++ b/vignettes/introduction.Rmd @@ -695,8 +695,8 @@ we issue the following command: ```{r ocpostprob_example, echo=TRUE} set.seed(4) results <- ocPostprob( - nn = c(10, 20, 30), p = 0.4, p0 = 0.2, p1 = 0.3, tL = 0.6, - tU = 0.8, parE = c(1, 1), ns = 10000 + nnE = c(10, 20, 30), truep = 0.4, p0 = 0.2, p1 = 0.3, tL = 0.6, + tU = 0.8, parE = c(1, 1), sim = 10000, wiggle = FALSE, randomdist = NULL, nnF = c(10, 20, 30) ) results$oc ```