I want to change y-axis and change (remove completely) the title of this plot using ggplot2 package.
## simulate ARIMA(1,0, 0)
set.seed(1)
ar1 <- arima.sim(n = 20, model = list(ar = 0.8, order = c(1, 0, 0)), sd = 1)
## do the plot
forecast::checkresiduals(forecast::auto.arima(ar1), main = "")
I want to remove the title, Residual from ARIMA(2,0,0) with zero mean and also replace df$y with let’s say value.
>Solution :
The function checkresiduals just runs ggtsdisplay on the residuals of your model. This plots a series of three ggplots in 3 separate grid viewports and returns the final plot as an object, so you can get the output you want with
set.seed(1)
ar1 <- arima.sim(n = 20, model = list(ar = 0.8, order = c(1, 0, 0)), sd = 1)
library(ggplot2)
library(forecast)
#> Registered S3 method overwritten by 'quantmod':
#> method from
#> as.zoo.data.frame zoo
p <- ggtsdisplay(residuals(auto.arima(ar1)), plot.type = "histogram")
p <- p + labs(y = "value", x = "residuals")
print(p, vp = grid::viewport(layout.pos.row = 2, layout.pos.col = 2))

Created on 2023-02-12 with reprex v2.0.2
