detrend_ts {EWSmethods} | R Documentation |
Detrend Time Series
Description
Removes directional signals from time series using loess, linear regression or gaussian detrending.
Usage
detrend_ts(data, method = "linear", bandwidth = NULL, span = 0.25, degree = 2)
Arguments
data |
The dataframe to be detrended. The first column must be a vector of dates with all other columns the individual time series. |
method |
The method of detrending. Options include |
bandwidth |
If |
span |
If |
degree |
If |
Value
Dataframe of deseasoned time series.
Examples
#Generate five random monthly time series
#of 5 years length.
spp_data <- matrix(nrow = 5*12, ncol = 5)
spp_data <- sapply(1:dim(spp_data)[2], function(x){
spp_data[,x] <- rnorm(5*12,mean=20,sd=5)})
multi_spp_data <- cbind("time" =
seq(as.Date('2000/01/01'), as.Date('2004/12/01'), by="month"),
as.data.frame(spp_data))
detrend_dat <- detrend_ts(data = multi_spp_data,
method = "gaussian",
bandwidth = 2)