An xts object reflected the desired lag and/or differencing.
an xts object
period to lag over
period to difference over
order of differencing
should arithmetic or geometric differencing be used
should (geometric) log differences be returned
pad vector back to original size
Jeffrey A. Ryan
The primary motivation for having methods specific to xts
was to make use of faster C-level code within xts. Additionally,
it was decided that lag's default behavior should
match the common time-series interpretation of that operator --- specifically
that a value at time ‘t’ should be the value at time ‘t-1’
for a positive lag. This is different than lag.zoo as well
Another notable difference is that na.pad is set to
TRUE by default, to better reflect the transformation visually
and within functions requiring positional matching of data.
Backwards compatability with zoo can be achieved by setting
options(xts.compat.zoo.lag=TRUE). This will change the
defaults of lag.xts to k=-1 and na.pad=FALSE.