sam_GMCMC  R Documentation 
These functions provide a quite general infrastructure for sampling BAMLSS. The default proposal function is based on iteratively weighted least squares (IWLS), however, each model term may have a different updating function, see the details.
## Sampler functions:
sam_GMCMC(x, y, family, start = NULL, weights = NULL, offset = NULL,
n.iter = 1200, burnin = 200, thin = 1, verbose = TRUE,
step = 20, propose = "iwlsC_gp", chains = NULL, ...)
GMCMC(x, y, family, start = NULL, weights = NULL, offset = NULL,
n.iter = 1200, burnin = 200, thin = 1, verbose = TRUE,
step = 20, propose = "iwlsC_gp", chains = NULL, ...)
## Propose functions:
GMCMC_iwls(family, theta, id, eta, y, data,
weights = NULL, offset = NULL, ...)
GMCMC_iwlsC(family, theta, id, eta, y, data,
weights = NULL, offset = NULL, zworking, resids, rho, ...)
GMCMC_iwlsC_gp(family, theta, id, eta, y, data,
weights = NULL, offset = NULL, zworking, resids, rho, ...)
GMCMC_slice(family, theta, id, eta, y, data, ...)
x 
For function 
y 
The model response, as returned from function 
family 
A bamlss family object, see 
start 
A named numeric vector containing possible starting values, the names are based on
function 
weights 
Prior weights on the data, as returned from function 
offset 
Can be used to supply model offsets for use in fitting,
returned from function 
n.iter 
Sets the number of MCMC iterations. 
burnin 
Sets the burnin phase of the sampler, i.e., the number of starting samples that should be removed. 
thin 
Defines the thinning parameter for MCMC simulation. E.g., 
verbose 
Print information during runtime of the algorithm. 
step 
How many times should algorithm runtime information be printed, divides 
propose 
Sets the propose function for model terms, e.g. for a term 
chains 
How many chains should be started? Chains a sampled sequentially! 
theta 
The current state of parameters, provided as a named list. The first level
represents the parameters of the distribution, the second level the parameters of
the model terms. E.g., using the 
id 
The parameter identifier, a character vector of length 2. The first character specifies the current distributional parameter, the second the current model term. 
eta 
The current value of the predictors, provided as a named list, one list entry
for each parameter. The names correspond to the parameter names in the family object,
see 
data 
An object as returned from function

zworking 
Preinitialized numeric vector of 
resids 
Preinitialized numeric vector of 
rho 
An environment, only for internal usage. 
... 
Arguments passed to function 
The sampler function sam_GMCMC()
cycles through all distributional parameters and corresponding
model terms in each iteration of the MCMC chain. Samples of the parameters of a model term (e.g.,
s(x)
) are generated by proposal functions, e.g. GMCMC_iwls()
.
The default proposal function that should be used for all model terms is set with argument
propose
. For smooth terms, e.g. terms created with function s
, if
a valid propose function is supplied within the extra xt
list, this propose function will
be used. This way each model term may have its own propose function for creating samples
of the parameters. See the example section.
The default proposal function GMCMC_iwlsC_gp
allows for general priors for the
smoothing variances and general penalty functions. Samples of smoothing variances are computed
using slice sampling. Function GMCMC_iwlsC
samples smoothing variances of univariate terms
assuming an inverse gamma prior. Terms of higher dimensions use again slice sampling for creating
samples of smoothing variances.
Function GMCMC_iwls
is similar to function GMCMC_iwlsC
but uses plain R code.
Function GMCMC_slice
applies slice sampling also for the regression coefficients and
is therefore relatively slow.
The function returns samples of parameters, depending on the return value of the propose functions
other quantities can be returned. The samples are provided as a mcmc
matrix.
If chains > 1
, the samples are provided as a mcmc.list
.
Umlauf N, Klein N, Zeileis A (2016). Bayesian Additive Models for Location Scale and Shape (and Beyond). (to appear)
bamlss
, bamlss.frame
,
bamlss.engine.setup
, set.starting.values
, s2
## Not run: ## Simulated data example illustrating
## how to call the sampler function.
## This is done internally within
## the setup of function bamlss().
d < GAMart()
f < num ~ s(x1, bs = "ps")
bf < bamlss.frame(f, data = d, family = "gaussian")
## First, find starting values with optimizer.
opt < with(bf, bfit(x, y, family))
## Sample.
samps < with(bf, sam_GMCMC(x, y, family, start = opt$parameters))
plot(samps)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.