Solved – How to compare ARIMA model in R to actual observations used to create the model

arimaforecastingrregression

I've been using the R forecast package's auto.arima() function to fit an ARIMA model to my time series data. I want to see how good of a fit the ARIMA model is to my original data. I hope to plot my original time series and the ARIMA simulation on the same plot and see how well they match up. How can I do this?

Thanks!

Best Answer

That is easy: I show you with an example

library(forecast)
y=arima.sim(list(ar=.9),n=100)
arm=auto.arima(x=y)
matplot(cbind(y,fitted(arm)),type='l')

Or if you want them on the same plot:

plot(y)
lines(fitted(arm), col='red')