Creates or updates a summary of an svdraws object.
updatesummary(
x,
quantiles = c(0.05, 0.5, 0.95),
esspara = TRUE,
esslatent = FALSE
)svdraws object.
numeric vector of posterior quantiles to be computed. The
default is c(0.05, 0.5, 0.95).
logical value which indicates whether the effective sample
size (ESS) should be calculated for the parameter draws. This is
achieved by calling effectiveSize from the coda
package. The default is TRUE.
logical value which indicates whether the effective sample
size (ESS) should be calculated for the latent log-volatility draws.
This is achieved by calling effectiveSize from the
coda package. The default is FALSE, because this can be quite
time-consuming when many latent variables are present.
The value returned is an updated list object of class svdraws
holding
mcmc object containing the parameter draws
from the posterior distribution.
mcmc object
containing the latent instantaneous log-volatility draws from the
posterior distribution.
mcmc object containing the
latent initial log-volatility draws from the posterior distribution.
argument y.
"proc_time" object
containing the run time of the sampler.
list
containing the parameter values of the prior distribution, i.e. the
arguments priormu, priorphi, priorsigma (and
potentially nu).
list containing the thinning
parameters, i.e. the arguments thinpara, thinlatent and
keeptime.
list containing a collection of
summary statistics of the posterior draws for para, latent,
and latent0.
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 gives a graphical
overview of the posterior distribution by calling volplot,
traceplot and densplot and displaying the
results on a single page.
updatesummary will always calculate the posterior mean and the
posterior standard deviation of the raw draws and some common
transformations thereof. Moroever, the posterior quantiles, specified by the
argument quantiles, are computed. If esspara and/or
esslatent are TRUE, the corresponding effective sample size
(ESS) will also be included.
updatesummary does not actually overwrite the object's current
summary, but in fact creates a new object with an updated summary. Thus,
don't forget to overwrite the old object if this is want you intend to do.
See the examples below for more details.
## Here is a baby-example to illustrate the idea.
## Simulate an SV time series of length 51 with default parameters:
sim <- svsim(51)
## Draw from the posterior:
res <- svsample(sim$y, draws = 2000, priorphi = c(10, 1.5))
#> Done!
#> Summarizing posterior draws...
## Check out the results:
summary(res)
#>
#> Summary of 'svdraws' object
#>
#> Prior distributions:
#> mu ~ Normal(mean = 0, sd = 100)
#> (phi+1)/2 ~ Beta(a = 10, b = 1.5)
#> sigma^2 ~ Gamma(shape = 0.5, rate = 0.5)
#> nu ~ Infinity
#> rho ~ Constant(value = 0)
#>
#> Stored 2000 MCMC draws after a burn-in of 1000.
#> No thinning.
#>
#> Posterior draws of SV parameters (thinning = 1):
#> mean sd 5% 50% 95% ESS
#> mu -9.5039 0.3031 -1.0e+01 -9.5146 -9.040 407
#> phi 0.6854 0.1917 3.4e-01 0.7070 0.950 212
#> sigma 0.2175 0.1716 1.3e-02 0.1861 0.537 180
#> exp(mu/2) 0.0087 0.0015 6.9e-03 0.0086 0.011 407
#> sigma^2 0.0768 0.1175 1.6e-04 0.0346 0.289 180
#>
plot(res)
## Look at other quantiles and calculate ESS of latents:
newquants <- c(0.01, 0.05, 0.25, 0.5, 0.75, 0.95, 0.99)
res <- updatesummary(res, quantiles = newquants, esslatent = TRUE)
## See the difference?
summary(res)
#>
#> Summary of 'svdraws' object
#>
#> Prior distributions:
#> mu ~ Normal(mean = 0, sd = 100)
#> (phi+1)/2 ~ Beta(a = 10, b = 1.5)
#> sigma^2 ~ Gamma(shape = 0.5, rate = 0.5)
#> nu ~ Infinity
#> rho ~ Constant(value = 0)
#>
#> Stored 2000 MCMC draws after a burn-in of 1000.
#> No thinning.
#>
#> Posterior draws of SV parameters (thinning = 1):
#> mean sd 1% 5% 25% 50% 75% 95%
#> mu -9.5039 0.3031 -1.0e+01 -1.0e+01 -9.6815 -9.5146 -9.3382 -9.040
#> phi 0.6854 0.1917 1.9e-01 3.4e-01 0.5663 0.7070 0.8354 0.950
#> sigma 0.2175 0.1716 2.9e-03 1.3e-02 0.0791 0.1861 0.3186 0.537
#> exp(mu/2) 0.0087 0.0015 6.0e-03 6.9e-03 0.0079 0.0086 0.0094 0.011
#> sigma^2 0.0768 0.1175 8.6e-06 1.6e-04 0.0063 0.0346 0.1015 0.289
#> 99% ESS
#> mu -8.685 407
#> phi 0.981 212
#> sigma 0.716 180
#> exp(mu/2) 0.013 407
#> sigma^2 0.513 180
#>
plot(res)