Decompose xts hourly time series

后端 未结 2 1798
梦谈多话
梦谈多话 2021-01-06 10:43

I want to decompose hourly time series with decompose, ets, or stl or whatever function. Here is an example code and its output:

2条回答
  •  说谎
    说谎 (楼主)
    2021-01-06 11:28

    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)

提交回复
热议问题