Skip to contents

Convenience constructor that calls new_hbmfit then validate_hbmfit – the safe public entry-point if you ever need to build an hbmfit object manually (e.g.\ when adapting a non-brms model). In normal usage you do not need to call this: hbm and the distribution-specific wrappers do it for you.

Usage

hbmfit(model, data, missing_method = NULL)

Arguments

model

A brmsfit or brmsfit_multiple object.

data

The data.frame used to fit model.

missing_method

Character scalar or NULL. One of "deleted", "multiple", "model".

Value

A validated hbmfit object.

Examples

# \donttest{
# Uses brms-default MCMC settings (chains = 4, iter = 2000,
# warmup = 1000) -- this toy data is only for verifying the
# hbmfit class structure, not for inference.
raw <- brms::brm(y ~ x1, data = data.frame(y = rnorm(10), x1 = 1:10),
                 chains = 4, iter = 2000, warmup = 1000, refresh = 0)
#> Compiling Stan program...
#> Error in .fun(model_code = .x1): Boost not found; call install.packages('BH')
fit <- hbmfit(model = raw,
              data  = data.frame(y = rnorm(10), x1 = 1:10),
              missing_method = NULL)
#> Error in new_hbmfit(model = model, missing_method = missing_method, data = data): inherits(model, c("brmsfit", "brmsfit_multiple")) is not TRUE
validate_hbmfit(fit)
#> Error: object 'fit' not found
# }