extractors: Common Extractors for 'svdraws' and 'svpredict' Objects

Description Usage Arguments Value See Also Examples

Description

Some simple extractors returning the corresponding element of an svdraws and svpredict object.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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

svdraws object.

chain

optional either a positive integer or the string "concatenated" (default) or the string "all".

y

svpredict object.

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 prior_spec object as generated by specify_priors.

thinning(x)

extracts the thinning parameters used and returns them in a list.

runtime(x)

extracts the runtime and returns it as a proc_time object.

sampled_parameters(x)

returns the names of time independent model parameters that were actually sampled by svsample.

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# 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)]

stochvol documentation built on July 12, 2021, 5:08 p.m.