Learn R Programming

bvartools (version 0.2.4)

stoch_vol: Stochastic Volatility

Description

Produces a draw of log-volatilities.

Usage

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

Value

A vector of log-volatility draws.

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.

Details

The function is a wrapper for function stochvol_ksc1998.

References

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

Kim, S., Shephard, N., & Chib, S. (1998). Stochastic volatility. Likelihood inference and comparison with ARCH models. Review of Economic Studies 65(3), 361--393. tools:::Rd_expr_doi("10.1111/1467-937X.00050")

Examples

Run this code
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
stoch_vol(y - mean(y), h, matrix(.05), h_init, matrix(0.0001))

Run the code above in your browser using DataLab