library("gamlss2")
## air quality data
air <- subset(airquality, !is.na(Ozone))
## set the seed
set.seed(123)
## estimate Gamma model with MCMC
m <- bamlss2(
Ozone ~ s(Temp) + s(Wind) | s(Temp),
data = air,
family = GA
)
## posterior summary
summary(m)
## plot estimated effects
plot(m)
## plot samples
plot(m, which = "samples", ask = TRUE)
## predict parameters using samples
pm <- predict(m, type = "parameter", FUN = mean)
print(head(pm))
psd <- predict(m, type = "parameter", FUN = sd)
print(head(psd))Bayesian GAMLSS Wrapper
Description
A wrapper around gamlss2 for fitting Bayesian GAMLSS models by MCMC sampling. Starting values are computed using maxit backfitting iterations before sampling. The controls n.iter, burnin, and thin can be specified directly; weights and offset are passed through to gamlss2.
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. |
…
|
Further arguments passed to gamlss2 and/or gamlss2_control.
|
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