dispersion: Extract Values for Dispersion

View source: R/bage_mod-methods.R

dispersionR Documentation

Extract Values for Dispersion

Description

Extract values for the 'dispersion' parameter from a model object.

Usage

dispersion(object, quiet = FALSE, original_scale = FALSE)

Arguments

object

Object of class "bage_mod", typically created with mod_pois(), mod_binom(), or mod_norm().

quiet

Whether to suppress messages. Default is FALSE.

original_scale

Whether values for disperson are on the original scale or the transformed scale. Default is FALSE.

Value

An rvec (or NULL if the model does not include a dispersion parameter.)

Fitted vs unfitted models

dispersion() is typically called on a fitted model. In this case, the values for dispersion are draws from the posterior distribution. dispersion() can, however, be called on an unfitted model. In this case, the values are drawn from the prior distribution.

Scaling and Normal models

Internally, models created with mod_norm() are fitted using transformed versions of the outcome and weights variables. By default, when dispersion() is used with these models, it returns values on the transformed scale. To instead obtain values on the untransformed scale, set original_scale to TRUE.

See Also

  • components() Extract values for hyper-parameters, including dispersion

  • set_disp() Specify a prior for dispersion

Examples

set.seed(0)

## specify model
mod <- mod_pois(injuries ~ age + sex + year,
                data = nzl_injuries,
                exposure = popn)

## prior distribution
mod |>
  dispersion()

## fit model
mod <- mod |>
  fit()

## posterior distribution
mod |>
  dispersion()

## fit normal model
mod <- mod_norm(value ~ age * diag + year,
                data = nld_expenditure,
                weights = 1) |>
  fit()

## values on the transformed scale
mod |>
  dispersion()

## values on the original scale
mod |>
  dispersion(original_scale = TRUE)

bage documentation built on Nov. 19, 2025, 9:07 a.m.