How to use Dynamic Regression models in R to forecast future sales 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?
 A: 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. 
A: This is an advanced class response to your question where dynamic regression structure is identified and error diagnostics are incorporated to refine tentative models.

*

*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.


*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.


*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


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


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