extractors {stochvol} | R Documentation |
Common Extractors for 'svdraws' and 'svpredict' Objects
Description
Some simple extractors returning the corresponding element of an
svdraws
and svpredict
object.
Usage
para(x, chain = "concatenated")
latent0(x, chain = "concatenated")
latent(x, chain = "concatenated")
vola(x, chain = "concatenated")
svbeta(x, chain = "concatenated")
svtau(x, chain = "concatenated")
priors(x)
thinning(x)
runtime(x)
sampled_parameters(x)
predy(y, chain = "concatenated")
predlatent(y, chain = "concatenated")
predvola(y, chain = "concatenated")
Arguments
x |
|
chain |
optional either a positive integer or the string
|
y |
|
Value
The return value depends on the actual funtion.
para(x , chain = "concatenated") |
extracts the parameter draws. |
latent(x , chain = "concatenated") |
extracts the latent contemporaneous log-volatility draws. |
latent0(x , chain = "concatenated") |
extracts the latent initial log-volatility draws. |
svbeta(x , chain = "concatenated") |
extracts the linear regression coefficient draws. |
svtau(x , chain = "concatenated") |
extracts the tau draws. |
vola(x , chain = "concatenated") |
extracts standard deviation draws. |
priors(x) |
extracts the prior
parameters used and returns them in a |
thinning(x) |
extracts the thinning parameters used and returns them in
a |
runtime(x) |
extracts the runtime and returns it as a
|
sampled_parameters(x) |
returns the names of time independent model
parameters that were actually sampled by |
predlatent(y , chain = "concatenated") |
extracts the predicted latent contemporaneous log-volatility draws. |
predvola(y , chain = "concatenated") |
extracts predicted standard deviation draws. |
predy(y , chain = "concatenated") |
extracts the predicted observation draws. |
Functions that have input parameter chain
return
an mcmc.list
object if chain=="all"
and
return an mcmc
object otherwise. If chain
is
an integer, then the specified chain is selected from
all chains. If chain
is "concatenated"
,
then all chains are merged into one mcmc
object.
See Also
specify_priors, svsample, predict.svdraws
Examples
# Simulate data
sim <- svsim(150)
# Draw from vanilla SV
draws <- svsample(sim, draws = 2000)
## Summarize all estimated parameter draws as a merged mcmc object
summary(para(draws)[, sampled_parameters(draws)])
## Extract the draws as an mcmc.list object
params <- para(draws, chain = "all")[, sampled_parameters(draws)]
options(max.print = 100)
## Further short examples
summary(latent0(draws))
summary(latent(draws))
summary(vola(draws))
sampled_parameters(draws)
priors(draws)
# Draw 3 independent chains from heavy-tailed and asymmetric SV with AR(2) structure
draws <- svsample(sim, draws = 20000, burnin = 3000,
designmatrix = "ar2",
priornu = 0.1, priorrho = c(4, 4),
n_chains = 3)
## Extract beta draws from the second chain
svbeta(draws, chain = 2)
## ... tau draws from all chains merged/concatenated together
svtau(draws)
## Create a new svdraws object from the first and third chain
second_chain_excluded <- draws[c(1, 3)]
# Draw from the predictive distribution
pred <- predict(draws, steps = 2)
## Extract the predicted observations as an mcmc.list object
predicted_y <- predy(pred, chain = "all")
## ... the predicted standard deviations from the second chain
predicted_sd <- predvola(pred, chain = 2)
## Create a new svpredict object from the first and third chain
second_chain_excluded <- pred[c(1, 3)]