@mara sorry for not clarifying good enough.
I have a time series of daily returns on S&P 500 (sample size 3051). I plotted a histogram of daily returns and plotted a normal distribution using parameters (sigma and mean) of my sample to visualise "goodness of fit". To do that I run the following code:
ggplot(snp.srdf, aes(x=snp.srdf$SNP.Adjusted))+geom_histogram(aes(y= stat(density)), binwidth = 0.008, color="azure4" ) + stat_function(fun=dnorm, args = list(mean=mean(snp.srdf$SNP.Adjusted), sd=sd(snp.srdf$SNP.Adjusted)), lwd=1, col="darkgray")
Which looks like this:
From the plot it is visible that a gaussian distribution is not a proper fit so I use StepAIC.ghyp (snp.srdf$SNP.Adjusted) to find the appropriate distribution. The best fit turns to be a symmetric NIG with certain parameters. I fitted my data into that distribution using fit.NIGuv() and saved the results.
So now I am trying to plot the same histogram from the beginning (histogram of my sample) with a NIG density. I have tried to use the stat_function with dghyp but it doesn't work.
Do you know of any way plotting that distribution using ggplot or is there a function in which I can add the NIG parameters (sigma, mu, lambda, chi) to get a density plot.
Thank you and regards!