Skip to contents

Computes posterior credible intervals at an arbitrary level by sampling via inlabru::generate() and taking the requested quantiles. Called by parsnip's predict(type = "conf_int", level = ...) dispatch. Exported only so parsnip::set_pred's quoted func can reach it via the pkg = "inlaops" lookup; not intended for end users.

Usage

bru_predict_conf_int(object, newdata, level, formula, n.samples = 1000L)

Arguments

object

A fitted bru object.

newdata

A data frame of covariate values.

level

Credible-interval level between 0 and 1.

formula

Response-scale prediction formula.

n.samples

Number of posterior samples (default 1000).

Value

A list with q_lower and q_upper numeric vectors.

Examples

if (FALSE) { # interactive() && rlang::is_installed(c("INLA", "sn"))
set.seed(1)
dat <- data.frame(x = rnorm(30))
dat$y <- 1 + 0.5 * dat$x + rnorm(30, sd = 0.5)
fit <- bru_inlaops_fit(y ~ Intercept(1) + x, data = dat, family = "gaussian")
bru_predict_conf_int(
  fit,
  newdata = data.frame(x = c(-1, 0, 1)),
  level = 0.9,
  formula = bru_pred_formula(fit),
  n.samples = 200
)
}