MannWhitney.Wilcoxon <- function(met=1, DGP=1:15, mets=7, res=2, replic=1000) { ################################################################################ # # # Mann-Whitney and Wilcoxon Function by Breno de Andrade Pinheiro Néri # # # # brenoneri@gmail.com www.fgv.br/aluno/bneri # # # # October, 2005 - Version 2 # # # ################################################################################ # # # This code computes Mann-Whitney and Wilcoxon test to help you to analyze the # # results of the Monte Carlo Simulations generated by MC_VaR.R or MC_VaRox.R. # # # # You enter the VaR methodology (met), 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: met=1, 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. # # # ################################################################################ message("") message("Two sided Mann-Whitney and Wilcoxon rank sum test with continuity correction p-values:") 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]] } message("") message("VaR methodology ", met, " under DGP ", j, ":") for(i in 1:mets) message("Comparing with VaR methodology ", i, ": ", wilcox.test(x[,met], x[,i], alternative="two.sided")[[3]]) } }