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 1 vector containing the time series.

h

a T \times 1 vector of log-volatilities.

sigma

a numeric of the variance of the log-volatilites.

h_init

a numeric of the initial state of log-volatilities.

constant

a numeric of the constant that should be added to y^2 before taking the natural logarithm. See 'Details'.

Details

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.

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 <- us_macrodata[, "r"]

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

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


bvartools documentation built on Aug. 31, 2023, 1:09 a.m.