[R] lags and differences

Gabor Grothendieck ggrothendieck at myway.com
Wed May 12 05:44:15 CEST 2004


In this particular case, i.e. regressing diff(y) against 
x and x lagged one could write this:

   lm(diff(y)~., data=as.data.frame(embed(x,2)))

which works since the length of diff(y) happens
to equal the number of rows in embed(x,2).

fciclone <fciclone <at> bol.com.br> writes:

: 
: Dear all, could someone please clarify me if this 
: works, so as to implement lags and differences for 
: example in y and in a independent x1 of a  regression?
: 
: model<-lm((diff(y), -i)~x1+lag(x1,-1), data=anydata)
: 
: Thanks, a lot,
: Alexandre.




More information about the R-help mailing list