seriesLag {splusTimeSeries} | R Documentation |
Time Series Lag/Lead Function
Description
Returns a lagged/leading timeSeries
or signalSeries
object.
Usage
seriesLag(X, k = 1, trim = FALSE, pad = NA)
Arguments
X |
an object of class |
k |
the number of positions the new time series or signal series is to lag or lead the input series, with a positive value resulting in a lagged series and a negative value resulting in a leading series. |
trim |
a logical flag. If |
pad |
any padding to fill in the beginning or ending missing values.
The default is |
Details
The difference between shift
and seriesLag
is
that the returned series of shift
is shifted in time (position
)
while the returned series of seriesLag
shifts the entire data slot
but keeps the same time (position
) intact.
They all work for both timeSeries
and signalSeries
objects.
Value
returns a lagged or leading time (signal) series of the original data.
See Also
Examples
x <- timeSeries(data=data.frame(x=1:10, y=11:20),
from="7/4/2000", by="bizdays")
seriesLag(x, 1)
seriesLag(x, -1)