splusTimeSeries (version 1.5.0-75)

shift: Create a Shifted Time Series

Description

Returns a time series like the input but shifted in time.

Usage

shift(x, k=1)

Arguments

x

a univariate or multivariate regular time series. Missing values (NAs) are allowed.

k

the number of positions the input series is to lead the new series. That is, the resulting series is shifted forwards in time; negative values lag the series backwards in time. Non-integer values of k are rounded to the nearest integer.

Value

returns a time series with the same data as x, but with positions lagged by k steps.

Details

shift is a generic function. Its default method calls lag(x,-k).

shift also has a method for series objects, which works for both timeSeries and signalSeries objects.

  • To align the times of several new-style time series, use seriesMerge.

  • To align the times of several old-style time series, use ts.intersect or ts.union.

  • To compute a lagged/leading series with same time position but shifted data slot, use seriesLag. (seriesLag also works for both timeSeries and signalSeries objects.)

See Also

seriesMerge, lag, lag.plot, ts.intersect, ts.union.

Examples

Run this code
# NOT RUN {
x <- signalSeries(data=data.frame(a=1:10, b=letters[1:10]), positions=1:10)
x5 <- shift(x,5)
seriesMerge(x, x5, pos="union")
# }

Run the code above in your browser using DataLab