[R-SIG-Finance] Problem with modified Var in PerformanceAnalytics?

Sergey Goriatchev sergeyg at gmail.com
Wed Apr 21 15:12:52 CEST 2010


Hello, everyone

I am calculating Cornish-Fisher VAR and I get an error message, so I
went in and did calculation by hand given the formula in the April 8,
2010 PerformanceAnalytics PDF
The two calculations do not match.
Am I blind and miss something obvious?

Thank you in advance for help!

Here is the code for an example:

library(PerformanceAnalytics)

Ra <- structure(c(0.00381225000000002, 0.01910025, 0.00866775000000002,
-0.00999375000000001, 0.0088140, -0.00122850000000003, 0.00286650000000001,
0.00760499999999998, 0.0026715, -0.00381224999999998, -0.00147225000000001,
0.000331499999999986, 0.00631800000000001, 0.00681525, 0.00448499999999998,
0.00428025000000001, -0.000555749999999994, -0.0189540000000000,
-0.000117000000000009, 0.00579149999999999, 0.005694, 0.000331500000000014,
0.000721500000000004, 0.000282749999999978, -0.000399750000000014,
0.016536, -0.00507974999999999, 0.00442649999999999, 0.00569399999999998,
-9.75000000002328e-06, -0.004719, 0.00773175, 0.00228150000000004,
-0.00635700000000002, 0.00163800000000003, 0.007449, 0.00535275000000001,
-0.00605474999999998, -0.00421199999999998, 0.0194610000000001,
0.0108127500000000, 0.0109102500000000, -0.0111930000000000,
0.0145665, -0.00220350000000003, 0.00364650000000005, -0.0134355,
0.0105202500000000, 0.0223665000000000, -0.0139035000000000,
-0.0076635, 0.00435824999999995, 0.00554774999999995, 0.09245925,
0.00257399999999992, 0.04094025, -0.00376349999999998, 0.00881278075224753,
0.00688591476689867, 0.0167352183579443, 0.00653643129435772,
0.0098458420745749, 0.0221513897096388, 0.00170018050184855,
0.0162582129024928, 0.0040719625229251, 0.0183583618801177,
0.00981248749367947,
-0.000320212636643245, 0.0113273034537261, 0.0138203348625449
), index = structure(c(12569, 12599, 12630, 12661, 12691, 12722,
12752, 12783, 12814, 12842, 12873, 12903, 12934, 12964, 12995,
13026, 13056, 13087, 13117, 13148, 13179, 13207, 13238, 13268,
13299, 13329, 13360, 13391, 13421, 13452, 13482, 13513, 13544,
13572, 13603, 13633, 13664, 13694, 13725, 13756, 13786, 13817,
13847, 13878, 13909, 13938, 13969, 13999, 14030, 14060, 14091,
14122, 14152, 14183, 14213, 14244, 14275, 14303, 14334, 14364,
14395, 14425, 14456, 14487, 14517, 14548, 14578, 14609, 14640,
14668, 14699), .Names = c("", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "", ""), class =
"Date"), class = "zoo")

#-----------------------------------

av <- mean(Ra)
std <- sd(Ra)
sk <- skewness(Ra)
kur <- kurtosis(Ra, method="excess")

zc <- qnorm(0.95)
zc2 <- zc^2
zc3 <- zc^3
sk2 <- sk^2

zcf <- zc+((zc2-1)*sk)/6+((zc3-3*zc)*kur)/24-((2*zc3-5*zc)*sk2)/36

CoFisherVAR <- -av-std*zcf
CoFisherVAR

VaR(Ra, method="modified")



More information about the R-SIG-Finance mailing list