I want to decompose hourly time series with decompose
, ets
, or stl
or whatever function. Here is an example code and its output:
You can use tbats
to decompose hourly data:
require(forecast)
set.seed(1)
time_index1 <- seq(from = as.POSIXct("2012-05-15 07:00"),
to = as.POSIXct("2012-05-17 18:00"), by="hour")
value <- rnorm(n = length(time_index1))
eventdata1 <- msts(value, seasonal.periods = c(24) )
seasonaldecomp <- tbats(eventdata1)
plot(seasonaldecomp)
Additionally, using msts
instead of xts
allows you to specify multiple seasons/cycles, fore instance hourly as well as daily: c(24, 24*7)