5
$\begingroup$

I want to forecast the sales having 2 independent variables, x1 and x2. I want to choose between different combinations and lags, e.g:

sales ~ x1

sales ~ lag(x1,-1)

sales ~ lag(x1,-1) + lag(x2,-1)

etc ...

I use the function auto.arima(sales, xreg=c(x1,x2)) in R.

My questions are:

i) What is the best way to choose the most appropriate model for forecasting purposes?

ii) I want to forecast sales, lets say, for the whole 2018. Do I have to separately forecast x1 and x2 and use these forecasts as inputs to the regression model? Is this the correct approach?

Does this process of forecasting the predictors and then using the forecasts as inputs to the regression model have a specific name?

$\endgroup$

2 Answers 2

4
$\begingroup$

1. What is the best way to choose the most appropriate model for forecasting purposes?

One approach is to 1.) set up lagged predictors, 2.) fit auto.arima 3.) compare aicc

The below is untested code, but hopefully useful

my_x1 <- cbind(
    Lag0 = df[,"x1"],
    Lag1 = stats::lag(df[,"x1"],-1),
    Lag2 = stats::lag(df[,"x1"],-2),
    Lag3 = stats::lag(df[,"x1"],-3)) %>%
  head(NROW(df))

my_x2 <- cbind(
    Lag0 = df[,"x2"],
    Lag1 = stats::lag(df[,"x2"],-1),
    Lag2 = stats::lag(df[,"x2"],-2),
    Lag3 = stats::lag(df[,"x2"],-3)) %>%
  head(NROW(df))

# Restrict data so models use same fitting period
fit1 <- auto.arima(df[4:40,1], xreg=c(my_x1[4:40,1], my_x2[4:40,1]),
  stationary=TRUE)
fit2 <- auto.arima(df[4:40,1], xreg=c(my_x1[4:40,1:2], my_x2[4:40,1:2]),
  stationary=TRUE)
fit3 <- auto.arima(df[4:40,1], xreg=c(my_x1[4:40,1:3], my_x2[4:40,1:3]),
  stationary=TRUE)
fit4 <- auto.arima(df[4:40,1], xreg=c(my_x1[4:40,1:4], my_x2[4:40,1:4]),
  stationary=TRUE)

c(fit1[["aicc"]],fit2[["aicc"]],fit3[["aicc"]],fit4[["aicc"]])

read more here

2. I want to forecast sales, lets say, for the whole 2018. Do I have to separately forecast x1 and x2 and use these forecasts as inputs to the regression model? Is this the correct approach?

It may be that your best option here is to setup some scenario forecasting. For example, if x1 went up by 5% then the forecast would be sales_y. To forecast your predictors then use those forecasts to forecast sales introduces additional potential for error.

read more here

3. Does this process of forecasting the predictors and then using the forecasts as inputs to the regression model have a specific name?

Unless you are doing "scenario forecasting" as described above, I think that some forecasters would call the processes of building forecasts off of forecasts not recommended, but maybe there are others on this forum who can provide more insight into this approach.

$\endgroup$
2
  • $\begingroup$ I can understand that this process allows for more error, but if lets say, I don't want to do scenario forecasting but get a normal 6 months ahead forecast, then what do I do? $\endgroup$
    – Vasilis
    Jul 3, 2018 at 6:56
  • $\begingroup$ I can't know your exact situation, but a pragmatic approach would be to back test as many senarios you can. Take a collection of univariate time series method, such as arima, exponential smoothing, and seasonal trend loess. Also, try some methods usually dubbed 'inappropriate' such as multiple regression. Test the monthly forecasts of these methods on the last 6 months and compair the MAE. Keep in mind that your multiple regression output may be overly optomisitc because you know your predictors with certainty. $\endgroup$
    – Alex
    Jul 3, 2018 at 9:44
0
$\begingroup$

This is an advanced class response to your question where dynamic regression structure is identified and error diagnostics are incorporated to refine tentative models.

  1. Follow http://www.math.cts.nthu.edu.tw/download.php?filename=569_fe0ff1a2.pdf&dir=publish&title=Ruey+S.+Tsay-Lec1 and https://web.archive.org/web/20160216193539/https://onlinecourses.science.psu.edu/stat510/node/75/ to form a Transfer Function.

  2. Follow http://docplayer.net/12080848-Outliers-level-shifts-and-variance-changes-in-time-series.html to possibly identify anomalies (pulses,level shiifts, seasonal pulses) and possible deterministic error variance change.

  3. Review Transfer function in forecasting models - interpretation and http://svds.com/avoiding-common-mistakes-with-time-series/ to find out why ols methods to identify a tf are to be studiously avoided

  4. study http://www.autobox.com/cms/index.php/afs-university/autobox-examples/modeling-with-autobox/ paaticularly section 4 and the flow diagram

  5. Finally when you predict use monte carlo methods enabling possible future anomalies in order to obtain meaningful prediction intervals.

$\endgroup$
1
  • $\begingroup$ If you are happy with mu answer , please accept it to close the question $\endgroup$
    – IrishStat
    Aug 15, 2019 at 8:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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