Description Usage Arguments Details Value Author(s) References See Also Examples
Constructor of the varstan object for Bayesian estimation in Stan.
1 2 |
model |
One of the |
chains |
An integer of the number of Markov Chains chains to be run, by default 4 chains are run. |
iter |
An integer of total iterations per chain including the warm-up, by default the number of iterations are 2000. |
warmup |
A positive integer specifying number of warm-up (aka burn-in)
iterations. This also specifies the number of iterations used for stepsize
adaptation, so warmup samples should not be used for inference. The number
of warmup should not be larger than |
adapt.delta |
An optional real value between 0 and 1, the thin of the jumps in a HMC method. By default is 0.9. |
tree.depth |
An integer of the maximum depth of the trees evaluated during each iteration. By default is 10. |
... |
Further arguments passed to |
The function estimates one of the defined models in Stan using
the stan()
function for sampling.
This is the principal package's function and the link with Stan, this function fits the posterior distribution of every parameter for a defined model using a HMC method.
Every estimated model become a varstan
object, with different methods
for summary, diagnostic, forecast and plotting.
Defining priors
Default priors are chosen to be non or very weakly informative so that their influence on the results will. However, after getting more familiar with Bayesian statistics, I recommend you to start thinking about reasonable informative priors for your model parameters.
Those can be changed using the function set_prior()
before estimating the
model with the varstan()
function. For checking the defined priors use
get_prior()
and report()
functions.
Adjusting the sampling behavior of Stan
In addition to choosing the number of iterations, warmup samples, and
chains, users can control the behavior of the NUTS sampler, by using the
control
argument. The most important reason to use control
is to decrease (or eliminate at best) the number of divergent transitions
that cause a bias in the obtained posterior samples. Whenever you see the
warning "There were x divergent transitions after warmup." you should really
think about increasing adapt_delta
. Increasing adapt_delta
will
slow down the sampler but will decrease the number of divergent transitions
threatening the validity of your posterior samples.
Another problem arises when the depth of the tree being evaluated in each iteration
is exceeded. This is less common than having divergent transitions, but may also
bias the posterior samples. When it happens, Stan will throw out a warning
suggesting to increase max_treedepth
. For more details on the control
argument see stan
.
a varstan
object with the estimated time series model.
A varstan
object is a list that contains the following values:
Stanfit a Stanfit object returned by rstan
pacakge.
stan.parmaters The parameters used in Stan for the sample.
model The defined model for the time series.
series.name The time series' name.
ts The provided time series data.
Asael Alonzo Matamoros
Carpenter, B. and Gelman, A. and Hoffman, D. and Lee, D. and Goodrich, B. and
Betancourt, M. and Brubaker, and Guo, L. and Riddell. 2017. Stan: A probabilistic
programming language. Journal of Statistical Software 76(1).
doi: 10.18637/jss.v076.i01
.
Stan Development Team. (2018). Stan Modeling Language Users Guide and Reference Manual,
Version 2.18.0. url: http://mc-stan.org
.
Paul-Christian Buerkner (2017). brms: An R Package for Bayesian Multilevel
Models Using Stan. Journal of Statistical Software, 80(1), 1-28.
doi:10.18637/jss.v080.i01
Hyndman, R. & Khandakar, Y. (2008). Automatic time series forecasting: the
forecast package for R
. Journal of Statistical Software. 26(3),
1-22.doi: 10.18637/jss.v027.i03
.
1 2 3 4 5 6 7 8 9 10 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.