Comparing lagged time series

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Comparing lagged time series

Thomas-69

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.


______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Comparing lagged time series

Uwe Ligges
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.
>
>
>
> ------------------------------------------------------------------------
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Comparing Lagged Time Series

Keith Chamberlain
In reply to this post by Thomas-69
Dear j,

I would probably use acf(). Also, set (or make sure you understand) the
parameter 'lag.max'.

See:
>?acf

Sincerely,
KeithC. [U.S]

______________________________________________
[hidden email] 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.