#' Argument Check: Binomial Model
#'
#' Checks if the arguments of the [PEC_binom_bound()] function are correctly specified.
#'
#' @usage check_PEC_binom_bound(
#' n,
#' alpha_1,
#' beta_1,
#' alpha_2,
#' beta_2,
#' alpha_D,
#' beta_D,
#' v,
#' plot
#' )
#'
#' @param n The sample size.
#' @param alpha_1,beta_1 The parameters of the first beta prior.
#' @param alpha_2,beta_2 The parameters of the second beta prior.
#' @param alpha_D,beta_D The parameters of the design beta prior.
#' @param v A constant used to determine the optimal sample size.
#' @param plot Logical. Should a plot be displayed?
#'
#' @return An error message.
#'
#' @note This is an internal function.
#'
#' @author Michele Cianfriglia \email{michele.cianfriglia@@uniroma1.it}
#'
#' @keywords internal
#'
#' @importFrom crayon italic
check_PEC_binom_bound <- function(n, alpha_1, beta_1, alpha_2, beta_2, alpha_D, beta_D, v, plot) {
if (anyNA(n)) {
stop(paste(italic("n"), "cannot contain missing values or NaNs."), call. = FALSE)
}
if (any(!is.vector(n), min(n) <= 0, any(n != floor(n)))) {
stop(paste(italic("n"), "must be a vector of positive integers."), call. = FALSE)
}
if (is.unsorted(x = n, strictly = TRUE)) {
stop(paste(italic("n"), "must be strictly increasing."), call. = FALSE)
}
if (any(!number(alpha_1), is.infinite(alpha_1), alpha_1 < 0, !number(beta_1), is.infinite(beta_1), beta_1 < 0)) {
stop(paste(italic("alpha_1"), "and", italic("beta_1"), "must be non-negative values."), call. = FALSE)
}
if (any(!number(alpha_2), is.infinite(alpha_2), alpha_2 < 0, !number(beta_2), is.infinite(beta_2), beta_2 < 0)) {
stop(paste(italic("alpha_2"), "and", italic("beta_2"), "must be non-negative values."), call. = FALSE)
}
if (any(!number(alpha_D), is.infinite(alpha_D), alpha_D <= 0, !number(beta_D), is.infinite(beta_D), beta_D <= 0)) {
stop(paste(italic("alpha_D"), "and", italic("beta_D"), "must be positive values."), call. = FALSE)
}
if (any(!number(v), v <= 0, v >= 1)) {
stop(paste(italic("v"), "must be a value in (0, 1)."), call. = FALSE)
}
if (!boolean(plot)) {
stop(paste(italic("plot"), "must be TRUE or FALSE."), call. = FALSE)
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.