| svlm | R Documentation |
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,
...
)
formula |
an object of class |
data |
an optional data frame, list or environment (or object
coercible by |
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 |
asymmetry |
if |
priorspec |
using the smart constructor |
thin |
single number greater or equal to 1, coercible to integer.
Every |
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
|
startpara |
optional named list, containing the starting values
for the parameter draws. If supplied, |
startlatent |
optional vector of length |
parallel |
optional one of |
n_cpus |
optional positive integer, the number of CPUs to be used in case of
parallel computations. Defaults to |
cl |
optional so-called SNOW cluster object as implemented in package
|
n_chains |
optional positive integer specifying the number of independent MCMC chains |
print_progress |
optional one of |
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
|
... |
Any extra arguments will be forwarded to
|
For details concerning the algorithm please see the paper by Kastner and Frühwirth-Schnatter (2014) and Hosszejni and Kastner (2019).
The value returned is a list object of class svdraws holding
para |
|
latent |
|
latent0 |
|
tau |
|
beta |
|
y |
the left hand side of the observation equation, usually
the argument |
runtime |
|
priors |
a |
thinning |
|
summary |
|
meanmodel |
|
svlm |
a flag for the use of |
model_terms |
helper object that represents the formula |
formula |
argument |
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.
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, \Sexpr[results=rd]{tools:::Rd_expr_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, \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1007/978-3-030-30611-3_8")}.
svsample, svsim, specify_priors
# 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)
# Prediction
predn <- 10L
preddat <- data.frame(x = runif(predn, 3, 4),
z = runif(predn, -1, -0.5))
pred <- predict(res, newdata = preddat, steps = predn)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.