Thanks a lot for the replay and for this package!
I have used a bigger dataset (linked below) to fit the variance gamma, the picture shows the results of the VarianceGamma's vg.Fit in bule and in red the ghyp's fit.VGuv.
https://drive.google.com/file/d/15SzktDmsQ1AfOnC33BU-3l1A1rnjempN/view?usp=sharing
this is the code that i have used to fit and plot the distributions
library(ggplot2)
library(VarianceGamma)
library(ghyp)
SP500 <- read.csv("HistoricalPricesSP500.csv")
MySeq <- seq(-0.05, 0.05, length.out = 100000)
vg<-fit.VGuv(SP500$Lret)
fitDF_vg <- data.frame(x = MySeq,
y = dghyp(MySeq, vg))
#the parameters are inputted manually because i havent found in time a way to imput the result of the vgFit (but they are exactly what the vgFit returns)
vgFit(SP500$Lret)
fitDF_vg1 <- data.frame(x = MySeq,
y = dvg(MySeq, param = c(0.001855, 0.010035, -0.001496, 0.262822)))
#legend name
legenda <- c("fit.VGuv"="red", "vgFit"="blue")
#plot
ggplot(SP500, aes(x=SP500$Lret)) +
geom_histogram(aes(y= stat(density)), bins = 100, color="white")+
#vg plot
geom_line(mapping = aes(x = x, y = y, col="fit.VGuv"), data = fitDF_vg, lwd=1) +
geom_line(mapping = aes(x = x, y = y, col="vgFit"), data = fitDF_vg1, lwd=1)+
xlim(-0.05,0.05)
As you can see the vg fitted with the VarrianceGamma package doesn't look good compared to the one found with the ghyp package. Do you know why? maybe there is an error in my code