Re: [R] How to use "lag"?

2005-03-05 Thread Gabor Grothendieck
Remigijus Lapinskas maf.vu.lt> writes: : : I use the following two function for a lagged regression: : : lm.lag=function(y,lag=1) summary(lm(embed(y,lag+1)[,1]~embed(y,lag+1)[,2: (lag+1)])) : lm.lag.x=function(y,x,lag=1) summary(lm(embed(y,lag+1)[,1]~embed(x,lag+1)[,2: (lag+1)])) : : for, resp

Re: [R] How to use "lag"?

2005-03-05 Thread Gabor Grothendieck
Dirk Eddelbuettel debian.org> writes: > > Spencer, > > You may want to peruse the list archive for posts that match 'ts' and are > written by Brian Ripley -- these issues have come up before. > > The ts class is designed for arima and friends (like Kalman filtering), and > very useful in that

Re: [R] How to use "lag"?

2005-03-05 Thread Remigijus Lapinskas
I use the following two function for a lagged regression: lm.lag=function(y,lag=1) summary(lm(embed(y,lag+1)[,1]~embed(y,lag+1)[,2:(lag+1)])) lm.lag.x=function(y,x,lag=1) summary(lm(embed(y,lag+1)[,1]~embed(x,lag+1)[,2:(lag+1)])) for, respectively, y_t=a+b_1*y_t-1+...+b_lag*y_t-lag y_t=a+b_1*

Re: [R] How to use "lag"?

2005-03-05 Thread Gabor Grothendieck
Spencer Graves pdf.com> writes: : : Is it possible to fit a lagged regression, "y[t]=b0+b1*x[t-1]+e", : using the function "lag"? If so, how? If not, of what use is the : function "lag"? I get the same answer from y~x as y~lag(x), whether : using lm or arima. I found it using y~c(NA, x[-l

Re: [R] How to use "lag"?

2005-03-05 Thread Dirk Eddelbuettel
Spencer, You may want to peruse the list archive for posts that match 'ts' and are written by Brian Ripley -- these issues have come up before. The ts class is designed for arima and friends (like Kalman filtering), and very useful in that context, but possibly not so much anywhere else. lag()

[R] How to use "lag"?

2005-03-05 Thread Spencer Graves
Is it possible to fit a lagged regression, "y[t]=b0+b1*x[t-1]+e", using the function "lag"? If so, how? If not, of what use is the function "lag"? I get the same answer from y~x as y~lag(x), whether using lm or arima. I found it using y~c(NA, x[-length(x)])). Consider the following: