View source: R/bage_mod-methods.R
| dispersion | R Documentation |
Extract values for the 'dispersion' parameter from a model object.
dispersion(object, quiet = FALSE, original_scale = FALSE)
object |
Object of class |
quiet |
Whether to suppress messages.
Default is |
original_scale |
Whether values for
disperson are on the original
scale or the transformed scale.
Default is |
An rvec
(or NULL if the model does not
include a dispersion parameter.)
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.
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.
components() Extract values for hyper-parameters,
including dispersion
set_disp() Specify a prior for dispersion
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.