Returns a lagged/leading "timeSeries" ("bdTimeSeries") or "signalSeries" ("bdSignalSeries") data.
USAGE:
seriesLag(X, k=1, trim=F, pad=NA)
REQUIRED ARGUMENTS:
X
a "timeSeries" ("bdTimeSeries") or "signalSeries" ("bdSignalSeries") object. Missing values (NA) are allowed.
OPTIONAL ARGUMENTS:
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
TRUE, the missing values at the beginning or end of the returned series
will be trimmed. The default is
FALSE.
pad
any padding to fill in the beginning or ending missing values. The default is
NA.
VALUE:
a lagged or leading time (signal) series of the original data.
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
timSeries
(
bdTimSeries) and
signalSeries
(
bdSignalSeries) objects.
SEE ALSO:
,
.
EXAMPLES:
djia.sub <- djia[timeEvent("01/01/1990","02/20/1990"),]
## creating a leading close price time series
seriesLag(djia.sub[,"close"], k=-(1:3), trim=F, pad=-999999)