2
$\begingroup$

I am comparing different exogenous variables in how good they support the forecast of the monthly seasonal adjusted unemployment rate. All my data is monthly (2006-01-01 until 2018-09-01) and Integrated of order zero. I have devided my data sample in a train (2006-01.01 until 2017-09-01) and testing sample (2017-10-01 until 2018-09-01)

I estimated based on AIC a stable ARIMAX(2,0,3) model with the inflation rate as an exogenous variable (see below) I now would like to use this model to forecast the unemployment rate with in the training sample. Because I do have the data, I would like the model a rolling window.

I am familiar with forecasting rolling windows without exogenous variables and forecasting n.step-ahead with exogenous variables. Additionally I have used the predict_rolling() function for VAR models. However I am not sure how to forecast a rolling window with an ARIMAX while supplying the exogenous values as well.

In my example below I have used the forecast function of the forecast package to estimate a forecast providing the actual values of the exogenous variable only.

What I do not understand is how I can incorporate not only the new xreg values but also the actual unemployment rates for the last year to estimate a rolling window. Below you can find a working example of my situation. Thank you so much in advance!!

library(forecast)

unemp <-  c(10.6, 10.5, 10.4, 10.3, 10.2, 10.1, 10.0,  9.9,  9.8,  9.7,  9.6,  9.4,  9.2,  9.0,  8.9,  8.7,  8.6,  8.6,  8.5,  8.4, 8.4, 8.3, 8.2, 8.1, 7.9, 7.8, 7.7, 7.6 , 7.5, 7.4, 7.3, 7.1, 7.0, 7.0, 7.1, 7.2, 7.3, 7.5, 7.6, 7.7, 7.8, 7.8, 7.9, 7.8, 7.8, 7.7, 7.6, 7.5, 7.4, 7.3, 7.3, 7.2, 7.0, 6.9, 6.8, 6.8, 6.7, 6.7, 6.6, 6.5, 6.4, 6.2, 6.1, 6.0, 5.9, 5.8, 5.8, 5.7, 5.7, 5.6, 5.6, 5.5, 5.5, 5.4, 5.4, 5.4, 5.4, 5.4, 5.4, 5.3, 5.3, 5.3, 5.3, 5.3, 5.4, 5.4, 5.4, 5.3, 5.3, 5.2, 5.2, 5.2, 5.2, 5.1, 5.1, 5.1, 5.1, 5.1, 5.1, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 4.9, 4.9, 4.8, 4.8, 4.7, 4.7, 4.7, 4.7, 4.6, 4.6, 4.5, 4.5, 4.5, 4.4, 4.4, 4.3, 4.3, 4.3, 4.2, 4.2, 4.2, 4.1, 4.0, 4.0, 3.9, 3.9, 3.9, 3.9, 3.9, 3.8, 3.8, 3.8, 3.7, 3.7, 3.7)
inflation <- c(86.6, 86.9, 87.0, 87.3, 87.5, 87.6, 88.0, 87.9, 87.5, 87.6, 87.5, 88.3, 88.1, 88.5, 88.7, 89.1, 89.2, 89.3, 89.8, 89.6, 89.8, 89.9, 90.4, 91.0, 90.7, 91.2, 91.6, 91.4, 92.0, 92.3, 92.9, 92.5, 92.5, 92.2, 91.7, 92.0, 91.6, 92.1, 91.9, 92.0, 91.9, 92.3, 92.2, 92.5, 92.1, 92.1, 92.0, 92.9, 92.2, 92.6, 93.1, 92.9, 93.1, 93.1, 93.3, 93.4, 93.3, 93.4, 93.4, 94.5, 94.0, 94.6, 95.2, 95.4, 95.3, 95.4, 95.8, 95.8, 95.9, 96.0, 96.0, 96.7, 96.2, 97.0, 97.4, 97.6, 97.3, 97.2, 97.6, 97.9, 97.9, 97.9, 97.8, 98.6, 98.0, 98.7, 99.2, 98.6, 98.9, 99.0, 99.5, 99.4, 99.4, 99.1, 99.4, 99.9, 99.1, 99.7, 100.0, 99.8, 99.6, 99.9, 100.2, 100.2, 100.2, 99.9, 99.9, 99.9, 98.7, 99.7, 100.2, 100.1, 100.2, 100.1, 100.3, 100.3, 100.1, 100.1, 100.1, 100.1, 99.1, 99.5, 100.3, 99.8, 100.2, 100.3, 100.7, 100.6, 100.6, 100.8, 100.8, 101.8, 101.0, 101.7, 101.8, 101.8, 101.6, 101.8, 102.2, 102.4, 102.4)
train_unemp <-c(3.6, 3.6, 3.6, 3.5, 3.5, 3.5, 3.5, 3.4, 3.4, 3.4, 3.4, 3.4)
train_inf <-c(102.3, 102.6, 103.4, 102.4, 102.9, 103.3, 103.2, 103.8, 103.9, 104.3, 104.3, 104.7)

basemodel<-Arima(unemp, order=c(2,0,3), xreg=inflation)
basemodel
predict_basemodel <- forecast::forecast(basemodel, xreg=train_inf)

