Search code examples
rplotlinedistribution

R generalized hyperbolic distribution plot line in hist


I have the following code:

x.grid <- seq(-0.05,to=0.05,by=0.001)
hist(df$dataset.d.return.aex, breaks=100, main='daily returns')

Which results in the following plot: [hist1

Now, I want to draw the implied marginal distributions in histograms of the daily returns, where I use a generalized hyperbolic distribution. I tried to do it with the following code:

ghypuv <- fit.ghypuv(data = returns[,"d.return.aex"], symmetric = TRUE)
lines(ghypuv, col="blue")

However, this results in the following plot: hist+line

So, my question is, how to properly draw the implied marginal distributions (using a generalized hyperbolic distribution) in histograms of the daily returns?


Solution

  • Try hist(..., freq=FALSE) to use density rather than number of counts on the y-axis.

    (This is probably a duplicate ...)