[R] corARMA and ACF in nlme

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Mar 10 09:27:03 CET 2004


On Tue, 9 Mar 2004, Jeff Jorgensen wrote:

> Just wondering what I might be doing wrong.  I'm trying to fit a multiple 
> linear regression model, and being ever mindful about the possibilities of 
> autocorrelation in the errors (it's a time series), the errors appear to 
> follow an AR1 process (ar(ts(glsfit$residuals)) selected order 1).  So, 
> when I go back and try to do the simultaneous regression and error fit with 
> gls, 

That's not really what you did: gls fits a multivariate normal 
distribution with covariance matrix like that of observations from an AR1 
rather than fit an AR model.  A fine distinction, but as the rest of the 
para shows, it does matter.

> the acf and pacf plots of residuals from the old model (glsfit) and 
> those plots of the new model (glsAR1fit, below)  look exactly the same (a 
> significant autocorrelation at lag of 1).

They should.  Those are the residuals from the regression, not the 
innovations of the autoregression fitted to the residuals.  So the problem 
lies in how you interpreted what you did, I believe.

You may find this clearer if you use arima which does fit an ARIMA model.

> Any ideas out there as to what I may be doing wrong?  Is there an error in 
> my code?
> 
> Here's my R code for the simultaneous model fit (taking a phi estimate=0.6 
> from a previous step <ACF(glsfit)>):
> 
> glsAR1fit<-gls(y~x1+x2+x3+x4, na.action = na.omit, subset=12:54,
>                  correlation = corARMA(0.6, p=1, q=0, fixed = FALSE))

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list