Lags and Leads for Time Series Objects
lagts.Rdlagts and leadts are new generic functions that do
intuitive computations of lags and leads. The main purpose is to overcome
the confusion about the sign of the lag order in the base lag
function that is employed differently by different classes.
Usage
lagts(x, ...)
leadts(x, ...)
# Default S3 method
lagts(x, k = 1, na.pad = TRUE, ...)
# S3 method for class 'ts'
lagts(x, k = 1, na.pad = TRUE, ...)
# S3 method for class 'zoo'
lagts(x, k = 1, na.pad = TRUE, ...)Arguments
- x
an object. The default method works for vectors and matrices.
- k
For
lagthe number of lags (in units of observations). Note the sign ofkbehaves as employed in most textbooks and not as inlag.- na.pad
logical. If
TRUEit adds any times that would not otherwise have been in the result with a value ofNA. IfFALSEthose times are dropped.- ...
currently not used.
Details
lagts by default computes real lags for positive k while
lag would in fact compute leads. The latter lead to a lot
of confusion among users of lag, especially because some time series
classes followed the base behavior while others decided for the intuitive
(but inconsistent) behavior. lagts aims to overcome this confusions
This functionality is still under development.