R: ACF/PACF plots contradict Breusch-Godfrey test results

acf-pacfautocorrelationdiagnostictime series

I run a linear regression of y on x and test the residuals for serial correlation. The Breusch-Godfrey test has us conclude that we fail to reject the null hypothesis that each of the autocorrelations of order 1-20 is 0. Or put simply, the residuals are not serially correlated.

enter image description here

    library(lmtest)
    library(forecast)    
    set.seed(5)
    par(mfrow=c(1,3))
    
    n=1000
    y<-rep((1:10)/10,n/10)+rnorm(n)
    x<-runif(n)
    
    #Breusch-Godfrey test
    lmtest::bgtest(lm(y~x),order=20,fill=NA)
    reg<-lm(y~x)
    
    plot(reg$residuals,type="l",ylim=c(-10,10))
    forecast::Acf(reg$residuals,type="correlation",
                  lwd=2,xlab="",main="",lag.max = 20)
    forecast::Acf(reg$residuals,type="partial",
                  lwd=2,xlab="",main="",lag.max = 20)

I expect to see the same conclusion visually in some ACF/PACF plot. The ACF/PACF plots I have below each show a bar extend beyond the dashed bands, suggesting that the residuals ARE serially correlated. How do I reconcile the ACF/PACF plots to the results of the Breusch-Godfrey test? What I care about here is: 1) to confirm that the Breusch-Godfrey is giving us the correct conclusion, and 2) to draw ACF/PACF plots that would agree with the Breusch-Godfrey test results.

enter image description here

Best Answer

Breusch-Godfrey is a portmanteau-type test; it looks at all lags up to 20 (or whatever maximum lag order you choose). Now, the ACF shows that autocorrelation is statistically significant only for one lag among the first 20 (a single bar sticks out from the confidence bound). This is exactly what you would expect under the null hypothesis of no autocorrelation at any lag tested at 5% level; on average, a single bar out of 20 would stick out purely by chance.

Hence, there is no contradiction between the ACF and the Breusch-Godfrey test.

One could also say that there is an approximate sine pattern in the ACF. If your series were longer and the autocorrelations were estimated with greater precision, you could try out a parsimonious seasonal ARMA model to account for them. But given the estimation precision that you have, there is hardly any need to worry about these autocorrelations.

Related Question