[R] lags in regressions

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Jan 23 20:41:29 CET 2004


You need to do tsunion (or something like it) on the time series.  lm()  
does not know about time series and you are merely supplying vectors as
far as it is concerned.

On Fri, 23 Jan 2004, Tobias Mühlhofer wrote:

> Hi!
> 
> I am trying to get R to run regressions for me of a variable on lagged 
> differences of itself.
> 
> Specifically:
> 
> x-x(-1) = a + b1(x(-1)-rx(-2))+b2(x(-4)-rx(-5))+e
> 
> I need to do this a lot of times, altering the value of r.
> 
> What I've been trying to do was to use the lag() command to create 
> lagged versions of these variables and then constructing these 
> differences by hand (i.e. creating new variables containing these 
> differences).
> 
> When I put all of those into the lm() command I get a singularity 
> problem: it seems that R is unlagging the time series as it constructs 
> the object matrix, instead of simply truncating away observations that 
> don't exist for all the series due to the "pushing over" that is 
> happening in the lagging.
> 
> What do I do? Do I need to truncate these by hand and if yes how? Or is 
> there a different way?
> 
> Thanks,
> 	TM
> 

-- 
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