View source: R/analysis_helpers.R
| compute_kupiec | R Documentation |
Performs Kupiec's (1995) Unconditional Coverage (UC) test for evaluating Value-at-Risk (VaR) forecasts from competing forecast against realized values.
Hypotheses:
H0: The forecast correctly captures VaR — violations occur with the
expected frequency alpha.
H1: The forecast fails to correctly capture VaR — the observed
frequency of violations differs significantly from alpha.
compute_kupiec(
forecast_matrix,
forecast_sd_models,
benchmark_col = ncol(forecast_matrix),
alpha = 0.05
)
forecast_matrix |
|
forecast_sd_models |
|
benchmark_col |
Index or name of the benchmark column. Defaults to the last column. |
alpha |
|
For each competing forecast k, the VaR at level alpha is:
VaR_{t,k} = \hat{y}_{t,k} + \Phi^{-1}(\alpha) \cdot \hat{\sigma}_{t,k}
where \Phi^{-1} is the standard normal quantile function. A violation occurs
when the realized value falls below VaR_{t,k}. The likelihood-ratio statistic
LR_{UC} follows a \chi^2(1) distribution under H0 (Kupiec, 1995).
Failing to reject H0 (large p-value) indicates correctly calibrated VaR;
rejecting H0 (small p-value) indicates the forecast under- or over-estimates
tail risk.
A named list (one element per competing forecast) of htest objects,
each containing:
statisticThe LR-UC test statistic (\chi^2-distributed under
H0).
p.valueP-value from the \chi^2(1) distribution. A large
p-value indicates correctly calibrated VaR coverage.
actual_exceedancesObserved number of VaR violations.
expectedExpected number of violations
(P * alpha).
Kupiec, P. H. (1995). Techniques for Verifying the Accuracy of Risk Measurement Models. The Journal of Derivatives, 3(2), 173–184. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.3905/jod.1995.407942")}
estimate_forecast_variance,
run_comprehensive_erc_analysis
data(metals)
benchmark_col <- 15
K_total <- ncol(metals)
comp_cols <- setdiff(seq_len(K_total), benchmark_col)
forecast_variance <- estimate_forecast_variance(metals,
benchmark_col = benchmark_col, window_size = 20)
forecast_sd_models <- sqrt(forecast_variance[, comp_cols])
coverage_results <- compute_kupiec(metals, forecast_sd_models,
benchmark_col = benchmark_col, alpha = 0.05)
print(coverage_results[[1]])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.