-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add build_curtailed() for use with est_curtailed()
- 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.
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
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) | ||
|
||
} |