Bayesian GAMLSS Wrapper

Description

The function bamlss2() is a convenience wrapper around gamlss2 to fit Bayesian GAMLSS models via MCMC sampling. It sets the optimizer to an MCMC routine and allows n.iter, burnin, and thin to be specified directly.

Usage

bamlss2(formula, n.iter = 1200, burnin = 200, thin = 1, maxit = 2, ...)

Arguments

formula A GAM-type formula or Formula. The model can include smooth terms as provided by the mgcv package.
n.iter Integer, the total number of MCMC iterations.
burnin Integer, the burn-in period.
thin Integer, the thinning parameter for saved samples.
maxit Integer, the number of backfitting iterations used to compute starting values before running MCMC. If maxit = 0, sampling starts from default or user-supplied starting values.
Further arguments passed to gamlss2 and/or gamlss2_control.

Details

Function bamlss2() calls gamlss2 and sets the optimizer to a Bayesian sampler. By default, a small number of backfitting iterations is performed first to obtain reasonable starting values for the MCMC sampler.

The wrapper is designed to behave in line with the gamlss()-style interfaces, i.e., it supports weights and offset arguments through gamlss2.

Value

An object of class “bamlss2” inheriting from “gamlss2” containing the fitted model and posterior samples.

References

Umlauf N, Klein N, Zeileis A (2018). BAMLSS: Bayesian Additive Models for Location, Scale and Shape (and Beyond). Journal of Computational and Graphical Statistics, 27(3), 612–627. doi:10.1080/10618600.2017.1407325

See Also

gamlss2, mcmc, BS

Examples

library("gamlss2")


data("abdom", package = "gamlss.data")

## specify the model formula
f <- y ~ s(x) | s(x) | s(x) | s(x)

## estimate Bayesian model
m <- bamlss2(f, data = abdom, family = BCT)

## posterior summary
summary(m)

## plot estimated effects
plot(m)

## plot samples
plot(m, which = "samples")

## predict parameters using samples
pm <- predict(m, FUN = mean)
print(head(pm))
psd <- predict(m, FUN = sd)
print(head(psd))