0

I tried to calculate the Value at Risk for a list auf Stock Returns. There are 1000 observations, but i wanted to calculate like the following:

VaR for observation:

1 to 500
2 to 501
3 to 502
4 to 503 
and 500 to 999

as you can see the result would be 500 calculations.

To solve the problem I tried to use a if condition with a for loop.

like this:

if(x < 501 & y < 1000){for(i in KO.Returns){VaR(KO.Returns[x: y], p = 0.95, method = "historical")}}

If I use the mentioned code I get the following error code:

VaR calculation produces unreliable result (inverse risk) for column 1:

LittleBobbyTables - Au Revoir
  • 32,008
  • 25
  • 109
  • 114

1 Answers1

0

I think the problem is in your data. When you specify your window, the calculation of historical VaR sorts the data and picks out 95th percentile. Sometimes your data will not have a negative value in that percentile, thus historical VaR is meaningless (your losses cannot be a positive value, loss is always negative). Hence the error.

I have been trying to reproduce similar errors using the following code:

library(PerformanceAnalytics)

data("edhec")
data = edhec[, 5]

valat = rollapply(data = data, width = 20,
                  FUN = function(x) VaR(x, p = 0.95, method = "historical"),
                  by.column = TRUE)
valat 

But when I change the confidence level to p = 0.99, I stop getting the error. So, maybe you can try to change your confidence level and see.

Also see this and this.

AK88
  • 2,946
  • 2
  • 12
  • 31
  • Thanks for your help. I tried different confidence levels and methods. But it still does not work. I also checked my data for missing negative value´s in every window. Didn´t help either. – Alexander Hentschel Jun 14 '17 at 12:13