library("gamlss2")
data("abdom", package = "gamlss.data")
## specify the model Formula
f <- y ~ s(x) | s(x) | s(x) | s(x)
## estimate Bayesian model
b <- bamlss2(f, data = abdom, family = BCT)
## posterior summary
summary(b)
## plot estimated effects
plot(b)
## plot samples
plot(b, which = "samples")
## predict parameters using samples
pm <- predict(b, FUN = mean)
print(head(pm))
psd <- predict(b, FUN = sd)
print(head(psd))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 to specify n.iter, burnin, and thin 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, thinning parameter for saved samples. |
maxit
|
Integer, number of backfitting iterations 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 to obtain reasonable starting values for the MCMC sampler.
The wrapper is designed to behave in line with gamlss() 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., and 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