Descriptive.Analysis <- function(DGP=1:15, mets=7, res=2, replic=1000) { ################################################################################ # # # Descriptive Analysis Function by Breno de Andrade Pinheiro Néri # # # # brenoneri@gmail.com www.fgv.br/aluno/bneri # # # # October, 2005 - Version 3 # # # ################################################################################ # # # This code computes descritive statistics to help you to analyze the results # # of the Monte Carlo Simulations generated by MC_VaR.R or MC_VaRox.R. # # # # You enter the DGP range (DGP, observe that it is a vector), the number of # # methodologies generated in your Monte Carlo Simulations (mets), the desired # # test statistics (res) and the number # # of replications generated in your MC Simulations (replic). # # # # You can choose among eleven test statistics generated by the code # # BackTest.R, setting up the res variable. Namely: # # 1: frequency of violations; # # 2: number of violations (default); # # 3: ---Not Available---; # # 4: Unconditional Coverage (Kupiec, 1995) Likelihood Ratio Test; # # 5: Independence (Christoffersen, 1997) Likelihood Ratio Test; # # 6: Conditional Coverage (Christoffersen, 1997) Likelihood Ratio Test; # # 7: Dynamic Quantile (Engle and Manganelli, 2002) Test Statistic; # # 8: Unconditional Coverage (Kupiec, 1995) P-Value; # # 9: Independence (Christoffersen, 1997) P-Value; # # 10: Conditional Coverage (Christoffersen, 1997) P-Value; # # 11: Dynamic Quantile (Engle and Manganelli, 2002) P-Value; # # 12: Magnitude Loss Function (Lopez, 1998). # # # # Defaults: DGP=1:15, mets=7, res=2, replic=1000. # # # ################################################################################ # # # 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. # # # ################################################################################ library(fBasics) library(tseries) for(j in DGP) { x <- array(0, c(replic, mets)) for(i in 1:replic) { load(paste("MC_VaR", j, i, "R", sep=".")) x[i,] <- result[[res]] } for(met in 1:mets) { message("") message("VaR methodology ", met, " under DGP ", j, ":") message("") message("Mean: ", mean(x[,met])) message("Median: ", median(x[,met])) message("Variance: ", var(x[,met])) message("Min: ", min(x[,met])) message("Max: ", max(x[,met])) message("Range: ", max(x[,met])-min(x[,met])) message("Skewness: ", skewness(x[,met])) message("Excess Kurtosis: ", kurtosis(x[,met])) message("P-Value of the Jarque-Bera Test for Normality: ", jarque.bera.test(x[,met])[[3]]) message("") } message("") } }