# ARMAX model and validation

I am new to time series and am trying to fit some time series data.

I understand the general concept of ARIMA model. However, as I read more textbooks and articles from Rob Hyndman, I realized I could put some regressors using the xreg argument for the functions auto.arima or arima in R to get an ARMAX model. Therefore, I wonder if it is still necessary to include seasonality in ts(...,frequency) as everything can be specified as dummy variable within the xreg matrix and a more complicated seasonality structure (e.g. monthly seasonality) can be specified.

In addition, what would be a good way to check the accuracy of the forecast? I am fitting multiple time series data with a hierarchical structure. Using auto.arima, I am able to select the best model and validate the model by looking at the residuals (check whether they are white noise). However, is there a way to even improve on the model if the prediction is still far from the actual data?

To sum up,

1. Is the frequency argument in ts function really necessary? Can I just specify everything in the xreg matrix?
2. What would be a normal routine to improve on model after selecting the appropriate ARIMA model with the lowest AIC?

I am now able to fit an ARIMA model with SARIMA error by specifying xreg argument and seasonal=F. One issue that I have with that is, my xreg matrix is not invertible (I assumed) and its not due to the presence of intercept term. Thus auto.arima() only fit a c(0,0,0) model.

I then tried using Arima() to manually select model and it outputted the following error

Error in optim(init[mask], armafn, method = optim.method, hessian = TRUE,  :
non-finite value supplied by optim


I check the xreg matrix and it turns out column 48 (Day) and column 52 (2015) is causing the issue. Could you check if there's something wrong with my matrix structure ?

• How do you know which columns are causing the issue? Also, why do you have dummies for 2014 and 2015? Do you think the two years should have different intercepts and there is an abrupt change in the level from 2014-12-31 to 2015-01-01? Also, your statement "I am now able to fit an ARIMA model with SARIMA error by specifying xreg argument and seasonal=F" does not make sense to me. First, it is not ARIMA model but regression; second, you cannot have SARIMA error if seasonal=F, can you? Also, do you think having day-of-month dummies makes sense? (That depends on the nature of your data.) Dec 17, 2015 at 19:45
• Yes, day of the month makes sense with my data. I guess I am confused about SARIMA error, I used xreg only to include all my seasonality and thus produce a better fit. I am worried about a potential trend for the data from 2014 to 2015 so I include year as a dummy too. Back to the outputted error, originally it gave me another error regarding my matrix (I forgot what it is, something related to the matrix and a huge number 2exxxxx) then when I deleted those two columns, the code worked. Now its just producing the error above. Dec 17, 2015 at 20:28
• My training data is from 2013 to 2015, so it makes senses to include year as a dummy to account for year change right? Dec 17, 2015 at 20:32
• Including year dummies implies abrupt changes in level from year to year. It could make sense if there is a regime change every January 1st, but that is not that common in applications. Dec 17, 2015 at 20:36
• But my matrix looks fine, I wondered why Arima() failed to run. Dec 17, 2015 at 20:57

Specifying the frequency argument allows estimating seasonal ARIMA (SARIMA) models, for example. If you specify your time series to be seasonal (by setting frequency argument to be greater than 1), the function auto.arima will consider SARIMA models for your data, while if you specify frequency=1 (non-seasonal), only ARIMA models will be considered. SARIMA model is not the same as a regression with ARMA errors where the regressors are seasonal variables (dummies or Fourier terms); you get the latter if you use arima with the seasonal variables supplied as xreg.
Also, frequency is used for setting the scale of the horizontal axis in the plots. For example, if your frequency is 4 (for quarterly data), you will get the horizontal axis in years and there will be four data point in one year; this is quite convenient.
Also, it should be possible to combine SARIMA with exogenous regressors by having frequency greater than 1 and some regressors passed with xreg; if I understand correctly, that would result in a regression with SARIMA errors.
• Thanks for the reply. As I have multiple seasonality, it might be better to run a ARMA model with seasonal variables than running a SARMA model with seasonal variables. Can you check if my xreg matrix looks right to you? The column "Day" and "2015" are giving me errors. Dec 17, 2015 at 19:07