# Fitting an ARFIMA Model with Covariates in R

In R's arima() function, one can specify a list of covariates while estimating the AR and MA coefficients using the xreg argument. For instance:

arima(lh, c(2,0,1), xreg= 1:length(lh))


returns a model with ARMA(2,0) disturbance and the linear effect of time series 1:length(lh):

Call:
arima(x = lh, order = c(2, 0, 1), xreg = 1:length(lh))

Coefficients:
ar1      ar2      ma1  intercept  1:length(lh)
1.3957  -0.6453  -1.0000     2.1072        0.0105
s.e.  0.1065   0.1082   0.0589     0.0585        0.0023

sigma^2 estimated as 0.1411:  log likelihood = -22.85,  aic = 57.7


Is there any equivalent method in R when fitting an ARFIMA (Autoregressive fractionally integrated moving average) model? I know it is possible to run a multiple regression on the residuals of an ARFIMA model, but this is different from estimating them together and would like to learn if anyone has a better suggestion.

• There's a good chance that the answer is no, but have you tried out package fArma? – Digio Jul 27 '17 at 12:14
• Try the "rugarch" package in R, I think it has the functionality for fitting ARFIMA models with exogenous regressors. However, I am not sure whether it is ARFIMAX or regression with ARFIMA errors (this should become clear from the documentation and the vignette). In the latter case, it should be more efficient than fitting the regression and the ARFIMA part in two stages. – Richard Hardy Jul 27 '17 at 12:30
• Most of R's time series libraries are wrappers of arima() so I would assume that the xreg option is always regression with ARMA errors. – Digio Jul 27 '17 at 12:34
• @Digio, from what I know about the package, I suspect this is not the case with "rugarch", but one should check to be sure. – Richard Hardy Jul 29 '17 at 10:23

Note that feeding the xreg parameter in arima() or auto.arima() does not fit an ARIMAX model, but a regression on xreg with ARIMA errors. See Rob Hyndman's "The ARIMAX model muddle" blog post.
This of course suggests how one could do a similar thing with ARFIMA: regress your observations on your covariates using lm() or similar, then fit an ARFIMA model to the residuals, e.g., using the arfima package. Alternatively, simply use the arfima() function in the package and use the xreg parameter.