Detrends y
by subtracting a linear trend in x
, to create
a vector that is zero for its first and last finite value.
If the second parameter (y
) is missing, then x
is
taken to be y
, and a new x
is constructed with
seq_along()
. Any NA
values are left as-is.
detrend(x, y)
a vector of numerical values. If y
is not given, then
x
is taken for y
.
an optional vector
A list containing Y
, the detrended version of y
, and
the intercept a
and slope b
of the linear function of x
that is subtracted from y
to yield Y
.
A common application is to bring the end points of a time series down to zero, prior to applying a digital filter. (See examples.)