var_es: One-step-ahead Value at Risk and Expected Shortfall

View source: R/risk.R

var_esR Documentation

One-step-ahead Value at Risk and Expected Shortfall

Description

Calculates the one-day Value at Risk (VaR) and Expected Shortfall (ES) of the returns from the predictive distribution of y_t given y_1, ..., y_{t-1}, for every observation and for the next day after the data.

Usage

var_es(object, level = c(0.95, 0.99), grid_size = 500)

Arguments

object

A stochvolTMB object returned from estimate_parameters.

level

Vector of confidence levels between 0.5 and 1.

grid_size

Number of grid points for the log-volatility.

Details

The predictive distribution is calculated exactly with the same filter on a grid for the log-volatility as residuals.stochvolTMB. It is a mixture over h_t of the conditional distribution of the returns. For a level \alpha, for example 0.99, let q_t be the 1 - \alpha quantile of the predictive distribution. Then

VaR_t = -q_t, \qquad ES_t = -E[y_t \mid y_t \le q_t, y_1, \ldots, y_{t-1}].

Both are reported as positive numbers when they are losses, on the scale of the returns. A return is an exceedance if y_t < -VaR_t.

The parameters are fixed at their estimates from the full data, and the uncertainty of the parameters is not included. The values for the observed data are therefore in-sample, and a backtest with backtest_var on them is slightly optimistic. The last row (time = nobs + 1) is the forecast for the next day. For more than one day, use forecast_var_es.

Value

A data.table with one row for each time point and level, and the columns time (1 to nobs + 1), level, y (the observed return, NA for the forecast), var, es and exceedance (y < -var).

See Also

backtest_var, forecast_var_es

Examples


opt <- estimate_parameters(spy$log_return, model = "skew_t_leverage", silent = TRUE)
risk <- var_es(opt, level = c(0.95, 0.99))
# Forecast for the next day
risk[is.na(y)]
backtest_var(risk)


stochvolTMB documentation built on Nov. 7, 2026, 5:08 p.m.