A convenient wrapper function (posterior
) to sample the posterior using MCMC in rstan
and returns a stanfit
object for diagnostics. Use RCMstan
to update the RCM and the enclosed operating model
with MCMC samples..
posterior(x, ...)
# S4 method for RCModel
posterior(
x,
priors_only = FALSE,
laplace = FALSE,
chains = 2,
iter = 2000,
warmup = floor(iter/2),
thin = 5,
seed = 34,
init = "last.par.best",
cores = chains,
...
)
# S4 method for Assessment
posterior(x, priors_only = FALSE, ...)
RCMstan(RCModel, stanfit, sim, cores = 1)
An object of class Assessment or RCModel.
Additional arguments to pass to rstan::sampling
via tmbstan::tmbstan
.
Logical, whether to set the likelihood to zero and sample the priors only.
Logical, whether to do the Laplace approximation for random parameters.
The numer of MCMC chains.
The number of iterations for each chain, including warmup.
The number of burnin iterations
The frequency at which iterations are kept (e.g., 5
saves every fifth iteration)
Seed for random number generator during the MCMC.
The initial values of parameters for starting the MCMC chain. See tmbstan::tmbstan
.
The number of cores for running in parallel, e.g., one core per MCMC chain. Used in RCMstan
for reconstructing the population.
An object of class RCModel
An object of class stanfit
returned by posterior
.
A matrix of RCModel@OM@nsim
rows and 2 columns that specifies the samples used to update the
operating model. The first column specifies the chain and the second columns specifies the MCMC iteration.
posterior
returns an object of class stanfit
. See class?stanfit
.
RCMstan
returns an updated RCModel
.
A vignette on the steps to run the MCMC is available on the openMSE website.