SV.mcmc | R Documentation |
Fits a stochastic volatility model to a univariate time series of returns.
SV.mcmc(y, nmcmc = 1000, burnin = 100, init = NULL, hyper = NULL, tuning = NULL,
sigma_MH = NULL, npart = NULL, mcmseed = NULL)
y |
single time series of returns |
nmcmc |
number of iterations for the MCMC procedure |
burnin |
number of iterations to discard for the MCMC procedure |
init |
initial values of (phi, sigma, beta) - default is |
hyper |
hyperparameters for bivariate normal distribution of (phi, sigma); user inputs (mu_phi, mu_q, sigma_phi, sigma_q, rho) -
default is |
tuning |
tuning parameter - default is |
sigma_MH |
covariance matrix used for random walk Metropolis; it will be scaled by |
npart |
number of particles used in particle filter - default is |
mcmseed |
seed for mcmc - default is |
The log-volatility process is x_t
and the returns are y_t
. The SV model is
x_t = \phi x_{t-1} + \sigma w_t \qquad y_t = \beta \exp\{\frac{1}{2} x_t\}\epsilon_t
where w_t
and \epsilon_t
are independent standard normal white noise.
The model is fit using a technique described in the paper listed below (in the Source section) where the state
parameters (\phi, \sigma)
are sampled simultaneously with a bivariate normal prior specified
in the arguments init
and hyper
.
Two graphics are returned: (1) the three parameter traces with the posterior mean highlighted, their ACFs [with effective sample sizes (ESS)], and their histograms with the .025, .5, and .975 quantiles displayed, and (2) the log-volatility posterior mean along with corresponding .95 credible intervals.
Returned invisibly:
phi |
vector of sampled state AR parameter |
sigma |
vector of sampled state error stnd deviation |
beta |
vector of sampled observation error scale |
log.vol |
matrix of sampled log-volatility |
options |
values of the input arguments |
Except for the data, all the other inputs have defaults. The time to run and the acceptance rate are returned at the end of the analysis. The acceptance rate should be around 30% and this is easily adjusted using the tuning parameter.
D.S. Stoffer
Gong & Stoffer (2021). A note on efficient fitting of stochastic volatility models. Journal of Time Series Analysis, 42(2), 186-200. https://github.com/nickpoison/Stochastic-Volatility-Models
You can find demonstrations of astsa capabilities at FUN WITH ASTSA.
The most recent version of the package can be found at https://github.com/nickpoison/astsa/.
In addition, the News and ChangeLog files are at https://github.com/nickpoison/astsa/blob/master/NEWS.md.
The webpages for the texts and some help on using R for time series analysis can be found at https://nickpoison.github.io/.
SV.mle
## Not run:
#-- A minimal example --##
myrun <- SV.mcmc(sp500w) # results in object myrun - don't forget it
str(myrun) # an easy way to see the default input options
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.