Estimates the trend (polynomial or lowess) of a time series and returns a graphic of the series with the trend and error bounds superimposed.
trend(series, order = 1, lowess = FALSE, lowspan = .75, robust = TRUE,
col = c(4, 6), ylab = NULL, ci=TRUE, ...)
Produces a graphic and returns the trend estimate fit
and error bounds lwr
and upr
invisibly
(see details) and with the same time series attributes as the input series
.
The time series to be analyzed (univariate only).
Order of the polynomial used to estimate the trend with a linear default (order=1) unless lowess
is TRUE.
If TRUE, loess
from the stats package is used to fit the trend. The default is FALSE.
The smoother span used for lowess.
If TRUE (default), the lowess fit is robust.
Vector of two colors for the graphic, first the color of the data (default is blue [4]) and second the color of the trend (default is magenta [6]). Both the data and trend line will be the same color if only one value is given.
Label for the vertical axis (default is the name of the series).
If TRUE (default), pointwise 95
Other graphical parameters.
D.S. Stoffer
Produces a graphic of the time series with the trend and a .95 pointwise confidence interval superimposed. The trend estimate and the error bounds are returned invisibly.
You can find demonstrations of astsa capabilities at FUN WITH ASTSA.
The most recent version of the package can be found at https://github.com/nickpoison/astsa/.
In addition, the News and ChangeLog files are at https://github.com/nickpoison/astsa/blob/master/NEWS.md.
The webpages for the texts and some help on using R for time series analysis can be found at https://nickpoison.github.io/.
detrend
if (FALSE) {
par(mfrow=2:1)
trend(soi)
trend(soi, lowess=TRUE)
}
Run the code above in your browser using DataLab