Calculates a posterior dispersion metric.

dispersion(model, summary = FALSE, seed = 10)

Arguments

model

An object of class bayesnecfit whose distribution family is either poisson or binomial.

summary

Logical. Should summary stats be returned instead of full vector? Defaults to FALSE.

seed

Change seed for reproducible purposes.

Value

A numeric vector. If summary is FALSE, an n-long vector containing the dispersion metric, where n is the number of post warm-up posterior draws from the brmsfit object. If TRUE, then a data.frame containing the summary stats (mean, median, 95% highest density intervals) of the dispersion metric.

Details

This function calculates a dispersion metric which takes the ratio between the observed relative to simulated Pearson residuals sums of squares.

References

Zuur, A. F., Hilbe, J. M., & Ieno, E. N. (2013). A Beginner's Guide to GLM and GLMM with R: A Frequentist and Bayesian Perspective for Ecologists. Highland Statistics Limited.

Examples

if (FALSE) {
library(bayesnec)
data(nec_data)
nec_data$y <- as.integer(round(nec_data$y * 100))
nec4param <- bnec(y ~ crf(x, "nec4param"), data = nec_data, chains = 2)
dispersion(nec4param, summary = TRUE)
}