diffXts: Lag and/or Difference/Use(rerun) a function(Fun) Upon its xts...

Description Usage Arguments Value Examples

View source: R/Functions.R

Description

1
Based on R CRAN package xts function diff.xts

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
diffXts(
  x,
  lag = 1,
  differences = 1,
  arithmetic = TRUE,
  log = FALSE,
  na.pad = TRUE,
  Fun = diff,
  ...
)

Arguments

x

as diff.xts

lag

as diff.xts

differences

as diff.xts. Also, knows as "number of (re)runs - 1" of function(Fun). Runs use as its input data, the results data from the the previous run (if any).s

arithmetic

as diff.xts

log

as diff.xts

na.pad

as diff.xts

Fun

difference-ing function. Meant to change the xTs in some way. (Default diff (expected: xts::diff.xts)). Should accept or (accept and ignore) the parameters: lag; for S3 compatibility, differences; for xts compatiblity, arithmetic, log, and/or na.pad.

...

dots passed

Value

xts object

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
## Not run: 

# diffXts examples

xts(matrix(c(1,-2,-4,8,16,32), ncol = 2), zoo::as.Date(0:2))
           [,1] [,2]
1970-01-01    1    8
1970-01-02   -2   16
1970-01-03   -4   32

diffXts(xts(matrix(c(1,-2,-4,8,16,32), ncol = 2), zoo::as.Date(0:2)))
        V1diff.1 V2diff.1
1970-01-01       NA       NA
1970-01-02       -3        8
1970-01-03       -2       16

# same as above
diffXts(xts(matrix(c(1,-2,-4,8,16,32), ncol = 2), zoo::as.Date(0:2)), Fun = AC)
           V1diff.1 V2diff.1
1970-01-01       NA       NA
1970-01-02       -3        8
1970-01-03       -2       16

diffXts(xts(matrix(c(1,-2,-4,8,16,32), ncol = 2), zoo::as.Date(0:2)),
       differences = 2, Fun = AC)

           V1diff.1 V2diff.1
1970-01-01       NA       NA
1970-01-02       NA       NA
1970-01-03        1        8

diffXts(xts(matrix(c(1,-2,-4,8,16,32), ncol = 2), zoo::as.Date(0:2)), Fun = RC)
           V1diff.1 V2diff.1
1970-01-01       NA       NA
1970-01-02       -2        2
1970-01-03       -1        2

diffXts(xts(matrix(c(1,-2,-4,8,16,32), ncol = 2), zoo::as.Date(0:2)),
        differences = 2, Fun = RC)

           V1diff.1 V2diff.1
1970-01-01       NA       NA
1970-01-02       NA       NA
1970-01-03      0.5        1


## End(Not run)

AndreMikulec/econModel documentation built on June 30, 2021, 9:48 a.m.