Solved – Generating SARIMA data and using it to evaluate the accuracy of the `predict` function, but getting some weird plots

I have written the following code to generate 500 data points from a $SARIMA$ model, use $400$ as training data and then predict the following $100$, while estimating the model with AIC. It appeared to me that I did everything correctly as I could see the AIC correctly choosing the model with certain phi values, etc. etc., however my plot outputs for the estimations is very very dense and incomprehensible and I'm not sure why. I checked the number of data points, the window size, etc. and am not sure what I have done wrong in my implementation.

library(CombMSC) library(forecast)   ##################### #generate data sdat1<- sarima.Sim(n=500, period=12, model = list(order = c(1,0,0), ar=0.5),list(order= c(1,0,0), ar = 0.5)) #procure training data <- window(sdat1, start=1, end=400)  #candidate models op1 <- arima(, order=c(0,0,0), list(order= c(0,1,0))) op2 <- arima(, order=c(1,0,0), list(order= c(1,0,1))) op3 <- arima(, order=c(1,0,0), list(order= c(0,2,0))) op4 <- arima(, order=c(0,1,0), list(order= c(0,0,0))) op5 <- arima(, order=c(1,0,1), list(order= c(0,0,0))) op6 <- arima(, order=c(1,0,0), list(order= c(1,0,0)))  models <- c(op1,op2,op3,op4,op5,op6) models.AIC <- c(op1$aic,op2$aic,op3$aic,op4$aic,op5$aic,op6$aic) = NULL if (min(models.AIC) == op1$aic){ } else if (min(models.AIC) == op2$aic){ } else if (min(models.AIC) == op3$aic){ } else if (min(models.AIC) == op4$aic){ } else if (min(models.AIC) == op5$aic){  } else if (min(models.AIC) == op6$aic){ } models.AIC modpred <- predict(, n.ahead=100) vld.data1<-  sdat1[401:500] plot.ts(sdat1, ylim=c(floor(min(sdat1)),ceiling(max(sdat1)))) plot.ts(sdat1, xlim=c(0,400),ylim=c(floor(min(sdat1)),ceiling(max(sdat1))))  lines(modpred$pred, col='blue') lines(modpred$pred-(1.96*modpred$se), col='red') lines(modpred$pred+(1.96*modpred$se), col='red') 

enter image description here

Seems you are simulating 500 years * 12 observations by years, not 500 observations. You must do:

sarima.Sim(n=500/12, period=12, model=list(order=c(1,0,0),  ar=0.5), list(order=c(1,0,0), ar=0.5)) 

Similar Posts:

Rate this post

Leave a Comment