Returns a time series like the input but shifted in time.
USAGE:
lag(x, k=1)
REQUIRED ARGUMENTS:
x:
a univariate or multivariate regular time series.
Missing values (NAs) are allowed.
OPTIONAL ARGUMENTS:
k:
the number of positions the new series is to lead the input
series, i.e., the resulting series is shifted backwards in time;
negative values lag the series forwards in time. Non-integer, values
of 'k' are rounded to the nearest integer.
VALUE:
a time series of the same length and the same number of channels as x
but lagged by k
positions. Only the start and end dates are changed; the
series still has the same number of observations.
NOTE:
Logically k should have the opposite sign, but due to its pervasive use
in other functions, lag remains unchanged.
DETAILS:
Use ts.intersect or ts.union to align the time domains of several series (using
cbind on lagged series will not align their domains).
lag is defined for both regular (rts) and calendar (cts) time series.