[R] Comparing lagged time series

Uwe Ligges ligges at statistik.uni-dortmund.de
Sun Oct 28 16:07:09 CET 2007


Please specify a reproducible example and tell us your version of R and 
your OS (as the posting guide asks you to do!), the following works for me:
lag(lh, -2)

Uwe Ligges


j taecha wrote:
> As a newbie to R I have the following question. I would like to compare values in a time series with values of the same series x observations ago. In gretl this is simply done like so: 
> 
> In R, I seem not to get it working. I have tried lag(data,-x) to obtain the lagged time series which produces the following error message:
> 
> Error in attr(x, "tsp") <- c(1, NROW(x), 1) : 
>         invalid time series parameters specified
> 
> Can anyone enlighten me on how to accomplish this task in R?
> 
> Thanks.
> 
> 
> 
> ------------------------------------------------------------------------
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list