Skip to content
Prev 3509 / 63421 Next

lag (PR#491)

On Fri, 17 Mar 2000 kthaka@uta.fi wrote:

            
So that is _not_ the original series!
Your description is exactly as documented:

Lag a Time Series

Description:

     Computed a lagged version of a time series, shifting the time base
     back by `k' observations.

[Please read the documentation before submitting a bug report. The FAQ
tells you what a bug is.]

Don't apply regression (a non-time-series technique) to time series, and
expect the implicit conversion to vectors to preserve the time alignment.
Do something like

library(ts)
data(lh)
df <- cbind(x=lh, x1 =lag(lh, 1))
lm(x ~ x1, data=df)