I saw this: time series - Poor prediction using ARIMA model But the answers aren't clear and isn't directing to me for solving the problem I have. Using only AR is giving me better prediction whereas Auto arima told me to use ARIMA.
acf(diff(sunspots)) #check if there's any seasonal pattern
pacf(diff(sunspots))
ACF plot suggesting to use MA(2) as ACF is cutting off and PACF is decreasing slowly.
auto.arima(sunspots, start.p=0, max.p=3, start.q=0, max.q=3)
Auto arima gave me (2,1,2)X(2,0,1):
fit <- arima(sunspots, c(2, 1, 2), seasonal = list(order = c(2, 0, 1), period = 12))
AIC(fit)
tsdisplay(residuals(fit), main="fit2residual")
pred <- predict(fit, n.ahead = 240)
#ts.plot(sunspots,pred$pred, log = "x", lty = c(1:3))
years20_pred<-pred$pred
years20_se<-pred$se
plot(sunspots,xlim=c(1700,2015),col="grey",lwd=1.5,ylab="sunspots")
lines(years20_pred, col="green",lwd=1.5)
This is evident how wrong the prediction is as it's not matching the previous patterns.
Using only AR is giving better prediction graph see below:
#++++++++++++++ ANOTHER WAY FOr AR=====
y<- ar(sunspots)
years20<-predict(y,n.ahead=240)
years20_pred<-predict(y,n.ahead=240)$pred
years20_se<-predict(y,n.ahead=240)$se
plot(sunspots,xlim=c(1700,2015),col="grey",lwd=1.5,ylab="sunspots")
lines(years20$pred, col="green",lwd=1.5)
I hvae tried lots of combination for ARIMA nothing is working and stuck on this for seven days. Can someone please advise where am I going wrong?
After doing BoxCoxplot as @stephan said I am getting the positive bounds of the prediction intervals very high which shouldn't be considering previous patterns. Also, I replaced the x-axis values with my own to show years using these lines:
forcastvar<- forecast(model_seasonal,h=240)
plot(forcastvar, xaxt='n')
axis(1, at=1:43, labels=seq(1790, 2003,5))
If I force change X-axis values it's not coming correctly according to data points. Is there a way for that?