deseason_ts {EWSmethods} | R Documentation |
Deseason Seasonal Time Series
Description
Removes seasonal signals from time series using either averaging or time series decomposition methods. Three decomposition methods are available: traditional decompostion, loess decomposition and X11 decompostion.
Usage
deseason_ts(
data,
increment = c("month", "year", "week", "day"),
method = c("average", "decompose", "stl"),
order = NULL
)
Arguments
data |
The dataframe to be transformed, The first column must be a vector of dates with all other columns the individual time series. |
increment |
The time-step increment in either |
method |
String of either |
order |
String indicating the date format of the date columns. Options are |
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))
#Deseason using time series
#decomposition.
decomp_dat <- deseason_ts(data = multi_spp_data,
increment = "month",
method = "decompose",
order = "ymd")
#Deseason using loess
decomp_dat <- deseason_ts(data = multi_spp_data,
increment = "month",
method = "stl",
order = "ymd")