inspect_par_bernoulli {inspector} | R Documentation |
Validate parameters for the Bernoulli/Binomial distributions
Description
inspect_par_bernoulli
checks if an object is an eligible
Bernoulli/Binomial proportion. This can be useful to validate inputs,
intermediate calculations or outputs in user-defined functions.
Usage
inspect_par_bernoulli(x)
Arguments
x |
An arbitrary object. |
Details
inspect_par_bernoulli
conducts a series of tests to check if x
is an eligible Bernoulli/Binomial proportion. Namely, inspect_par_bernoulli
checks if:
-
x
isNULL
or empty. -
x
is an atomic vector -
x
is numeric -
x
haslength
1 -
x
isNA
orNaN
. -
x
is in the (0, 1) interval.
Value
inspect_par_bernoulli
does not return any output. There are two
possible outcomes:
The call is silent if
x
is an eligible Bernoulli/Binomial proportion.An informative error message is thrown otherwise.
See Also
-
inspect_par_multinomial
to validate parameters for the Multinomial distribution. -
inspect_par_beta
to validate parameters for the Beta distribution. -
inspect_par_dirichlet
to validate parameters for the Dirichlet distribution. -
inspect_par_haldane
to validate parameters for the Haldane distribution. -
inspect_data_dichotomous
to validate dichotomous data. -
inspect_prob
to check if an object is a numeric vector of valid probability values.
Examples
# Calls that pass silently:
x <- 0.5
inspect_par_bernoulli(x)
inspect_par_bernoulli(0.1)
# Calls that throw an informative error message:
mylist <- list(
NULL, TRUE, factor(.5), matrix(0.5), "0.5",
list(0.5), NA, NaN, numeric(0), c(0.1, 0.5), -0.5, 1.1
)
try(inspect_par_bernoulli(mylist[[1]]))
try(inspect_par_bernoulli(mylist[[2]]))
try(inspect_par_bernoulli(mylist[[3]]))
try(inspect_par_bernoulli(mylist[[4]]))
try(inspect_par_bernoulli(mylist[[5]]))
try(inspect_par_bernoulli(mylist[[6]]))
try(inspect_par_bernoulli(mylist[[7]]))
try(inspect_par_bernoulli(mylist[[8]]))
try(inspect_par_bernoulli(mylist[[9]]))
try(inspect_par_bernoulli(mylist[[10]]))
try(inspect_par_bernoulli(mylist[[11]]))
try(inspect_par_bernoulli(mylist[[12]]))