Skip to contents

The INLA backend returns a flexybayes_inla object whose internal layout differs from the other engines', it has no $glm shim, so it needs its own tidy() method even though it shares the flexybayes parent class. The fixed-effect summary is read directly off INLA's summary.fixed table, whose mean, sd, and 0.025quant / 0.975quant columns map cleanly onto the broom-canonical estimate, std.error, conf.low, and conf.high.

Usage

# S3 method for class 'flexybayes_inla'
tidy(
  x,
  conf.int = TRUE,
  conf.level = 0.95,
  effects = c("fixed", "random"),
  ...
)

Arguments

x

A flexybayes_inla fit.

conf.int

Logical. Whether to attach the credible-interval columns. Defaults to TRUE.

conf.level

Numeric in (0, 1). Accepted for generic compatibility. INLA reports the 95% marginal bounds, so a non-0.95 request is noted.

effects

Character. Which effects to return: "fixed" for the population-level coefficients or "random" for the variance-component summary. Defaults to "fixed".

...

Currently unused. Present for generic compatibility.

Value

A data.frame with one row per term and the columns term, estimate, std.error, and (when conf.int = TRUE) conf.low / conf.high. The rows are the fixed-effect terms under effects = "fixed" and the variance components under effects = "random".

Details

Because the INLA fixed-effect intervals come from the marginal posteriors INLA has already integrated, the conf.level argument is accepted for generic compatibility but only the 95% bounds INLA reports are returned. A one-off message notes this when a different level is requested rather than silently ignoring it.

The effects argument is the same one tidy.flexybayes() carries, and means the same thing on both: "fixed" returns the population-level coefficients, "random" the variance-component summary. Before 0.9.1 this method had no such argument, so effects = "random" on an INLA fit was absorbed by ... and the FIXED-effect table came back under a call that asked for variance components, a wrong answer with no error. An unrecognised value now stops.

Examples

# \donttest{
set.seed(1)
dat <- data.frame(yield = rnorm(40),
                  env = factor(rep(1:4, each = 10)),
                  block = factor(rep(1:5, times = 8)))
fit <- flexybayes(yield ~ env, random = ~block, data = dat,
                  backend = "inla", verbose = FALSE)
tidy(fit)
#>          term    estimate std.error   conf.low conf.high
#> 1 (Intercept)  0.13218419 0.3414308 -0.5413323 0.8056978
#> 2        env2  0.11664728 0.4265600 -0.7239542 0.9572496
#> 3        env3 -0.26582665 0.4265600 -1.1064247 0.5747791
#> 4        env4 -0.01145265 0.4265600 -0.8520530 0.8291508
tidy(fit, effects = "random")
#>       term  estimate std.error   conf.low conf.high
#> 1    sigma 0.9486288 0.1161080 0.74648474 1.2009160
#> 2 sd_block 0.2470558 0.2176887 0.03192191 0.8227742
# }