dtrend: Deterministic Trend

Description Usage Arguments Value Examples

Description

Stable lifecycle

Remove global deterministic trend information from the series.

Usage

1
2
3
4
5
dtrend_lin(x, bp = NULL, na.rm = getOption("transx.na.rm"))

dtrend_quad(x, bp = NULL, na.rm = getOption("transx.na.rm"))

dtrend_poly(x, degree, bp = NULL, na.rm = getOption("transx.na.rm"))

Arguments

x

[univariate vector]

Univariate vector, numeric or ts object with only one dimension.

bp

[positive integer(1)]

Break points to define piecewise segments of the data.

na.rm

[logical(1): getOption("transx.na.rm")]

A value indicating whether NA values should be stripped before the computation proceeds.

degree

[positive integer(1)]

Value indicating the degree of polynomial

Value

Returns a vector with the same class and attributes as the input vector.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
set.seed(123)
t <- 1:20

# Linear trend
x <-  3*sin(t) + t
plotx(cbind(x, dtrend_lin(x)))

# Quadratic trend
x2 <-  3*sin(t) + t + t^2
plotx(cbind(raw = x2, quad = dtrend_quad(x2)))

# Introduce a breaking point at point = 10
xbp <- 3*sin(t) + t
xbp[10:20] <- x[10:20] + 15
plotx(cbind(raw = xbp, lin = dtrend_lin(xbp), lin_bp = dtrend_lin(xbp, bp = 10)))

kvasilopoulos/transx documentation built on Jan. 26, 2021, 6:14 p.m.