Skip to contents

Ensures the fit object was created with the expected inference mode. Useful for enforcing mode requirements in downstream analysis.

Usage

validate_mode(fit, expected_mode, error = TRUE)

Arguments

fit

A ratiod_fit object

expected_mode

Mode that should have been used: a tier ("exact", "structured", "optimized") or a backend ("hmc", "laplace", ...), as passed to tratio(mode = ).

error

If TRUE (default), error on mismatch. If FALSE, return logical.

Value

If error = FALSE, returns TRUE/FALSE. Otherwise errors on mismatch.

Examples

# \donttest{
sim <- sim_ratiod(n = 100, family = ratiod_poisson_gamma(), seed = 1)
fit <- tratio(y_num | y_denom ~ x1 + (1 | group), data = sim$data,
              family = ratiod_poisson_gamma(),
              control = list(iter = 1000, chains = 2, seed = 1))
validate_mode(fit, "hmc")
#> [1] TRUE
validate_mode(fit, "laplace", error = FALSE)
#> [1] FALSE
# }