Hello,
someone, maybe Alexios even, could confirm what are the arguments to these functions? I suspect that VaRloss and VaRTest the inputs are the actual realized RETURNS and corresponding lower quantiles for VaR, while to ESTest it seems to be the opposite, the actual LOSSES and corresponding higher quantiles. I checked the source code but still in doubt. Thanks, Rafael [[alternative HTML version deleted]] _______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go. |
Hi Rafael,
VaRloss and VaRTest take the realized and conditional quantiles, whilst the ESTest takes the realized, conditional expected shortfall and conditional quantiles (as the help file example shows). Here is a short script showing how VaRloss can be used: ################################################################ # ideally you want to test many models with different distributions # for this example library(xts) library(rugarch) data("sp500ret") R = xts(as.numeric(sp500ret[,1]), as.Date(rownames(sp500ret))) spec<-vector(mode="list", length=2) spec[[1]]<-ugarchspec(mean.model = list(armaOrder=c(2,1)), variance.model=list(model="sGARCH")) spec[[2]]<-ugarchspec(mean.model = list(armaOrder=c(2,1)), variance.model=list(model="gjrGARCH")) fitlist = vector(mode="list", length = 2) for(i in 1:2){ tmp = ugarchroll(spec[[i]], R, n.ahead = 1, forecast.length = 1500, refit.every = 50,refit.window = "moving", windows.size = 1500, solver = "hybrid",calculate.VaR = FALSE, keep.coef = FALSE) if(!is.null(tmp@model$noncidx)){ tmp = resume(tmp, solver = "solnp", fit.control = list(scale=1), solver.control = list(tol=1e-7, delta=1e-6), cluster = cluster) if(!is.null(tmp@model$noncidx)) fitlist[[i]] = NA } else{ fitlist[[i]] = as.data.frame(tmp, which = "density") } } ## The cost of misspecification using VaR qx1 = qx5 = matrix(NA, ncol = 2, nrow = 1500) for(i in 1:2){ qx5[,i] = as.numeric(apply(fitlist[[i]], 1, function(x) qdist("norm", 0.05, mu = x["Mu"],sigma = x["Sigma"], skew = x["Skew"], shape = x["Shape"]))) qx1[,i] = as.numeric(apply(fitlist[[i]], 1, function(x) qdist("norm", 0.01, mu = x["Mu"],sigma = x["Sigma"], skew = x["Skew"], shape = x["Shape"]))) } VL5 = apply(qx5, 2, function(x) VaRloss(0.05, fitlist[[1]][,"Realized"], x)) test <- mcsTest(VL5, 0.05, 5000, 1, "stationary") ################################################################ Regards, Alexios On 12/15/2017 4:09 AM, Rafael Bressan wrote: > Hello, > > someone, maybe Alexios even, could confirm what are the arguments to these > functions? > > I suspect that VaRloss and VaRTest the inputs are the actual realized > RETURNS and corresponding lower quantiles for VaR, > > while to ESTest it seems to be the opposite, the actual LOSSES and > corresponding higher quantiles. > > I checked the source code but still in doubt. > > Thanks, > Rafael > > [[alternative HTML version deleted]] > > _______________________________________________ > [hidden email] mailing list > https://stat.ethz.ch/mailman/listinfo/r-sig-finance > -- Subscriber-posting only. If you want to post, subscribe first. > -- Also note that this is not the r-help list where general R questions should go. > _______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go. |
Free forum by Nabble - Free Resume Builder | Edit this page |