Quantcast

Proposal for PerformanceAnalytics::Omega, method = "interp"

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Proposal for PerformanceAnalytics::Omega, method = "interp"

Anton Antonov
Hi list,

I've been working on various risk measures recently, Omega being one of
them. In PerformanceAnalytics I saw two implemented methods ("simple"
and "interp"), so I studied both. A quick analysis shows that "interp"
does not work as intended (R 3.3.2, PerformanceAnalytics_1.4.3541):

set.seed(42)
x <- rnorm(1000) / 5
Omega(x)
#[1] 0.9370033
Omega(x, method = "interp")
#[1] 2.877499

It is quite simple to see that under normality assumption Omega at L = 0
converges to 1, so the "interp" estimate is looking strange. Here's the
relevant piece of code (truncated for clarity):

xcdf = Hmisc::Ecdf.default(x, pl=FALSE)
f <- approxfun(xcdf$x,xcdf$y,method="linear",ties="ordered")
omegafull = cumsum(1-f(xcdf$x))/cumsum(f(xcdf$x)) # ????????
g <- approxfun(xcdf$x,omegafull,method="linear",ties="ordered")
omega = g(L)

Here the ratio of cumulative sums is not a correct approximation for the
ratio of two integrals from the Omega definition (which is probably
pointed out by the comment with question marks). I originally wanted to
propose the replacement with left rectangle rule for approximation:

xcdf <- Hmisc::Ecdf.default(x, pl=FALSE)
xs <- xcdf$x[-1]
ys <- xcdf$y[-1]
den <- c(0, cumsum(ys[-length(ys)] * diff(xs)))
num <- rev(c(0, cumsum((1 - rev(ys[-length(ys)])) * (rev(diff(xs))))))
g1 <- approxfun(xs, num, method="linear", ties="ordered")
g2 <- approxfun(xs, den, method="linear", ties="ordered")
if (output == "point") {
   omega = g1(L)/g2(L)
} else {
   omega = matrix(num/den)
   names(omega) = xs
}

but it is seemingly exactly the same as "simple" (given the ecdf is
stepwise). So maybe there's no need for such approximation altogether?
Anyway, the proposed patch allows to fix the call Omega(x, method =
"interp", output = "full"), which returns the whole distribution of Omega.
Relevant previous threads:
https://stat.ethz.ch/pipermail/r-sig-finance/2011q3/008524.html
https://stat.ethz.ch/pipermail/r-sig-finance/2008q3/002969.html

Best regards,
Anton

_______________________________________________
[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.
Loading...