The DIF() function returns a simple or seasonal differencing transformation of the provided time series. DIF.rev() reverses the transformation. Wrapper functions for diff and diffinv of the stats package, respectively.
Usage
DIF(x, lag = ifelse(type=="simple", 1, frequency(x)), differences = NULL,
type = c("simple","seasonal"), ...)
A numeric vector or univariate time series containing the values to be differenced.
lag
Integer indicating the lag parameter. Default set to 1 if type = "simple", or frequency(x) if type = "seasonal".
differences
Integer representing the order of the difference. If NULL, the order of the difference is automatically selected using ndiffs (if type = "simple") or nsdiffs (if type = "seasonal") from the forecast package.
type
Character string. Indicates if the function should perform simple or seasonal differencing.
xi
Numeric vector or time series containing the initial values for the integrals. If missing, zeros are used.
...
Additional arguments passed to ndiffs (if type = "simple") or nsdiffs (if type = "seasonal") from the forecast package.
Value
x if differences is automatically selected, and is not set as greater than 0.
# NOT RUN {data(CATS)
d <- DIF(CATS[,1], differences = 1)
x <- DIF.rev(as.vector(d), differences = attributes(d)$ndiffs, xi = CATS[1,1])
all(round(x,4)==round(CATS[,1],4))
# }