Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Create a R TimeSeries for Hourly data

Tags:

r

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 tried the following

EventData<-ts(Eventmatrix$X20030,start=c(2012,5,15),frequency=8000) 
HoltWinters(EventData)

But I got Error in decompose(ts(x[1L:wind], start = start(x), frequency = f), seasonal) : time series has no or less than 2 periods

What value should I put from Frequency?

like image 542
R.D Avatar asked Jun 17 '13 20:06

R.D


1 Answers

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)

like image 81
dickoa Avatar answered Sep 28 '22 04:09

dickoa