# Obtain the ARFIMA residuals residuals <- data.frame(date = data$date[1:1000], residuals = arfima_best_fit$fit@fit['residuals']$residuals) # Plot the arfima(1,d,1) residuals ggplot(data=residuals, aes(x = date)) + # Choose the residuals as the y-axis variable geom_line(aes(y = residuals, color="Residuals")) + # Set the title, x and y labels ggtitle("Best ARFIMA model Residuals") + xlab("Date") + ylab("Residuals") + theme(plot.title = element_text(hjust = 0.5, size=30), legend.position="bottom", legend.text = element_text(size=20)) + scale_x_date(date_labels = "%b %y") + theme( axis.title.x = element_text(size = 20), axis.text.x = element_text(size = 20), axis.title.y = element_text(size = 20), axis.text.y = element_text(size = 20),) ggsave("best-arfima-residuals.png")