Learn R Programming

stochvol (version 2.0.4)

svlsample2: Minimal overhead version of svlsample.

Description

svlsample2 is a minimal overhead version of svlsample with slightly different default arguments and a simplified return value structure. It is intended to be used mainly for one-step updates where speed is an issue, e.g., as a plug-in into other MCMC samplers. Note that absolutely no input checking is performed, thus this function is to be used with proper care!

Usage

svlsample2(y, draws = 1, burnin = 0, priormu = c(0, 100),
  priorphi = c(5, 1.5), priorsigma = 1, priorrho = c(4, 4),
  thinpara = 1, thinlatent = 1, thintime = NULL, keeptime = "all",
  quiet = TRUE, startpara, startlatent)

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 default value is 1.

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

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 uninformative prior for common exchange rate datasets, stock returns and the like.

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), which constitutes a prior that puts some belief in a persistent log-volatility but also encompasses the region where phi is around 0.

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 value is 1, which constitutes a reasonably vague prior for many common exchange rate datasets, stock returns and the like.

priorrho

numeric vector of length 2, indicating the shape parameters for the Beta prior distribution of the transformed parameter (rho + 1) / 2, where rho denotes the conditional correlation between observation and the increment of the log-volatility. The default value is c(4, 4), which constitutes a slightly informative prior around 0 (the no leverage case) to boost convergence.

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

Deprecated. Use 'keeptime' instead.

keeptime

Either 'all' (the default) or 'last'. Indicates which latent

quiet

logical value indicating whether the progress bar and other informative output during sampling should be omitted. The default value is TRUE.

startpara

compulsory named list, containing the starting values for the parameter draws. It must contain four elements named mu, phi, sigma, and rho, where mu is an arbitrary numerical value, phi is a real number between -1 and 1, sigma is a positive real number, and rho is a real number between -1 and 1.

startlatent

compulsory vector of length length(y), containing the starting values for the latent log-volatility draws.

Value

The value returned is a list object holding

para

matrix of dimension 4 x draws containing the parameter draws from the posterior distribution.

latent

matrix of dimension length(y) x draws containing the latent instantaneous log-volatility draws from the posterior distribution.

meanmodel

always equals "none"

Details

As opposed to the ordinary svlsample, the default values differ for draws, burnin, and quiet. Note that currently neither expert nor …{} arguments are provided.

See Also

svlsample

Examples

Run this code
# NOT RUN {
data(exrates)
aud.price <- subset(exrates,
  as.Date("2010-01-01") <= date & date < as.Date("2011-01-01"),
  "AUD")[,1]
draws <- svlsample2(logret(aud.price),
                    draws = 10, burnin = 0,
                    startpara = list(phi=0.95, mu=-10, sigma=0.2, rho=-0.1),
                    startlatent = rep_len(-10, length(aud.price)-1))
# }

Run the code above in your browser using DataLab