Skip to content

Commit

Permalink
Add build_curtailed() for use with est_curtailed()
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael J. Grayling committed Oct 1, 2018
1 parent 4a3e997 commit 79ceb43
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions R/build_curtailed.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#' @export
build_curtailed <- function(J = 2, n = c(10, 19), a = c(1, 5), r = c(Inf, 6),
a_curt, r_curt, pi0 = 0.1, pi1 = 0.3, alpha = 0.05,
beta = 0.2, summary = T) {

##### Input checking #########################################################

check_integer_range(J, "J", c(1, Inf))
check_real_pair_range_strict(pi0, pi1, "pi0", "pi1", c(0, 1))
check_real_range_strict(alpha, "alpha", c(0, 1), 1)
check_real_range_strict(beta, "beta", c(0, 1), 1)
check_gs_boundaries(J, n, a, r)
check_gs_boundaries(sum(n), rep(1, sum(n)), a_curt, r_curt)
check_logical(summary, "summary")

##### Main computations ######################################################

if (summary){
message("Building the design...")
}
des <- list(J = J, n = n, a = a, r = r, pi0 = pi0, pi1 = pi1,
alpha = alpha, beta = beta, J_curt = sum(n),
a_curt = a_curt, r_curt = r_curt,
n_curt = rep(1, sum(n)))

##### Outputting #############################################################

if (summary) {
message("...outputting.")
}
output <- list(des = des, feasible = NULL, J = J, pi0 = pi0,
pi1 = pi1, alpha = alpha, beta = beta, Nmin = NULL,
Nmax = NULL, futility = any(is.finite(a[1:(J - 1)])),
efficacy = any(is.finite(r[1:(J - 1)])),
optimality = NULL, point_prior = NULL,
beta_prior = NULL, equal_n = NULL, ensign = NULL,
summary = summary)
class(output) <- "sa_des_curtailed"
return(output)

}

0 comments on commit 79ceb43

Please sign in to comment.