inspect_bfactor_log {inspector}R Documentation

Validate vectors of logarithmic Bayes factors

Description

inspect_bfactor_log checks if an object is a numeric vector of valid logarithmic Bayes factor values. This can be useful to validate inputs, intermediate calculations or outputs in user-defined functions.

Usage

inspect_bfactor_log(x, allow_nas = TRUE, warning_nas = TRUE)

Arguments

x

An arbitrary object.

allow_nas

Logical value. If TRUE then NA and NaN values in x are allowed. If FALSE, execution is stopped and an error message is thrown in case there are NA or NaN values in x.

warning_nas

Logical value. If TRUE then the presence of NA or NaN values in x generates a warning message. NA and NaN values pass silently otherwise (if allow_nas is TRUE).

Details

inspect_bfactor_log conducts a series of tests to check if x is a numeric vector of valid logarithmic Bayes factor values. Namely, inspect_bfactor_log checks if:

Value

inspect_bfactor_log does not return any output. There are three possible outcomes:

See Also

Examples

# Calls that pass silently:
x1 <- c(0, 0.5, 1, 10, 50, 100)
x2 <- c(NA, 0.5, 1, 10, 50, 100)
inspect_bfactor_log(x1)
inspect_bfactor_log(x2, warning_nas = FALSE)
inspect_bfactor_log(x2, allow_nas = TRUE, warning_nas = FALSE)

# Call that throws an informative warning message:
y <- c(0.1, 0.2, NA, 0.4, 0.5)
try(inspect_bfactor_log(y))
try(inspect_bfactor_log(y, warning_nas = TRUE))
try(inspect_bfactor_log(y, allow_nas = TRUE, warning_nas = TRUE))

# Calls that throw informative error messages:
mylist <- list(
  NULL, TRUE, factor(.5), matrix(0.5),
  "0.5", list(0.5), numeric(0), NA, NaN
)
try(inspect_bfactor_log(mylist[[1]]))
try(inspect_bfactor_log(mylist[[2]]))
try(inspect_bfactor_log(mylist[[3]]))
try(inspect_bfactor_log(mylist[[4]]))
try(inspect_bfactor_log(mylist[[5]]))
try(inspect_bfactor_log(mylist[[6]]))
try(inspect_bfactor_log(mylist[[7]]))
try(inspect_bfactor_log(mylist[[8]]))
try(inspect_bfactor_log(mylist[[9]]))

[Package inspector version 1.0.3 Index]