Learn R Programming

segMGarch (version 1.3)

TL: Method to backtest VaR violation using the Traffic Light (TL) approach of Basel

Description

A method that performs backtest for VaR models using the TL approach. According to Basel, a VaR model is deemed valid if the cumulative probability of observing up to \(n_f\) failures is less than 0.95 (green zone) under the binomial distribution with \(n\) (sample size) and Var level as the parameters. If the cumulative probability is between 0.95 and 0.9999 a VaR model is in yellow zone. Otherwise (>0.9999) a VaR model is in red zone.

Usage

TL(y, n = NULL, no_fail = NULL, VaR, VaR_level)

# S4 method for ANY TL(y, n = NULL, no_fail = NULL, VaR, VaR_level)

Arguments

y

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

n

If y is not provided, then insert sample size. Default is NULL.

no_fail

If y is not provided, then insert number of fails. Default is NULL.

VaR

The forecast VaR.

VaR_level

The VaR level, typically 95% or 99%.

References

Basle Committee on Banking Supervision (1996). "Supervisory Framework for the Use of ‘Backtesting’ in Conjunction with the Internal Models Approach to Market Risk Capital Requirements".

Examples

Run this code
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")
#TL(y=y_out_of_sample%*%w,VaR=rep(VaR,100),VaR_level = 0.95)

Run the code above in your browser using DataLab