SV.mcmc: Fit Bayesian Stochastic Volatility Model

View source: R/SV.mcmc.R

SV.mcmcR Documentation

Fit Bayesian Stochastic Volatility Model

Description

Fits a stochastic volatility model to a univariate time series of returns.

Usage

SV.mcmc(y, nmcmc = 1000, burnin = 100, init = NULL, hyper = NULL, tuning = NULL, 
         sigma_MH = NULL, npart = NULL, mcmseed = NULL)

Arguments

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 c(0.9, 0.5, .1)

hyper

hyperparameters for bivariate normal distribution of (phi, sigma); user inputs (mu_phi, mu_q, sigma_phi, sigma_q, rho) - default is c(0.9, 0.5, 0.075, 0.3, -0.25)

tuning

tuning parameter - default is .03

sigma_MH

covariance matrix used for random walk Metropolis; it will be scaled by tuning in the script - default is matrix(c(1,-.25,-.25,1), nrow=2, ncol=2)

npart

number of particles used in particle filter - default is 10

mcmseed

seed for mcmc - default is 90210

Details

The log-volatility process is x_t and the returns are y_t. The SV model is

x_t = φ x_{t-1} + σ w_t \qquad y_t = β \exp\{\frac{1}{2} x_t\}ε_t

where w_t and ε_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 (φ, σ) 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 effective sample sizes (ESS)], their ACFs, and their histograms with the .025, .5, and .975 quantiles displayed, and (2) the log-volatility posterior mean along with corresponding .95 credible intervals.

Value

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

Note

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 28% and this can be adjusted using the tuning parameter.

Author(s)

D.S. Stoffer

Source

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

References

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/.

Examples

## 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)

astsa documentation built on Jan. 10, 2023, 1:11 a.m.