Hi all I am trying to forecast with an ARIMA model with outliers.
At first
x<-ts(data$value, start=c(2009,1), end=c(2015,12), freq=12) # keep 7 months to evaluate foecast
SAR011011<-arima(serie,order=c(0,1,1),seasonal=list(order=c(0,1,1),period=12));
SAR011011 #fit.an.ARIMA.model.with.no.outlier;
Coefficients:
ma1 sma1
-0.3372 -0.7815
s.e. 0.1166 0.2433
sigma^2 estimated as 198465069: log likelihood = -784.53, aic = 1573.06
Then I check for some outliers with the TSA package
detectIO(SAR011011)
ind 19.000000 30.000000 31.000000
lambda1 5.146045 -4.250828 4.136944
So, then I added 3 outliers at theobs 19, 30 and 31
Coefficients:
ma1 sma1 IO-19 IO-30 IO-31
-0.1550 -0.4761 23262.107 -41275.194 20083.911
s.e. 0.1274 0.1283 8954.079 8778.279 9112.721
All of them are sigficant and really improve AIC.
So, when I tried to forecast.. most common procedures did not work.
predict(SAR011011out, n.ahead = 7, se.fit = TRUE) -->data' must be of a vector type, was 'NULL'
forecast(SAR011011out, h=3)--> 'data' must be of a vector type, was 'NULL'
I have read here that TSA does not have a predict function. But I just do not believe that is not possible to forecast incorporating outliers.
what does the community use in this cases?
Best Answer
If you have
there should be no difficulty in forecasting. You have all the inputs you need. Use the model formula to obtain a one-step-ahead forecast. If you want to forecast further ahead, use the forecasted value in place of the true value and iterate forward.
If you are asking how to do that in R, that would be off topic. But it is actually quite easy: if you fit your model with
arima
orArima
, the methodpredict
should work. If you want to account for outliers at known time points when fitting witharima
orArima
, you can use a set of dummy variables (supplied via the argumentxreg
) with unit values on these time points. For forecasting, you would supply zero vectors fornewxreg
as presumably you cannot predict the future outliers.