| stochvol_ocsn2007 | R Documentation | 
Produces a draw of log-volatilities based on Omori, Chib, Shephard and Nakajima (2007).
stochvol_ocsn2007(y, h, sigma, h_init, constant)
y | 
 a   | 
h | 
 a   | 
sigma | 
 a   | 
h_init | 
 a   | 
constant | 
 a   | 
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:
 Perform the transformation y_t^* = ln(y_t^2 + constant).
 Obtain a sample from the ten-component normal mixture for
approximating the log-\chi_1^2 distribution.
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).
A vector of log-volatility draws.
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")}
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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.