[R] correlated residuals in gls: Coefficient matrix not invertible

huan.huang@bnpparibas.com huan.huang at bnpparibas.com
Mon Jul 21 12:17:07 CEST 2003

Dear Rers,

I have threes series, x, y, z and I want to fit a model z ~ x + y. First of
all, I fit a lm. I found the residuals are correlated, by looking at the
acf() and pacf(). Then I tried to fit a gls model allowing residuals to be
correlated (correlation = corARMA(p=5, q=1)):

y.na <- as.data.frame(y[complete.cases(y),])
y.gls <- gls(z ~ x + y, data = y.na,  correlation=corARMA(p=5, q=1))

It gave this error message:
Error in "coef<-.corARMA"(*tmp*, value = c(188.077895742055, 180.123242661068,  :
      Coefficient matrix not invertible

I tried the gls allowing residuals following AR(1):

y.gls <- gls(z ~ x + y, data = y.na,  correlation=corAR1())

and it works. Actually I found in the correlation structure, as long as I set the p larger than 1 (ARMA(2, 1) OR ARMA(3,1)), I will have the error
message saying "Coefficient matrix not invertible".
But if I only set q (ARMA(0,2), ARMA(0,3)), it is working all right.

I did the above on some other data and had similar error messages:
Error in "coef<-.corARMA"(*tmp*, value = c(123.027732874371, 114.73028258271,  :
      Coefficient matrix not invertible

Could anybody give me some hint or point me a direction?

Thanks a lot.

Huan Huang

This message and any attachments (the "message") is\ intende...{{dropped}}

More information about the R-help mailing list