run_mcmc | R Documentation |
Run a MCMC sampler on a network model using Stan
run_mcmc(
model,
iter = 2000,
chains = 4,
method = "matrix_exp",
euler_control = list(),
cores = NULL,
stanfit = FALSE,
...
)
model |
A |
iter |
A positive integer specifying the number of iterations for each chain (including warmup). The default is 2000. |
chains |
A positive integer specifying the number of Markov chains. The default is 4. |
method |
A character string indicating the method to use to solve ODE
in the Stan model; available methods are "matrix_exp" and "euler". The
default is "matrix_exp", which uses matrix exponential and is reasonably
fast for small networks. For large networks, the "euler" method can be
used. It implements a simple forward Euler method to solve the ODE and can
be faster than the matrix exponential approach, but extra caution must be
taken to check for numerical accuracy (e.g. testing different |
euler_control |
An optional list containing extra parameters when using
|
cores |
Number of cores to use for parallel use. Default is
|
stanfit |
If TRUE, returns a 'stanfit' object instead of the more classical 'mcmc.list' object. Note that when an 'mcmc.list' object is returned, the original 'stanfit' object is still accessible as an attribute of that object (see Examples). |
... |
Arguments passed to 'rstan::sampling' (e.g. iter, chains). |
An object of class 'stanfit' returned by 'rstan::sampling' if
stanfit = TRUE
, otherwise the result of converting this
stanfit
object with stanfit_to_named_mcmclist
(i.e. an
object of class networkModelStanfit
and mcmc.list, which still
carries the original 'stanfit' object stored as an attribute).
aquarium_mod
## Not run:
# The 'aquarium_run' object is shipped with the package, so you don't
# actually need to run the line below to obtain it
aquarium_run <- run_mcmc(aquarium_mod)
plot(aquarium_run)
summary(aquarium_run)
# The original stanfit object returned by Stan
sfit <- attr(aquarium_run, "stanfit")
sfit
# The stanfit object can be used for diagnostics, LOO cross-validation, etc.
rstan::loo(sfit)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.