Description Usage Arguments Details Value Author(s) References Examples
Methods for computing lags and differences on xts
objects. This
matches most of the functionality of zoo methods, with some default
argument changes.
1 2 3 4 5 6 7 |
x |
an |
k |
period to lag over |
lag |
period to difference over |
differences |
order of differencing |
arithmetic |
should arithmetic or geometric differencing be used |
log |
should (geometric) log differences be returned |
na.pad |
pad vector back to original size |
... |
additional arguments |
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
as lag.ts
.
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.
An xts
object reflected the desired lag and/or differencing.
Jeffrey A. Ryan
http://en.wikipedia.org/wiki/Lag
1 2 3 4 5 6 7 8 9 10 11 12 13 |
Loading required package: zoo
Attaching package: 'zoo'
The following objects are masked from 'package:base':
as.Date, as.Date.numeric
[,1]
2017-06-08 NA
2017-06-09 1
2017-06-10 2
2017-06-11 3
2017-06-12 4
2017-06-13 5
2017-06-14 6
2017-06-15 7
2017-06-16 8
2017-06-17 9
[,1]
2017-06-08 NA
2017-06-09 NA
2017-06-10 1
2017-06-11 2
2017-06-12 3
2017-06-13 4
2017-06-14 5
2017-06-15 6
2017-06-16 7
2017-06-17 8
[,1]
2017-06-08 2
2017-06-09 3
2017-06-10 4
2017-06-11 5
2017-06-12 6
2017-06-13 7
2017-06-14 8
2017-06-15 9
2017-06-16 10
[,1]
2017-06-08 NA
2017-06-09 1
2017-06-10 1
2017-06-11 1
2017-06-12 1
2017-06-13 1
2017-06-14 1
2017-06-15 1
2017-06-16 1
2017-06-17 1
[,1]
2017-06-08 NA
2017-06-09 1
2017-06-10 1
2017-06-11 1
2017-06-12 1
2017-06-13 1
2017-06-14 1
2017-06-15 1
2017-06-16 1
2017-06-17 1
[,1]
2017-06-08 NA
2017-06-09 NA
2017-06-10 0
2017-06-11 0
2017-06-12 0
2017-06-13 0
2017-06-14 0
2017-06-15 0
2017-06-16 0
2017-06-17 0
[,1]
2017-06-08 NA
2017-06-09 NA
2017-06-10 0
2017-06-11 0
2017-06-12 0
2017-06-13 0
2017-06-14 0
2017-06-15 0
2017-06-16 0
2017-06-17 0
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.