Removes the mean value or (piecewise) linear trend from a vector or
from each column of a matrix.
Usage
detrend(x, tt = 'linear', bp = c())
Arguments
x
vector or matrix, columns considered as the time series.
tt
trend type, `constant' or `linear', default is `linear'.
bp
break points, indices between 1 and nrow(x).
Value
removes the mean or (piecewise) linear trend from x and returns it
in y=detrend(x), that is x-yis the linear trend.
Details
detrend computes the least-squares fit of a straight line (or
composite line for piecewise linear trends) to the data and subtracts the
resulting function from the data.
To obtain the equation of the straight-line fit, use polyfit.