ARIMA Model with Residuals of Regression Model

Hello there,

I have a question regarding your loop for Multi-step forecasts, re-estimation with Arima and Regressions. I am looking for four different loops:

  • Multi-step forecasts, without re-estimation,
  • Multi-step forecasts, re-estimation (Regression & Arima)
  • Multi-step forecasts, re-estimation (Regression), refit Arima model
  • Multi-step forecasts, re-estimation, refit Regression & Arima model

I am currently working with the following:

xreg <- as.matrix(outlier.data[,c("LS53","AO156")])
h <- 1
n <- length(test) - h +1
arima_reg_outlier_mat <- matrix(0, nrow=n, ncol=h)
for(i in 1:n)
{  
  x <- window(ts, end=c(2018, 52) + (i-1)/52)
  refit <- Arima(x, model=arima_reg_outlier, xreg=xreg)
  arima_reg_outlier_mat[i,] <- fabletools::forecast(refit, h=h)$mean
}

For refit the Arima Model I use

h <- 1
n <- length(test) - h +1
arima_reg_outlier_mat <- matrix(0, nrow=n, ncol=h)
for(i in 1:n)
{  
  x <- window(ts, end=c(2018, 52) + (i-1)/52)
  refit <- auto.arima(x, xreg=xreg)
  arima_reg_outlier_mat[i,] <- fabletools::forecast(refit, h=h)$mean
}

But I receive the following error for that one:

The chosen seasonal unit root test encountered an error when testing for the second difference.
From stl(): series is not periodic or has less than two periods
1 seasonal differences will be used. Consider using a different unit root test. 

But I don't know how to write the other two loops.
I would be very thankful if you could help me out with this.
Thank you very much and have a nice weekend.

Kind regards,
Lukas

Hi Lukas,

Without your outlier.data object I cannot reproduce this issue.

You might be having an issue because you are using the same xreg with different lengths of x?

As an aside, you should also be able to use forecast::forecast() to remove the dependency on fabletools in your script. fabletools::forecast() should only be necessary if you're using models from the fable package (or other tidy time series modelling packages).

Best,
Mitch.

1 Like