D: Difference of a Time Series

Description Usage Arguments Value Examples

Description

D calculates the difference between an xts time series and its lag.

Usage

1
D(x, lag = 1, diff = 1)

Arguments

x

'xts' time series variable

lag

numeric or character value indicating the number of periods to lag x. Defaults to one lag. Character inputs indicate the type of time period to lag. lag accepts 'y' years, 'q' quarters, 'm' months, 'w' weeks, and 'd' days. Number and character values can be combined.

diff

number of times the x is differenced

Value

differenced 'xts' object.

Examples

1
2
3
4
5
Y <- pwt(country = 'USA', series = 'gdp')
d_Y <- D(Y)           # GDP differenced by 1 period (quarter)
y_Y <- D(Y, 'y')      # GDP differenced by 1 year
D_Y <- D(Y, diff = 2) # GDP differenced twice
#Table(Y, d_y, y_Y, D_Y)

cmann3/econ311 documentation built on May 31, 2019, 1:14 p.m.