sampler | R Documentation |
bdm
modelExecute a Bayesian model fit using rstan.
sampler(object, ...)
## S4 method for signature 'bdm'
sampler(
object,
data = list(),
run = character(),
init = "random",
chains,
iter,
warmup,
thin,
...
)
object |
a |
... |
further arguments to |
data |
a |
run |
optional character vector to label the run |
init |
an initialisation |
chains |
number of MCMC chains |
iter |
number of iterations per chain |
warmup |
number of iterations to be discarded |
thin |
sampling interval from chains |
By default a Bayesian fit is executed through a call to sampling
, which implements an MCMC algorithm. Default values for chains
, iter
, warmup
and thin
follow those for rstan.
The init
argument can be a list
, function
or character
string. If it is a function then it should take no arguments and return a named list of intial values for the estimated parameters. Alternatively the list can be specified directly.
This behaviour matches that for sampling
. If a character string is supplied it should be either 'random'
or 'fixed'
.
If the model is the default model and init = 'fixed'
then sensible starting values for r
, logK
and x
are produced using getr
, getlogK
and getx
.
If the model is the default model and init = 'random'
then sensible starting values are obtained by sampling from the priors for r, logK, x
.
If the model is not the default model, then the user should specify a function or list, otherwise starting values will be randomly generated by sampling(init = 'random', ...)
.
Returns a bdm
object containing posterior samples contained in object@trace
.
# get some data
data(albio)
dat <- bdmData(harvest = albio$catch, index = albio$cpue, time = rownames(albio))
# initialize and fit default model
## Not run:
mdl <- bdm()
mdl <- compiler(mdl)
mdl <- sampler(mdl, dat)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.