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")
Problem with modified Var in PerformanceAnalytics?
2 messages · Sergey Goriatchev, Brian G. Peterson
1 day later
There are two discrepancies that we see on reviewing your example. By far the biggest one is the use of p=.95. In the calculation, it is actually \alpha, or 1-p, because we are concerned with the loss tail of the distribution, not the best 5% returns. In the code, the function .checkalphaprob takes care of this. When this is corrected, there is still a discrepancy, but it is very small. The second arises from a discrepancy in the literature on comoments. Standardized skewness uses 1/T-1, and this is recommended for any short series. Because the VaR/ES calculations in PerformanceAnalytics now also support component risk decomposition, we apply the standard centered mathematical moment calculation to calculate the third centered moment, which we then standardize as per the usual definition of skewness. This effectively uses 1/T rather than 1/T-1. This is a decision consistent with the literature on coskewness and cokurtosis, which are required for the component decomposition. In longer series, the discrepancy would be miniscule, and in this example series, the discrepancy is still very small. Kris and I will continue to discuss how to update the documentation, or perhaps the functions, to make this clearer. Regards, - Brian
On 04/21/2010 08:12 AM, Sergey Goriatchev wrote:
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")
_______________________________________________ R-SIG-Finance at stat.math.ethz.ch 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.
Brian G. Peterson http://braverock.com/brian/ Ph: 773-459-4973 IM: bgpbraverock