detrend: Remove a linear trend from a vector

Description Usage Arguments Value Author(s) Examples

View source: R/egcm_base.R

Description

Given a numeric vector Y, removes a linear trend from it.

Usage

1

Arguments

Y

numeric vector to be de-trended

Value

Returns a vector X where X[i] = Y[i] - a - b * i, where a and b describe the linear trend in Y.

Author(s)

Matthew Clegg [email protected]

Examples

1
2
3
4
5
6
7
detrend(rep(1,10))  # == 0 0 0 0 0 0 0 0 0 0
detrend(1:10)       # == 0 0 0 0 0 0 0 0 0 0
detrend((1:10)^2)   # == 12  4 -2 -6 -8 -8 -6 -2  4 12

mean(detrend(rnorm(1:100) + 1:100))  # should be very close to 0
sd(rnorm(1:100) + 1:100)             # approximately 29
sd(detrend(rnorm(1:100) + 1:100))    # approximately 1

egcm documentation built on Sept. 18, 2017, 5:03 p.m.