Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Changing Axis Names and Title of checkresiduals(} plots with ggplot2 package

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 = "")

Here is the plot

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading