svlm is a wrapper around svsample with a formula interface. The name derives from SV and lm because a linear model with SV residuals is fitted. The function simulates from the joint posterior distribution of the regression coefficients and the SV parameters mu, phi, sigma (and potentially nu and rho), along with the latent log-volatilities h_0,...,h_n and returns the MCMC draws.

svlm(
  formula,
  data,
  draws = 10000,
  burnin = 1000,
  heavytails = FALSE,
  asymmetry = FALSE,
  priorspec = NULL,
  thin = 1,
  keeptime = "all",
  quiet = FALSE,
  startpara = NULL,
  startlatent = NULL,
  parallel = c("no", "multicore", "snow"),
  n_cpus = 1L,
  cl = NULL,
  n_chains = 1L,
  print_progress = "automatic",
  expert = NULL,
  ...
)

Arguments

formula

an object of class "formula", as in lm.

data

an optional data frame, list or environment (or object coercible by as.data.frame to a data frame) containing the variables in the model. If not found in data, the variables are taken from environment(formula), typically the environment from which svlm is called.

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

heavytails

if TRUE, then the residuals of the linear model will follow a t-distribution conditional on the latent volatility process. This model is usually called SV-t. If priorspec is given, then heavytails is ignored.

asymmetry

if TRUE, then the residuals of the linear model will follow an SV process with leverage. If priorspec is given, then heavytails is ignored.

priorspec

using the smart constructor specify_priors, one can set the details of the prior distribution.

thin

single number greater or equal to 1, coercible to integer. Every thinparath parameter and latent draw is kept and returned. The default value is 1, corresponding to no thinning of the parameter draws i.e. every draw is stored.

keeptime

Either 'all' (the default) or 'last'. Indicates which latent volatility draws should be stored.

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 may contain elements named mu, phi, sigma, nu, rho, beta, and latent0. The default value is equal to the prior mean. In case of parallel execution with cl provided, startpara can be a list of named lists that initialize the parallel chains.

startlatent

optional vector of length length(y), containing the starting values for the latent log-volatility draws. The default value is rep(-10, length(y)). In case of parallel execution with cl provided, startlatent can be a list of named lists that initialize the parallel chains.

parallel

optional one of "no" (default), "multicore", or "snow", indicating what type of parallellism is to be applied. Option "multicore" is not available on Windows.

n_cpus

optional positive integer, the number of CPUs to be used in case of parallel computations. Defaults to 1L. Ignored if parameter cl is supplied and parallel != "snow".

cl

optional so-called SNOW cluster object as implemented in package parallel. Ignored unless parallel == "snow".

n_chains

optional positive integer specifying the number of independent MCMC chains

print_progress

optional one of "automatic", "progressbar", or "iteration", controls the output. Ignored if quiet is TRUE.

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 following named elements:

interweave

Logical value. If TRUE (the default), then ancillarity-sufficiency interweaving strategy (ASIS) is applied to improve on the sampling efficiency for the parameters. Otherwise one parameterization is used.

correct_model_misspecification

Logical value. If FALSE (the default), then auxiliary mixture sampling is used to sample the latent states. If TRUE, extra computations are made to correct for model misspecification either ex-post by reweighting or on-line using a Metropolis-Hastings step.

...

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

para

mcmc.list object containing the parameter draws from the posterior distribution.

latent

mcmc.list object containing the latent instantaneous log-volatility draws from the posterior distribution.

latent0

mcmc.list object containing the latent initial log-volatility draws from the posterior distribution.

tau

mcmc.list object containing the latent variance inflation factors for the sampler with conditional t-innovations (optional).

beta

mcmc.list object containing the regression coefficient draws from the posterior distribution (optional).

y

the left hand side of the observation equation, usually the argument y. In case of an AR(k) specification, the first k elements are removed.

runtime

proc_time object containing the run time of the sampler.

priors

a priorspec object containing the parameter values of the prior distributions for mu, phi, sigma, nu, rho, and betas, and the variance of specification for latent0.

thinning

list containing the thinning parameters, i.e. the arguments thinpara, thinlatent and keeptime.

summary

list containing a collection of summary statistics of the posterior draws for para, latent, and latent0.

meanmodel

character containing information about how designmatrix was employed.

svlm

a flag for the use of svlm

model_terms

helper object that represents the formula

formula

argument formula

xlevels

helper object that is needed to interpret the formula

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.

Details

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

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, doi:10.1016/j.csda.2013.01.002 .

Hosszejni, D. and Kastner, G. (2019). Approaches Toward the Bayesian Estimation of the Stochastic Volatility Model with Leverage. Springer Proceedings in Mathematics & Statistics, 296, 75--83, doi:10.1007/978-3-030-30611-3_8 .

Examples

# Simulate data
n <- 50L
dat <- data.frame(x = runif(n, 3, 4),
                  z = runif(n, -1, -0.5))
designmatrix <- matrix(c(dat$x, dat$x^2, log10(dat$x),
                         dat$z), ncol = 4)
betas <- matrix(c(-1, 1, 2, 0), ncol = 1)
y <- designmatrix %*% betas + svsim(n)$y
dat$y <- y
# Formula interface
res <- svlm(y ~ 0 + x + I(x^2) + log10(x) + z, data = dat)
#> Done!
#> Summarizing posterior draws...
# Prediction
predn <- 10L
preddat <- data.frame(x = runif(predn, 3, 4),
                      z = runif(predn, -1, -0.5))
pred <- predict(res, newdata = preddat, steps = predn)