Skip to content
Back to formatted view

Raw Message

Message-ID: <x2add5bf2c.fsf@biostat.ku.dk>
Date: 2003-05-29T21:40:29Z
From: Peter Dalgaard
Subject: Newbie trying to Lag Variables in a regression
In-Reply-To: <NDEKIJPPGJCIKBNEDOKOMEDPCCAA.rwatkins@cornerstonelp.com>

<rwatkins at cornerstonelp.com> writes:

> Perhaps I am making this too hard, but how does one regress y(t) on a
> constant, x(t-1) and y(t-1)?  I've tried the manuals and until I get
> Dalgaard's book (just ordered on Amazon), I am stuck!

Not sure the book will unstick you...

However, the simple way is to create a new variable which shifts the
response, i.e. 

yshft <- c(y[-1], NA) # pad with missing
summary(lm(yshft ~ x + y))

Alternatively, lag the regressors:

N <- length(x)
xlag <- c(NA, x[1:(N-1)])
ylag <- c(NA, y[1:(N-1)])
summary(lm(y ~ xlag + ylag))


-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907