Does anyone have any hints on utilizing VaR.gpd on return series instead
of price series?
I have tried converting a return series to a wealth index (using
cumprod), but this still seems to cause problems with the VaR package.
for example:
library(PerformanceAnalytics)
data(edhec)
wi<-cumprod.column(1+edhec)
library(VaR)
vt<-VaR.gpd(wi[,1])
Error in optim(init, gpd.liklhd, hessian = TRUE, method = "Nelder-Mead") :
non-finite finite-difference value [2]
In addition: There were 50 or more warnings (use warnings() to see the
first 50)
A message to the maintainer of the package has without response.
If I don't get any usable feedback, I'll probably move to using fit.GPD
from QRMlib (which I have had some luck with in the past) to add a
general Pareto method to the VaR functions in PerformanceAnalytics, as I
feel that parametric VaR functions on a broader set of distributions and
copulae should be more widely available.
Regards,
- Brian
pointers on using VaR.gpd with return series?
4 messages · Sylvain BARTHELEMY, Krishna Kumar, Brian G. Peterson
I think that there is a problem with the VaR.gpd function, as it works on
USD/EUR and not on EUR/USD values
library(PerformanceAnalytics)
eurusd <- get.hist.quote("EUR/USD", provider="oanda", start = "2006-01-01")
usdeur <- get.hist.quote("USD/EUR", provider="oanda", start = "2006-01-01")
library(VaR)
v1 <- VaR.gpd(as.vector(eurusd))
v2 <- VaR.gpd(as.vector(usdeur))
output:
v1 <- VaR.gpd(as.vector(eurusd))
Error in optim(init, gpd.liklhd, hessian = TRUE, method = "Nelder-Mead") :
non-finite finite-difference value [2]
In addition: There were 50 or more warnings (use warnings() to see the
first 50)
v2 <- VaR.gpd(as.vector(usdeur))
There were 11 warnings (use warnings() to see)
---
Sylvain Barth?l?my
Research Director, TAC
www.tac-financial.com | www.sylbarth.com
-----Message d'origine-----
De?: r-sig-finance-bounces at stat.math.ethz.ch
[mailto:r-sig-finance-bounces at stat.math.ethz.ch] De la part de Brian G.
Peterson
Envoy??: mardi 21 ao?t 2007 14:38
??: R-SIG-Finance
Objet?: [R-SIG-Finance] pointers on using VaR.gpd with return series?
Does anyone have any hints on utilizing VaR.gpd on return series instead
of price series?
I have tried converting a return series to a wealth index (using
cumprod), but this still seems to cause problems with the VaR package.
for example:
library(PerformanceAnalytics)
data(edhec)
wi<-cumprod.column(1+edhec)
library(VaR)
vt<-VaR.gpd(wi[,1])
Error in optim(init, gpd.liklhd, hessian = TRUE, method = "Nelder-Mead") :
non-finite finite-difference value [2]
In addition: There were 50 or more warnings (use warnings() to see the
first 50)
A message to the maintainer of the package has without response.
If I don't get any usable feedback, I'll probably move to using fit.GPD
from QRMlib (which I have had some luck with in the past) to add a
general Pareto method to the VaR functions in PerformanceAnalytics, as I
feel that parametric VaR functions on a broader set of distributions and
copulae should be more widely available.
Regards,
- Brian
_______________________________________________
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.
Sylvain BARTHELEMY wrote:
I think that there is a problem with the VaR.gpd function, as it works on
USD/EUR and not on EUR/USD values
library(PerformanceAnalytics)
eurusd <- get.hist.quote("EUR/USD", provider="oanda", start = "2006-01-01")
usdeur <- get.hist.quote("USD/EUR", provider="oanda", start = "2006-01-01")
library(VaR)
v1 <- VaR.gpd(as.vector(eurusd))
v2 <- VaR.gpd(as.vector(usdeur))
output:
v1 <- VaR.gpd(as.vector(eurusd))
Error in optim(init, gpd.liklhd, hessian = TRUE, method = "Nelder-Mead") :
non-finite finite-difference value [2]
In addition: There were 50 or more warnings (use warnings() to see the
first 50)
Ouch the default parameters there are two possible fixes setting the cut-off threshold using p.tr helps. (a) doing the following call on your data comes back with some results.. > v1 <- VaR.gpd(as.vector(eurusd),p.tr=0.95) (b) The other alternate is to rewrite VaR.gpd and set hessian=FALSE where it makes the call to maximize the log-likelihood. optim(init, gpd.liklhd, *hessian = TRUE*, method = "Nelder-Mead") : Neither of these are "the solution" as this is more an Art than a science. Method (a) relates to the question of how to pick the threshold. Very few and you have biased fit and too many you are no longer fitting the tail. In this context I would point you towards the evir library and the excellent book by Alex Mcneill on this but doing the following should give you some hints.. >require(evir) >shape(danish) Hope this helps, Best Krishna
Krishna Kumar wrote:
Sylvain BARTHELEMY wrote:
I think that there is a problem with the VaR.gpd function, as it works on
USD/EUR and not on EUR/USD values
library(PerformanceAnalytics)
eurusd <- get.hist.quote("EUR/USD", provider="oanda", start = "2006-01-01")
usdeur <- get.hist.quote("USD/EUR", provider="oanda", start = "2006-01-01")
library(VaR)
v1 <- VaR.gpd(as.vector(eurusd))
v2 <- VaR.gpd(as.vector(usdeur))
output:
v1 <- VaR.gpd(as.vector(eurusd))
Error in optim(init, gpd.liklhd, hessian = TRUE, method = "Nelder-Mead") :
non-finite finite-difference value [2]
In addition: There were 50 or more warnings (use warnings() to see the
first 50)
Ouch the default parameters there are two possible fixes setting the cut-off threshold using p.tr helps. (a) doing the following call on your data comes back with some results..
> v1 <- VaR.gpd(as.vector(eurusd),p.tr=0.95)
(b) The other alternate is to rewrite VaR.gpd and set hessian=FALSE where it makes the call to maximize the log-likelihood. optim(init, gpd.liklhd, *hessian = TRUE*, method = "Nelder-Mead") : Neither of these are "the solution" as this is more an Art than a science. Method (a) relates to the question of how to pick the threshold. Very few and you have biased fit and too many you are no longer fitting the tail. In this context I would point you towards the evir library and the excellent book by Alex Mcneill on this but doing the following should give you some hints..
>require(evir) >shape(danish)
Kris and Sylvain, Thanks for the pointers. I would have assumed that a VaR function would set some reasonable defaults for threshold and p value, but I guess not. Basically, I *know* that a GPD distribution is fitable in a reasonable fashion to this data, as I've done it. I was hoping to cut down on my implementation difficulties by using functions already written. I'll try fitting with evir and QRMlib. (the QRMlib package is the R port for functions from McNiel's book, which is well worth owning) Stay tuned... as always, we'll share our results. Regards, - Brian