Result.Generator <- function(N=1000, i=1, l=.01) { ################################################################################ # # # Result.Generator Function by Breno de Andrade Pinheiro Néri # # # # brenoneri@gmail.com www.fgv.br/aluno/bneri # # # # September, 2005 - Version 1 # # # ################################################################################ # # # This function computes and prints the frequency of rejection of the five # # backtests generated by MC_VaR.R or MC_VaRox.R codes, by Breno Néri, namely: # # 1- Kupiec (1995), Unconditional Coverage; # # 2- Christoffersen (1997), Independence; # # 3- Christoffersen (1997), Conditional Coverage; # # 4- Engle and Manganelli (2002), Dynamic Quantile; # # 5- Lopez (1998), Magnitude Loss Function. # # # # You enter the number of replications generated by the Monte Carlo (N), the # # choosen DGP (i), and the Significance Level of the tests (l). # # # # Defaults: N=1000, i=1, l=1%. # # # ################################################################################ # # # You may use this code only if you accept the conditions: # # (1) I am not liable for any problem caused by this code (i.e. you use it at # # your own risk); # # (2) You must give me credit in your papers where this code has been used. # # # ################################################################################ res <- array(0, c(N,7,5)) for(j in 1:N) { load(paste("MC_VaR", i, j, "R", sep=".")) for(k in 1:5) res[j,,k] <- result[[7+k]] } cat("\nKupiec's Test Size for Unconditional Coverage at", 100*l, "% =", apply((res[,,1]