Learn R Programming

segMGarch (version 1.2)

kupiec: Method to backtest VaR violation using the Kupiec statistics

Description

An S4 method that performs backtest for VaR models using the Kupiec statistics. For a sample of \(n\) observations, the Kupiec test statistics takes the form of likelihood ratio

\(LR_{PoF}= -2 \log\left(\frac{(1-\alpha)^{T-n_f}\alpha^{n_f}} {\left(1-\frac{n_f}{T}\right)^{T-n_f}\left(\frac{n_f}{T}\right)^{n_f}}\right)\)

\(LR_{TFF}= -2 \log\left (\frac{\alpha(1-\alpha)^{t_f -1}} {\left ( \frac{1}{t_f}\right )\left ( 1- \frac{1}{t_f}\right )^{t_f-1}}\right), \)

where \(n_f\) denotes the number of failures occurred and \(t_f\) the number of days until the first failure within the \(n\) observations. Under \(H_0\), both \(LR_{PoF}\) and \(LR_{TFF}\) are asymptotically \(\chi^2_1\)-distributed, and their exceedance of the critical value implies that the VaR model is inadequate.

Usage

kupiec(y, VaR, VaR_level, verbose = TRUE, test = "PoF")

# S4 method for ANY kupiec(y, VaR, VaR_level, verbose = TRUE, test = "PoF")

Arguments

y

The time series to apply a VaR model (a single asset rerurn or portfolio return).

VaR

The forecast VaR.

VaR_level

The VaR level, typically 95% or 99%.

verbose

If TRUE show the outcome. Default is TRUE.

test

Choose between PoF or TFF. Default is PoF.

References

Kupiec, P. "Techniques for Verifying the Accuracy of Risk Management Models." Journal of Derivatives. Vol. 3, 1995, pp. 73<U+2013>84.

Examples

Run this code
# NOT RUN {
pw.CCC.obj = new("simMGarch")
pw.CCC.obj@d = 10
pw.CCC.obj@n = 1000
pw.CCC.obj@changepoints = c(250,750)
pw.CCC.obj = pc_cccsim(pw.CCC.obj)
y_out_of_sample = t(pw.CCC.obj@y[,900:1000])
w=rep(1/pw.CCC.obj@d,pw.CCC.obj@d) #an equally weighted portfolio
#VaR = quantile(t(pw.CCC.obj@y[,1:899])%*%w,0.05)
#ts.plot(y_out_of_sample%*%w,ylab="portfolio return");abline(h=VaR,col="red")
#kupiec(y_out_of_sample%*%w,rep(VaR,100),.95,verbose=TRUE,test="PoF")
# }

Run the code above in your browser using DataLab