inspect_par_beta checks if an object is an eligible vector of
parameters for the Beta distribution. This can be useful to validate inputs,
intermediate calculations or outputs in user-defined functions.
inspect_par_beta(x)| x | An arbitrary object.  | 
    
|---|
inspect_par_beta does not return any output. There are two possible
outcomes:
The call is silent if x is an eligible vector of parameters for the Beta
distribution.
An informative error message is thrown otherwise.
inspect_par_beta conducts a series of tests to check if x is an
eligible vector of parameters for the Beta distribution. Namely,
inspect_par_beta checks if:
x is NULL or empty.
x is an atomic vector
x is numeric
x has length  2
x has NA or NaN values.
All elements of x are positive.
inspect_par_bernoulli to validate parameters for
the Bernoulli/Binomial distribution.
inspect_par_multinomial to validate parameters for
the Multinomial distribution.
inspect_par_dirichlet to validate parameters for
the Dirichlet distribution.
inspect_par_haldane to validate parameters for the
Haldane distribution.
# Calls that pass silently:
x1 <- c(1, 1)
x2 <- c(2, 5)
inspect_par_beta(x1)
inspect_par_beta(x2)
# Calls that throw an informative error message:
mylist <- list(
  NULL, 1, factor(1, 1),
  matrix(c(1, 1)), c("1", "1"), list(1, 1), c(1, NA),
  c(1, NaN), c(TRUE, FALSE), numeric(0), c(-1, 1)
)
try(inspect_par_beta(mylist[[1]]))
#> Error in inspect_par_beta(mylist[[1]]) : 
#>   Invalid argument: mylist[[1]] is NULL.
try(inspect_par_beta(mylist[[2]]))
#> Error in inspect_par_beta(mylist[[2]]) : 
#>   Invalid argument: mylist[[2]] must be of length 2.
try(inspect_par_beta(mylist[[3]]))
#> Error in inspect_par_beta(mylist[[3]]) : 
#>   Invalid argument: mylist[[3]] must be an atomic vector.
try(inspect_par_beta(mylist[[4]]))
#> Error in inspect_par_beta(mylist[[4]]) : 
#>   Invalid argument: mylist[[4]] must be an atomic vector.
try(inspect_par_beta(mylist[[5]]))
#> Error in inspect_par_beta(mylist[[5]]) : 
#>   Invalid argument: mylist[[5]] must be numeric.
try(inspect_par_beta(mylist[[6]]))
#> Error in inspect_par_beta(mylist[[6]]) : 
#>   Invalid argument: mylist[[6]] must be an atomic vector.
try(inspect_par_beta(mylist[[7]]))
#> Error in inspect_par_beta(mylist[[7]]) : 
#>   Invalid argument: there are NA or NaN values in mylist[[7]].
try(inspect_par_beta(mylist[[8]]))
#> Error in inspect_par_beta(mylist[[8]]) : 
#>   Invalid argument: there are NA or NaN values in mylist[[8]].
try(inspect_par_beta(mylist[[9]]))
#> Error in inspect_par_beta(mylist[[9]]) : 
#>   Invalid argument: mylist[[9]] must be numeric.
try(inspect_par_beta(mylist[[10]]))
#> Error in inspect_par_beta(mylist[[10]]) : 
#>   Invalid argument: mylist[[10]] must be of length 2.
try(inspect_par_beta(mylist[[11]]))
#> Error in inspect_par_beta(mylist[[11]]) : 
#>   Invalid argument: elements of mylist[[11]] must be greather than 0.