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.