Re: [R] lm and time series: simple question

From: Prof Brian Ripley <>
Date: Fri 17 Jun 2005 - 17:02:55 EST

On Thu, 16 Jun 2005 wrote:

> This question is partly about R and partly out of my ignorance about
> time series.
> I want to regress one time series on another, taking into account the
> autocorrelation (in an AR1 model) within each series. I am interested in how
> the standard error changes when the acf is taken into account.

This does not happen with least-squares fitting as done by lm. You can use arima or gls (in package nlme). Note that both assume a model for the residuals, not for the series themselves.

You could also make a joint model of the two time series. That is probably not what you want.

> I've made both of my datasets into ts objects and used the basic lm
> function (with na.action=NULL) to no effect (i.e. the resulting standard
> error is the same as if they were not times series). I've also looked
> at binding the two series together with ts.union or ts.intersect, but
> then I am left with a single object, and don't understand how to regress
> one of the components of this onto the other.

Brian D. Ripley,        
Professor of Applied Statistics,
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________ mailing list
PLEASE do read the posting guide!
Received on Fri Jun 17 18:10:30 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:46 EST