0
$\begingroup$

I want to do a linear regression over the corporate spread bonds. The way I did it is to run a linear model using lm, then running an auto.arima on residuals of the output of lm and at last use the same coefficients as in the auto.arima and run an Arima model with the spread values. At last, I want to do a forecast. When I run an auto.arima with xreg, I get a different answer from using lm+Arima. I get an "I" term when using auto.arima though my variables are all stationary. I wonder what is the correct way to do this. Here's my code:


forecast.func <- function(NS.spread, ind.v, maturity, training, forc.horizon){
  
  NS.spread <- NS.spread/100
  forc <- list()
  j <- 0
  
  for(i in 1:floor((nrow(NS.spread)-training)/forc.horizon)){
    
    # linear model
    y <- as.vector(NS.spread[(1+j):(training+j) , maturity])
    f <- ind.v[(1+j):(training+j) , maturity]
    a <- cbind(y,f)
    a <- as.data.frame(a)
    b <- lm(y ~ lagmatrix(f, -1), data= a)
    
    
    # auto- arima
    c <- auto.arima(b$residuals, test= "adf")
    
    # Arima
    d <- Arima(y, xreg = lagmatrix(f, -1), order = c(c$arma[1], c$arma[6], c$arma[2]), include.mean = FALSE)
    
    # forecast
    e <- ind.v[(training+j+1):(training+j+forc.horizon) , maturity]
    h <- forecast(d, xreg = lagmatrix(e, -1))
    
    forc <- c(h, forc)
    
    j <- j + forc.horizon

  }
  
  return(forc)
}
$\endgroup$
0
1
$\begingroup$

Difference between using lm + Arima and auto.arima

In lm + Arima, the lm estimates ignore the ARIMA structure of the error term. This yields a logical inconsistency; the lm step effectively assumes no ARIMA structure, but the next step explicitly models it. Both the point estimates and the confidence intervals from lm can be expected to differ from the case where the error structure is not ignored. This probably also explains the problem with the I term.

In Arima with xreg or auto.arima with xreg, the estimates of xreg take the ARIMA structure of the error term into account. This is the proper way to account for error autocorrelation.

$\endgroup$
13
  • $\begingroup$ Shouldn't gls used instead? $\endgroup$ – usεr11852 Aug 18 '20 at 9:19
  • $\begingroup$ @usεr11852, perhaps it could. It depends on how the covariance matrix would be estimated. I would use maximum likelihood for estimating ARIMA-type models, including regression with ARIMA errors such as here. As long as the likelihood is well specified, it would be my method of choice due to all the nice properties of MLEs. If the likelihood is off, then GLS might be an interesting competitor. I wonder how the results would compare in practice given moderate violations of the distributional asssumption. $\endgroup$ – Richard Hardy Aug 18 '20 at 9:58
  • $\begingroup$ @usεr11852, also, while GLS would yield reasonable point estimates of slope coefficients, a lack of an explicit model of the error structure would prevent making accurate forecasts. This is another argument in favour of regression with ARIMA errors over GLS. $\endgroup$ – Richard Hardy Aug 18 '20 at 11:11
  • $\begingroup$ I was thinking somehting likegls( ..., correlation=corARMA(p,q), method="ML") so we fit a multivariate regression with autocorrelated errors. In that way after doing an auto.arima(residuals(lm(...))) we pass the relevant structure to gls so we go around the lm + Arima inconsistency. (My bad, probably I should have written this out originally and not just "gls would work, no?" comment this.) $\endgroup$ – usεr11852 Aug 18 '20 at 12:28
  • $\begingroup$ @usεr11852, OK, but I suppose this does not solve the problem of predictions that ignore the ARIMA structure aside from adjusting the slope coefficients in a sensible way. Also, I have long been confused by GLS implemented via maximum likelihood (though I have never put much effort into clarifying things for myself). Does that mean the covariance matrix is estimated by ML? If not, I am puzzled. For me, GLS is an estimation technique similar to OLS. When ML gets involved, might we be actually doing more or less the same as ML estimation of regression with ARIMA errors? $\endgroup$ – Richard Hardy Aug 18 '20 at 12:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.