stochvol_ocsn2007: Stochastic Volatility

View source: R/RcppExports.R

stochvol_ocsn2007R Documentation

Stochastic Volatility

Description

Produces a draw of log-volatilities based on Omori, Chib, Shephard and Nakajima (2007).

Usage

stochvol_ocsn2007(y, h, sigma, h_init, constant)

Arguments

y

a T \times K matrix containing the time series.

h

a T \times K vector of the current draw of log-volatilities.

sigma

a K \times 1 vector of variances of log-volatilities, where the ith element corresponds to the ith column in y.

h_init

a K \times 1 vector of the initial states of log-volatilities, where the ith element corresponds to the ith column in y.

constant

a K \times 1 vector of constants that should be added to y^2 before taking the natural logarithm. The ith element corresponds to the ith column in y. See 'Details'.

Details

For each column in y the function produces a posterior draw of the log-volatility h for the model

y_{t} = e^{\frac{1}{2}h_t} \epsilon_{t},

where \epsilon_t \sim N(0, 1) and h_t is assumed to evolve according to a random walk

h_t = h_{t - 1} + u_t,

with u_t \sim N(0, \sigma^2).

The implementation follows the algorithm of Omori, Chib, Shephard and Nakajima (2007) and performs the following steps:

  1. Perform the transformation y_t^* = ln(y_t^2 + constant).

  2. Obtain a sample from the ten-component normal mixture for approximating the log-\chi_1^2 distribution.

  3. Obtain a draw of log-volatilities.

The implementation is an adaption of the code provided on the website to the textbook by Chan, Koop, Poirier, and Tobias (2019).

Value

A vector of log-volatility draws.

References

Chan, J., Koop, G., Poirier, D. J., & Tobias J. L. (2019). Bayesian econometric methods (2nd ed.). Cambridge: Cambridge University Press.

Omori, Y., Chib, S., Shephard, N., & Nakajima, J. (2007). Stochastic volatiltiy with leverage. Fast and efficient likelihood inference. Journal of Econometrics 140(2), 425–449. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1016/j.jeconom.2006.07.008")}

Examples

data("us_macrodata")
y <- matrix(us_macrodata[, "r"])

# Initialise log-volatilites
h_init <- matrix(log(var(y)))
h <- matrix(rep(h_init, length(y)))

# Obtain draw
stochvol_ocsn2007(y - mean(y), h, matrix(.05), h_init, matrix(0.0001))


franzmohr/bvartools documentation built on Jan. 28, 2024, 4:06 a.m.