1
$\begingroup$

I'm trying to forecast a seasonal time series based on its historical values, and also two more time series (that are seasonal themselves.)

I'm trying to use an auto.arima, and I'm going to input the other two time series (the exogeneous regressors) as a contatenated list of dummy variables, in auto.arima's xreg parameter.

I am having difficulty how to use the forecast function after this point. I've written up the following code, but I don't understand what I should put in the xreg and newxreg parameters of the forecast function.

tempfit<-auto.arima(dnew, xreg=dExt)
plot(forecast(tempfit, xreg=dnew1,newxreg=dExt1))

Also, my data points for these three series were all values per day that had a seven day seasonality. In order to let auto.arima calculate the (p,q,d) for seasonality, I converted them to time series with a frequency of 7. Now, after forecasting is done, the plot shows one unit for every seven days. How can I covert this back to one unit per day?

Further, do you happen to know how we can input a set of external regressors to an ETS model?

I would greatly appreciate your inputs!

Thank you.

EDIT:

I just saw the following page from Dr. Hyndman: Time series modeling with dynamic regressors in SAS vs. in R

Is it safe to assume that I don't need to enter a newxreg parameter for my forecast?

Also, I really want to know if it's statistically correct to use the two external regressors in xreg, but then also use a number of dummy variables in xreg that will represent the seasonality of these two variables.

$\endgroup$
8
$\begingroup$

If you fit an arima model with external regressions, you MUST provide newxreg to the predictions function. This goes for arima, auto.arima, and Arima. You cannot provide external regressors to ets.

xreg should contain the exogenous variables for the training set, and newxreg should contain those variables for the prediction set. If the nexreg contains variables you do not know the future values of, you will either need to forecast these variables or exclude them from the model.

$\endgroup$
  • $\begingroup$ Thank you! I'm aware of newxreg in predict function, but I'm curious to know whether in forecast function this newxreg has been renamed to just xreg (using newxreg I get an error) $\endgroup$ – user2370334 May 15 '13 at 3:05
  • $\begingroup$ @user2370334 Good catch. The argument is xreg. Type ?forecast.Arima for more info. $\endgroup$ – Zach May 15 '13 at 3:12
  • 1
    $\begingroup$ It can be helpful to define newxreg, just to differentiate between training (xreg) and testing (newxreg). Then when using the forecast function, set xreg=newxreg. $\endgroup$ – SCallan Sep 29 '17 at 14:10

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.