Disclaimer: I know that MA3 and the exogenous variable show insignificant coefficients, but without the MA3 term I observe autocorrelation in my residuals. Therefore I’ve decided to keep it.

$\endgroup$
0
$\begingroup$

takes forever and retains a complicated nested list but works

unemp <-  ts(c(10.6, 10.5, 10.4, 10.3, 10.2, 10.1, 10.0,  9.9,  9.8,  9.7,  9.6,  9.4,  
               9.2,  9.0,  8.9, 8.7,  8.6,  8.6,  8.5,  8.4, 8.4, 8.3, 8.2, 8.1, 
               7.9, 7.8, 7.7, 7.6 , 7.5, 7.4, 7.3, 7.1, 7.0, 7.0, 7.1, 7.2, 
               7.3, 7.5, 7.6, 7.7, 7.8, 7.8, 7.9, 7.8, 7.8, 7.7, 7.6, 7.5,
               7.4, 7.3, 7.3, 7.2, 7.0, 6.9, 6.8, 6.8, 6.7, 6.7, 6.6, 6.5, 
               6.4, 6.2, 6.1, 6.0, 5.9, 5.8, 5.8, 5.7, 5.7, 5.6, 5.6, 5.5, 
               5.5, 5.4, 5.4, 5.4, 5.4, 5.4, 5.4, 5.3, 5.3, 5.3, 5.3, 5.3, 
               5.4, 5.4, 5.4, 5.3, 5.3, 5.2, 5.2, 5.2, 5.2, 5.1, 5.1, 5.1, 
               5.1, 5.1, 5.1, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 4.9, 4.9, 
               4.8, 4.8, 4.7, 4.7, 4.7, 4.7, 4.6, 4.6, 4.5, 4.5, 4.5, 4.4, 
               4.4, 4.3, 4.3, 4.3, 4.2, 4.2, 4.2, 4.1, 4.0, 4.0, 3.9, 3.9, 
               3.9, 3.9, 3.9, 3.8, 3.8, 3.8, 3.7, 3.7, 3.7, 3.6, 3.6, 3.6, 
               3.5, 3.5, 3.5, 3.5, 3.4, 3.4, 3.4, 3.4, 3.4), start=2006, frequency = 12)

inflation <- ts(c(86.6, 86.9, 87.0, 87.3, 87.5, 87.6, 88.0, 87.9, 87.5, 87.6, 87.5, 88.3, 
                  88.1, 88.5, 88.7, 89.1, 89.2, 89.3, 89.8, 89.6, 89.8, 89.9, 90.4, 91.0, 
                  90.7, 91.2, 91.6, 91.4, 92.0, 92.3, 92.9, 92.5, 92.5, 92.2, 91.7, 92.0, 
                  91.6, 92.1, 91.9, 92.0, 91.9, 92.3, 92.2, 92.5, 92.1,92.1, 92.0, 92.9, 
                  92.2, 92.6, 93.1, 92.9, 93.1, 93.1, 93.3, 93.4, 93.3, 93.4, 93.4, 94.5, 
                  94.0, 94.6, 95.2, 95.4, 95.3, 95.4, 95.8, 95.8, 95.9, 96.0, 96.0, 96.7, 
                  96.2, 97.0, 97.4, 97.6, 97.3, 97.2, 97.6, 97.9, 97.9, 97.9, 97.8, 98.6, 
                  98.0, 98.7, 99.2, 98.6, 98.9, 99.0, 99.5, 99.4, 99.4, 99.1, 99.4, 99.9, 
                  99.1, 99.7, 100.0, 99.8, 99.6, 99.9, 100.2, 100.2, 100.2, 99.9, 99.9, 99.9, 
                  98.7, 99.7, 100.2, 100.1, 100.2, 100.1, 100.3, 100.3, 100.1, 100.1, 100.1, 100.1, 
                  99.1, 99.5, 100.3, 99.8, 100.2, 100.3, 100.7, 100.6, 100.6, 100.8, 100.8, 101.8, 
                  101.0, 101.7, 101.8, 101.8, 101.6, 101.8, 102.2, 102.4, 102.4, 102.3, 102.6, 103.4, 
                  102.4, 102.9, 103.3, 103.2, 103.8, 103.9, 104.3, 104.3, 104.7), start=2006, frequency = 12)

fcasts <- vector(mode = "list", length=20L)
for (i in 1:20) {
  win.y <- window(unemp, end = 2017+i/12)
  win.x<-window(inflation, end=2017+i/12)
  win.z<-window(inflation, end=2017+(1+i)/12)
  fit <- auto.arima(win.y, xreg=win.x)
  fcasts[[i]] <- forecast(fit, h = 1, xreg = win.z)
}
$\endgroup$
0
$\begingroup$

Why would you want to use the actual future values for Inflation as they are unknown at any origin as using actuals for the future for the causal smacks of "statistical cheating". I would alternatively actually predict the future (truly unknown at the point of forecast) monthly inflation and encode the uncertainty in those predictions into the uncertainty in your unemployment forecasts. In this way you get 2 estimates for forecast error.

As an aside were you interested in 12 1 period out forecast accuracy or 1 12 period out forecast accuracy ?

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.