
The detrend()
function performs a detrending transformation and
removes a trend from the provided time series. detrend.rev()
reverses
the transformation.
detrend(x, trend)
A numeric vector or univariate time series of class ts
.
A numeric vector or univariate time series containing the trend to be removed. Generally, the fitted values of a model object.
A vector of the same length as x
containing the residuals of
x
after trend removal.
R. H. Shumway, D. S. Stoffer, Time Series Analysis and Its Applications: With R Examples, Springer, New York, NY, 4 edition, 2017.
# NOT RUN {
data(CATS,CATS.cont)
fpoly <- fittestPolyR(CATS[,1],h=20)
trend <- fitted(fpoly$model)
residuals <- detrend(CATS[,1],trend)
x <- detrend.rev(residuals,trend)
# }
Run the code above in your browser using DataLab