library("gamlss2")
## see ?mcmcBayesian Sampler (BS) for GAMLSS Models
Description
The function BS() implements an MCMC sampler for generalized additive models for location, scale and shape (GAMLSS) as fitted by gamlss2. The sampler uses a Metropolis-Hastings update for regression coefficients of linear and smooth terms. Smoothing variances are updated using univariate slice sampling or conjugate updates, depending on the structure of the penalty matrices.
Usage
## Bayesian sampler.
BS(x, y, specials, family, offsets,
weights, start, xterms, sterms, control)
Arguments
x
|
The full model matrix to be used for fitting. |
y
|
The response vector or matrix. |
specials
|
A named list of special model terms, e.g., including design and penalty matrices for fitting smooth terms using smooth.construct.
|
family
|
A family object, see gamlss2.family.
|
offsets
|
If supplied, a list or data frame of possible model offset. See gamlss2 for details on the offset interface.
|
weights
|
If supplied, a numeric vector of prior weights to be used in the fitting process. Should be NULL or a numeric vector.
|
start
|
Starting values for the parameters of the response distribution. See the examples for gamlss2.
|
xterms
|
A named list specifying the linear model terms. Each named list element represents one parameter as specified in the family object. |
sterms
|
A named list specifying the special model terms. Each named list element represents one parameter as specified in the family object. |
control
|
Further control arguments as specified within the call of gamlss2. See the details.
|
Details
Function BS() is typically called via mcmc or via wrapper function bamlss2. It implements a blocked Metropolis-Hastings sampler using working responses and working weights. Smooth terms are updated using penalized weighted least squares proposals and their smoothing variances are sampled using univariate slice sampling.
The function uses the following control arguments:
-
n.iter: Integer, the total number of MCMC iterations. -
burnin: Integer, the burn-in period. -
thin: Integer, thinning parameter for saved samples. -
trace: Logical, should information be printed while the sampler is running? -
flush: Logical, useflush.consolefor displaying the current output in the console. -
nullmodel: Logical, should an intercept-only null model be evaluated to compute a null deviance and deviance reduction? -
binning: Logical, should binning be used for smooth terms if available (unique observations for building \(X^{\top}WX\) and related quantities)?
The returned object contains posterior samples for all model components. In addition, DIC and related quantities may be computed from saved log-likelihood values if enabled.
Value
The function returns a fitted model object containing posterior samples and summary information. The exact structure is determined by the sampler implementation, but typically includes:
-
samples: A matrix of posterior draws for coefficients and smoothing variances. -
coefficients: Posterior means of coefficients. -
fitted.values: Posterior mean fitted values for each distributional parameter. -
edf: Estimated degrees of freedom for smooth terms. -
logLik: Log-likelihood at the posterior mean predictor. -
dic: DIC-related quantities (if computed).
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, RS, CG, mcmc, bamlss2