Learn R Programming

stochvol (version 1.1.3)

svsample: Markov Chain Monte Carlo (MCMC) Sampling for the Stochastic Volatility (SV) Model

Description

svsample simulates from the joint posterior distribution of the SV parameters mu, phi, sigma (and potentially nu), along with the latent log-volatilities h_0,...,h_n and returns the MCMC draws.

Usage

svsample(y, draws = 10000, burnin = 1000, priormu = c(0, 100),
         priorphi = c(5, 1.5), priorsigma = 1, priornu = NA,
	 thinpara = 1, thinlatent = 1, thintime = 1, quiet = FALSE,
	 startpara, startlatent, expert, ...)

Arguments

y
numeric vector containing the data (usually log-returns), which must not contain zeros. Alternatively, y can be an svsim object. In this case, the returns will be extracted and a warning is thrown.
draws
single number greater or equal to 1, indicating the number of draws after burn-in (see below). Will be automatically coerced to integer. The defaults value is 10000.
burnin
single number greater or equal to 0, indicating the number of draws discarded as burn-in. Will be automatically coerced to integer. The default value is 1000.
priormu
numeric vector of length 2, indicating mean and standard deviation for the Gaussian prior distribution of the parameter mu, the level of the log-volatility. The default value is c(0, 100), which constitutes a practically uninform
priorphi
numeric vector of length 2, indicating the shape parameters for the Beta prior distribution of the transformed parameter (phi+1)/2, where phi denotes the persistence of the log-volatility. The default value is c(5, 1.5)
priorsigma
single positive real number, which stands for the scaling of the transformed parameter sigma^2, where sigma denotes the volatility of log-volatility. More precisely, sigma^2 ~ priorsigma * chisq(df = 1). The default
priornu
numeric vector of length 2 (or NA), indicating the lower and upper bounds for the uniform prior distribution of the parameter nu, the degrees-of-freedom parameter of the conditional innovations t-distribution. The default value i
thinpara
single number greater or equal to 1, coercible to integer. Every thinparath parameter draw is kept and returned. The default value is 1, corresponding to no thinning of the parameter draws i.e. every draw is stored.
thinlatent
single number greater or equal to 1, coercible to integer. Every thinlatentth latent variable draw is kept and returned. The default value is 1, corresponding to no thinning of the latent variable draws, i.e. every draw is kept.
thintime
single number greater or equal to 1, coercible to integer. If thintime is different from 1, only every thintimeth latent log-volatility is being monitored. If, e.g., thintime = 3, the latent log-volatilities h_
quiet
logical value indicating whether the progress bar and other informative output during sampling should be omitted. The default value is FALSE, implying verbose output.
startpara
optional named list, containing the starting values for the parameter draws. If supplied, startpara must contain three elements named mu, phi, and sigma, where mu is an arbitrary nu
startlatent
optional vector of length length(x$y), containing the starting values for the latent log-volatility draws. The default value is rep(-10, length(x$y)).
expert
optional named list of expert parameters. For most applications, the default values probably work best. Interested users are referred to the literature provided in the References section. If expert is provided, it may contain the fol
...
Any extra arguments will be forwarded to updatesummary, controlling the type of statistics calculated for the posterior draws.

Value

  • The value returned is a list object of class svdraws holding
  • paramcmc object containing the parameter draws from the posterior distribution.
  • latentmcmc object containing the latent instantaneous log-volatility draws from the posterior distribution.
  • latent0mcmc object containing the latent initial log-volatility draws from the posterior distribution.
  • ythe argument y
  • runtimeproc_time object containing the run time of the sampler.
  • priorslist containing the parameter values of the prior distribution, i.e. the arguments priormu, priorphi and priorsigma.
  • thinninglist containing the thinning parameters, i.e. the arguments thinpara, thinlatent and thintime.
  • summarylist containing a collection of summary statistics of the posterior draws for para, latent, and latent0.
  • To display the output, use print, summary and plot. The print method simply prints the posterior draws (which is very likely a lot of output); the summary method displays the summary statistics currently stored in the object; the plot method plot.svdraws gives a graphical overview of the posterior distribution by calling volplot, traceplot and densplot and displaying the results on a single page.

encoding

UTF-8

Details

For details concerning the algorithm please see the paper by Kastner and Frühwirth-Schnatter (2014).

References

Kastner, G. and Frühwirth-Schnatter, S. (2014). Ancillarity-sufficiency interweaving strategy (ASIS) for boosting MCMC estimation of stochastic volatility models. Computational Statistics & Data Analysis, 76, 408--423, http://dx.doi.org/10.1016/j.csda.2013.01.002.

See Also

svsim, updatesummary, predict.svdraws, plot.svdraws.

Examples

Run this code
## Simulate a short and highly persistent SV process 
sim <- svsim(100, mu = -10, phi = 0.99, sigma = 0.2)

## Obtain 5000 draws from the sampler (that's not a lot)
draws <- svsample(sim$y, draws = 5000, burnin = 100,
		  priormu = c(-10, 1), priorphi = c(20, 1.5), priorsigma = 0.2)

## Check out the results
summary(draws)
plot(draws)

Run the code above in your browser using DataLab