I would like to draw a line overlaying the normal curve to below histogram
however it doesn´t work. I don´t understand where is the problem. thanks in advance!
{r Load libraries}
library(fpp3)
{r tidy data}
A_Beer_production <- aus_production %>% select(Quarter:Beer)
{r set training period}
B_Set_training_period <- A_Beer_production %>%
filter_index("1992 Q1" ~ "2007 Q4")
{r Residuals Seasonal Naive method}
Residuals_SNAIVE <- B_Set_training_period %>% model(SNAIVE(Beer)) %>% augment()
{r ggplot}
ggplot(Residuals_SNAIVE, aes(x=.resid)) +
geom_histogram(aes(y = ..density..), fill='lightgray', col='black') +
stat_function(fun = dnorm, args = list(mean=mean(Residuals_SNAIVE$.resid), sd=sd(Residuals_SNAIVE$.resid)))
thanks in advance