svlsample
.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!
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)
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.
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.
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.
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.
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.
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.
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.
single number greater or equal to 1, coercible to integer.
Every thinpara
th 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.
single number greater or equal to 1, coercible to integer.
Every thinlatent
th 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.
Deprecated. Use 'keeptime' instead.
Either 'all' (the default) or 'last'. Indicates which latent
logical value indicating whether the progress bar and other
informative output during sampling should be omitted. The default value is
TRUE
.
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
.
compulsory vector of length length(y)
,
containing the starting values for the latent log-volatility draws.
The value returned is a list object holding
matrix of dimension 4 x draws
containing
the parameter draws from the posterior distribution.
matrix of dimension length(y) x draws
containing the
latent instantaneous log-volatility draws from the posterior
distribution.
always equals "none"
As opposed to the ordinary svlsample
, the default values differ
for draws
, burnin
, and quiet
. Note that currently
neither expert
nor …{}
arguments are provided.
# 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