inspect_bfactor_scale checks if an object is a character vector of length 1 that is eligible to represent one of the Bayes factor interpretation scales available in the pcal package. This can be useful to validate inputs in user-defined functions.

inspect_bfactor_scale(x)

Arguments

x

An arbitrary object.

Value

inspect_bfactor_scale does not return any output. There are two possible scenarios:

  • The call is silent if x is a character vector of length 1 that is eligible to represent one of the Bayes factor interpretation scales available in the pcal package.

  • An informative error message is thrown otherwise.

Details

inspect_bfactor_scale conducts a series of tests to check if x is a character vector of length 1 that is eligible to represent one of the Bayes factor interpretation scales available in the pcal package. Namely, inspect_bfactor_scale checks if:

  • x is NULL or empty.

  • x is NA or NaN.

  • x is an atomic vector of length 1

  • The typeof x is character

  • The value of x is either "Jeffreys" or "Kass-Raftery" (not case sensitive).

See also

Examples

# Calls that pass silently:
x1 <- "Jeffreys"
x2 <- "jeffreys"
x3 <- "kass-raftery"
x4 <- "Kass-Raftery"
inspect_bfactor_scale(x1)
inspect_bfactor_scale(x2)
inspect_bfactor_scale(x3)
inspect_bfactor_scale(x4)

# Calls that throw informative error messages:
mylist <- list(
  NULL, NA, NaN, 10, "Bayes", "Jeff",
  "kassraftery", c("jeffreys", "kass-raftery")
)
try(inspect_bfactor_scale(mylist[[1]]))
#> Error in inspect_bfactor_scale(mylist[[1]]) : 
#>   Invalid argument: mylist[[1]] is NULL.
try(inspect_bfactor_scale(mylist[[2]]))
#> Error in inspect_bfactor_scale(mylist[[2]]) : 
#>   Invalid argument: mylist[[2]] is NA or NaN.
try(inspect_bfactor_scale(mylist[[3]]))
#> Error in inspect_bfactor_scale(mylist[[3]]) : 
#>   Invalid argument: mylist[[3]] is NA or NaN.
try(inspect_bfactor_scale(mylist[[4]]))
#> Error in inspect_bfactor_scale(mylist[[4]]) : 
#>   Invalid argument: the type of mylist[[4]] must be character.
try(inspect_bfactor_scale(mylist[[5]]))
#> Error in inspect_bfactor_scale(mylist[[5]]) : 
#>   Invalid argument: mylist[[5]] must be either 'jeffreys' or 'kass-raftery'.
try(inspect_bfactor_scale(mylist[[6]]))
#> Error in inspect_bfactor_scale(mylist[[6]]) : 
#>   Invalid argument: mylist[[6]] must be either 'jeffreys' or 'kass-raftery'.
try(inspect_bfactor_scale(mylist[[7]]))
#> Error in inspect_bfactor_scale(mylist[[7]]) : 
#>   Invalid argument: mylist[[7]] must be either 'jeffreys' or 'kass-raftery'.
try(inspect_bfactor_scale(mylist[[8]]))
#> Error in inspect_bfactor_scale(mylist[[8]]) : 
#>   Invalid argument: mylist[[8]] must be an atomic vector of length 1.