Is there an R package that I can use to fit a model being a blend of the ARMA model and the ordinary linear regression? I mean something like this: $$Y_t=\beta_0+\beta_1 X_1+\beta_2 X_2+\beta_3Y_{t-1}+\beta_4 Y_{t-2}+\beta_5 \varepsilon_t+\beta_6 \varepsilon_{t-1} $$ How can we fit such a model?
1 Answer
This is known as an ARMAX model. Note that this is different from what forecast::auto.arima()
with external regressors provided in the xreg
parameter fits, which is a regression with ARIMA errors. If you search for "ARMAX R", you need to be careful about the distinction between the two kinds of models, because this is very frequently confused. More information on the difference can be found in Rob Hyndman's blog post on "The ARIMAX model muddle".
He says at the very bottom that TSA::arimax()
fits a general transfer function model, which includes ARMAX models. This may be helpful. Unfortunately, the TSA package has been removed from CRAN. You could try your luck with an archived version.