Apply a time lag to an xts time series.
An xts time series.
An integer equal to the number of time periods of lag
A Boolean argument: Should the output be
padded with zeros? (The default is
Additional arguments to function
Applies a time lag to an xts time series and pads with the
first and last elements instead of
A positive lag argument
lagg means elements from
in the past are moved to the present. A negative lag argument
moves elements from the future to the present.
lagg = 0, then
lag_xts() returns the input time series
To avoid leading or trailing
NA values, the output xts is padded
with zeroes, or with elements from either the first or the last row.
For the lag of asset returns, they should be padded with zeros, to avoid look-ahead bias. For the lag of prices, they should be padded with the first or last prices, not with zeros.
lag_xts() is just a wrapper for function
lag.xts() from package
xts, but it
pads with the first and last elements instead of
lag_it() has incorporated the functionality of
lag_xts(), so that
lag_xts() will be retired in future
An xts time series with the same dimensions and the same time
index as the input
x_ts time series.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.