In this image you can see several distributions and a histogram
What I am trying to do is create a log plot (on the y axes) of this one where both the distributions and the histogram follows the log scale. I tried different method to make a log graph of this one, but none of them worked.
Can anyone help?
This is the code that i used
library(ggplot2)
library(VarianceGamma)
library(ghyp)
#csv imported
AAPL <- read.csv("AAPL1.csv")
MySeq <- seq(-0.2, 0.2, length.out = 100000)
#fitting the different tistributions to the data
vg1<-fit.VGuv(AAPL$Lret)
fitDF_vg <- data.frame(x = MySeq,
y = dghyp(MySeq, vg1))
vg2 <- vgFit(AAPL$Lret)
fitDF_vg1 <- data.frame(x = MySeq,
y = dvg(MySeq, param = vg2$param))
nig<-fit.NIGuv(AAPL$Lret)
fitDF_nig <- data.frame(x = MySeq,
y = dghyp(MySeq, nig))
ghyp<-fit.ghypuv(AAPL$Lret)
fitDF_ghyp <- data.frame(x = MySeq,
y = dghyp(MySeq, ghyp))
hyp<-fit.hypuv(AAPL$Lret)
fitDF_hyp <- data.frame(x = MySeq,
y = dghyp(MySeq, hyp))
td<-fit.tuv(AAPL$Lret)
fitDF_td <- data.frame(x = MySeq,
y = dghyp(MySeq, td))
#legend
legenda <- c("vg1"="red", "vg2"="yellow", "NIG"="green", "ghyp"="blue", "Student-t"="brown", "hip"="orange")
#ggplot
ggplot(AAPL, aes(x=Lret)) +
geom_histogram(aes(y= stat(density)), bins = 100, color="white")+
stat_function(fun=dnorm, args = list(mean=mean(AAPL$Lret), sd=sd(AAPL$Lret)), lwd=1, col="darkgray") +
#fitted function plot
geom_line(mapping = aes(x = x, y = y, col="vg1"), data = fitDF_vg, lwd=1) +
geom_line(mapping = aes(x = x, y = y, col="vg2"), data = fitDF_vg1, lwd=1)+
geom_line(mapping = aes(x = x, y = y, col="NIG"), data = fitDF_nig, lwd=1)+
geom_line(mapping = aes(x = x, y = y, col="ghyp"), data = fitDF_ghyp, lwd=1)+
geom_line(mapping = aes(x = x, y = y, col="Student-t"), data = fitDF_td, lwd=1)+
geom_line(mapping = aes(x = x, y = y, col="hip"), data = fitDF_hyp, lwd=1)+
xlim(-0.15,0.15)+
scale_color_manual(values = legenda)+
labs(color = "Legend")+
theme(plot.title = element_text(size = 15))