lag.zoo

0th

Percentile

Lags and Differences of zoo Objects

Methods for computing lags and differences of "zoo" objects.

Keywords
ts
Usage
## S3 method for class 'zoo':
lag(x, k = 1, \dots)
## S3 method for class 'zoo':
diff(x, lag = 1, differences = 1, arithmetic = TRUE, \dots)
Arguments
x
a "zoo" object.
k, lag
the number of lags (in units of observations). Note the sign of k behaves as in lag.
differences
an integer indicating the order of the difference.
arithmetic
logical. Should arithmetic (or geometric) differences be computed?
...
currently not used.
Details

These methods for "zoo" objects behave analogously to the default methods. The only additional argument is arithmetic in diff.

Value

  • The lagged or differenced "zoo" object.

Note

Note the sign of k: a series lagged by a positive k is shifted earlier in time.

See Also

zoo, lag, diff

Aliases
  • lag.zoo
  • diff.zoo
Examples
x <- zoo(11:21)

lag(x, k = 1)
lag(x, k = -1)
# this pairs each value of x with the next or future value
merge(x, lag1 = lag(x, k=1))
diff(x^2)
Documentation reproduced from package zoo, version 0.9-9, License: GPL

Community examples

Looks like there are no examples yet.