The conditional (Kupiec, 1995), the unconditional coverage test (Christoffersen, 1998) and the independence test (Christoffersen, 1998) of the Value-at-Risk (VaR) can be applied.
covtest(obj = list(Loss = NULL, VaR = NULL, p = NULL), conflvl = 0.95)A list of class ufRisk with the following four elements:
probability p stated in the null hypotheses of the coverage tests.
the p-value of the unconditional coverage test.
the p-value of the conditional coverage test.
the p-value of the independence test.
the significance level at which the null hypotheses are evaluated.
a list that contains the following elements:
Lossa numeric vector that contains the values of a loss series
ordered from past to present; is set to NULL by default.
VaRa numeric vector that contains the estimated values of the
VaR for the same time points of the loss series Loss;
is set to NULL by default.
pa numeric vector with one element; defines the probability p
stated in the null hypotheses of the coverage tests (see the section
Details for more information); is set to NULL by default.
a numeric vector with one element; the significance
level at which the null hypotheses are evaluated; is set to 0.95 by
default.
Please note that a list returned by the varcast function can be directly
passed to covtest.
Sebastian Letmathe (Scientific Employee) (Department of Economics,
Paderborn University)
Dominik Schulz (Scientific Employee) (Department of Economics,
Paderborn University),
With this function, the conditional and the unconditional coverage tests introduced by Kupiec (1995) and Christoffersen (1998) can be applied. Given a return series \(r_t\) with \(n\) observations, divide the series into \(n-K\) in-sample and \(K\) out-of-sample observations, fit a model to the in-sample data and obtain rolling one-step forecasts of the VaR for the out-of-sample time points.
Define
$$I_t = 1,$$
if \(-r_t > \widehat{VaR}_t (\alpha)\) or
$$I_t = 0,$$ otherwise,
for \(t = n + 1, n + 2, ..., n + K\) as the hit sequence, where \(\alpha\) is the confidence level for the VaR (often \(\alpha = 0.95\) or \(\alpha = 0.99\)). Furthermore, denote \(p = \alpha\) and let \(w\) be the actual covered proportion of losses in the data.
1. Unconditional coverage test:
$$H_{0, uc}: p = w$$
Let \(K_1\) be the number of ones in \(I_t\) and analogously \(K_0\) the number of zeros (all conditional on the first observation). Also calculate \(\hat{w} = K_0 / (K - 1)\). Obtain
$$L(I_t, p) = p^{K_0}(1 - p)^{K_1}$$
and
$$L(I_t, \hat{w}) = \hat{w}^{K_0}(1 - \hat{w})^{K_1}$$
and subsequently the test statistic
$$LR_{uc} = -2 * \ln \{L(I_t, p) / L(I_t, \hat{w})\}.$$
\(LR_{uc}\) now asymptotically follows a chi-square-distribution with one degree of freedom.
2. Conditional coverage test:
The conditional coverage test combines the unconditional coverage test with a test on independence. Denote by \(w_{ij}\) the probability of an \(i\) on day \(t-1\) being followed by a \(j\) on day \(t\), where \(i\) and \(j\) correspond to the value of \(I_t\) on the respective day.
$$H_{0, cc}: w_{00} = w{10} = p$$
with \(i = 0, 1\) and \(j = 0, 1\).
Let \(K_{ij}\) be the number of observations, where the values on two following days follow the pattern \(ij\). Calculate
$$L(I_t, \hat{w}_{00}, \hat{w}_{10}) = \hat{w}_{00}^{K_{00}}(1 - \hat{w}_{00})^{K_{01}} * \hat{w}_{10})^{K_{10}}(1 - \hat{w}_{10})^{K_{11}},$$
where \(\hat{w}_{00} = K_{00} / K_0\) and \(\hat{w}_{10} = K_{10} / K_1\). The test statistic is then given by
$$LR_{cc} = -2 * \ln \{ L(I_t, p) / L(I_t, \hat{w}_{00}, \hat{w}_{10}) \},$$
which asymptotically follows a chi-square-distribution with two degrees of freedom.
3. Independence test:
$$H_{0,ind}: w_{00} = w_{10}$$
The asymptotically chi-square-distributed test statistic (one degree of freedom) is given by
$$LR_{ind} = -2 * \ln \{L(I_t, \hat{w}_{00}, \hat{w}_{10}) / L(I_t, \hat{w})\}.$$
-----------------------------------------------------------------------------
The function needs four inputs: the out-of-sample loss series obj$Loss, the
corresponding estimated VaR series obj$VaR, the coverage level obj$p,
for which the VaR has been calculated and the significance level conflvl,
at which the null hypotheses are evaluated. If an object returned by this function
is entered into the R console, a detailed overview of the test
results is printed.
Christoffersen, P. F. (1998). Evaluating interval forecasts. International economic review, pp. 841-862.
Kupiec, P. (1995). Techniques for verifying the accuracy of risk measurement models. The J. of Derivatives, 3(2).
# \donttest{
# Example for Walmart Inc. (WMT)
prices <- WMT$price.close
output <- varcast(prices)
Loss <- -output$ret.out
VaR <- output$VaR.v
covtest.data <- list(Loss = Loss, VaR = VaR, p = 0.99)
covtest(covtest.data)
# directly passing an output object of 'varcast()' to 'covtest()'
output <- varcast(prices)
covtest(output)
# }
Run the code above in your browser using DataLab