I'm reading the Dynamic Regression Models chapter ( https://www.otexts.org/fpp/9/1 ) in Professor Hyndman's book, and I couldn't understand how to fit the regression model when the error is modeled with an ARIMA process:
$$ \begin{align*} y_t &= \beta_0 + \beta_1 x_{1,t} + \dots + \beta_k x_{k,t} + n_t,\\ & (1-\phi_1B)(1-B)n_t = (1+\theta_1B)e_t, \end{align*} $$
The procedure that is described in the chapter is the following:
- Check that the forecast variable and all predictors are stationary. If not, apply differencing until all variables are stationary. Where appropriate, use the same differencing for all variables to preserve interpretability.
- Fit the regression model with AR(2) errors for non-seasonal data or ARIMA(2,0,0)(1,0,0)m errors for seasonal data.
- Calculate the errors ($n_{t}$) from the fitted regression model and identify an appropriate ARMA model for them.
- Re-fit the entire model using the new ARMA model for the errors.
- Check that the $e_{t}$ series looks like white noise.
I completely understand that applying the least square approach directly is not appropriate as this will produce biased parameters estimates, however the fitting process is not clear at all for me (particularly step 2 of the procedure above). I honestly would like to understand it and not to rely blindly in an automatic R code.
Thanks for any help!