| inspect_bfactor {inspector} | R Documentation |
Validate vectors of Bayes factors
Description
inspect_bfactor checks if an object is a numeric vector of
valid Bayes factor values. This can be useful to validate inputs,
intermediate calculations or outputs in user-defined functions.
Usage
inspect_bfactor(x, allow_nas = TRUE, warning_nas = TRUE)
Arguments
x |
An arbitrary object. |
allow_nas |
Logical value. If |
warning_nas |
Logical value. If |
Details
inspect_bfactor conducts a series of tests to check if x is a
numeric vector of valid Bayes factor values. Namely, inspect_bfactor checks
if:
-
xisNULLor empty. -
xis an atomic vector. -
xis numeric. -
xhasNAorNaNvalues. The values of
xare non-negative.
Value
inspect_bfactor does not return any output. There are three
possible outcomes:
The call is silent if:
-
xis a numeric vector of valid Bayes factor values and there are noNAorNaNvalues inx. -
xis a numeric vector of valid Bayes factor values, there are someNAorNaNvalues inx,allow_nasis set toTRUEandwarning_nasis set toFALSE.
-
An informative warning message is given if
xis a numeric vector of valid Bayes factor values, there are someNAorNaNvalues inxand bothallow_nasandwarning_nasare set toTRUE.An informative error message is thrown and the execution is stopped if:
-
xis not a numeric vector of valid Bayes factor values. -
xis a numeric vector of valid Bayes factor values, there are some inNAorNaNvalues inxandallow_nasis set toFALSE.
-
See Also
-
inspect_bfactor_logto check if an object is a numeric vector of valid logarithmic Bayes factor values. -
bfactor_interpretfor the interpretation of Bayes factors. -
inspect_bfactor_scaleto check if an object is a valid Bayes factor interpretation scale.
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(x1)
inspect_bfactor(x2, warning_nas = FALSE)
inspect_bfactor(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(y))
try(inspect_bfactor(y, warning_nas = TRUE))
try(inspect_bfactor(y, allow_nas = TRUE, warning_nas = TRUE))
# Calls that throw informative error messages:
z <- c(-0.9, 0, 0.1, 0.2, 0.3, 0.4, 0.5)
try(inspect_bfactor(z))
mylist <- list(
NULL, TRUE, factor(.5), matrix(0.5),
"0.5", list(0.5), NA, NaN, numeric(0), -0.5, -5
)
try(inspect_bfactor(mylist[[1]]))
try(inspect_bfactor(mylist[[2]]))
try(inspect_bfactor(mylist[[3]]))
try(inspect_bfactor(mylist[[4]]))
try(inspect_bfactor(mylist[[5]]))
try(inspect_bfactor(mylist[[6]]))
try(inspect_bfactor(mylist[[7]]))
try(inspect_bfactor(mylist[[8]]))
try(inspect_bfactor(mylist[[9]]))
try(inspect_bfactor(mylist[[10]]))
try(inspect_bfactor(mylist[[11]]))