covtest  R Documentation 
The conditional (Kupiec, 1995), the unconditional coverage test (Christoffersen, 1998) and the independence test (Christoffersen, 1998) of the ValueatRisk (VaR) can be applied.
covtest(obj = list(Loss = NULL, VaR = NULL, p = NULL), conflvl = 0.95)
obj 
a list that contains the following elements:

conflvl 
a numeric vector with one element; the significance
level at which the null hypotheses are evaluated; is set to 
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 nK
insample and K
outofsample observations,
fit a model to the insample data and obtain rolling onestep forecasts of
the VaR for the outofsample 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 chisquaredistribution 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
t1
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 chisquaredistribution with two degrees of freedom.
3. Independence test:
H_{0,ind}: w_{00} = w_{10}
The asymptotically chisquaredistributed 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 outofsample 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.
A list of class ufRisk
with the following four elements:
probability p stated in the null hypotheses of the coverage tests.
the pvalue of the unconditional coverage test.
the pvalue of the conditional coverage test.
the pvalue of the independence test.
the significance level at which the null hypotheses are evaluated.
Sebastian Letmathe (Scientific Employee) (Department of Economics,
Paderborn University)
Dominik Schulz (Scientific Employee) (Department of Economics,
Paderborn University),
Christoffersen, P. F. (1998). Evaluating interval forecasts. International economic review, pp. 841862.
Kupiec, P. (1995). Techniques for verifying the accuracy of risk measurement models. The J. of Derivatives, 3(2).
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.