How to Create a R TimeSeries for Hourly data

前端 未结 2 1877
既然无缘
既然无缘 2020-12-08 08:40

I have hourly snapshot of an event starting from 2012-05-15-0700 to 2013-05-17-1800. How can I create a Timeseries on this data and perform HoltWinters to it?

I trie

相关标签:
2条回答
  • 2020-12-08 09:03

    I think you should consider using ets from the package forecast to perform exponential smoothing. Read this post to have a comparison between HoltWinters and ets .

    require(xts)
    require(forecast)
    
    time_index <- seq(from = as.POSIXct("2012-05-15 07:00"), 
                      to = as.POSIXct("2012-05-17 18:00"), by = "hour")
    set.seed(1)
    value <- rnorm(n = length(time_index))
    
    eventdata <- xts(value, order.by = time_index)
    ets(eventdata)
    

    Now if you want to know more about the syntax of ets check the help of this function and the online book of Rob Hyndman (Chap 7 section 6)

    0 讨论(0)
  • 2020-12-08 09:04

    Please take a look at the following post which might answer the question:

    Decompose xts hourly time series

    Its explains how you can create a xts object using POSIXct objects. This xts object can have its frequency attribute set manually and you will probably then be able to use HoltWinters

    0 讨论(0)
提交回复
热议问题