简体   繁体   中英

HoltWinters forecast in R

I have a time series divided in 30 days and hour , so 720 values (24h*30).

在此处输入图片说明

Every Saturday and Sunday as you can see I have the lowest values at the time series . (It starts from friday).

I divided the time series in 3 week for "train" and 1 for test with the 4th. I applied HoltWinters method at first 3 week and then I did a forecast on 4th week and make a comparison beetween observed value and simulated.

Test<-function(ID,Unique,i){
  DfIn<-ID$V4[1:552]
  DfReal<-ID$V4[553:720]
  x<-ts(data=DfIn,frequency=24)
  HW<-HoltWinters(x,beta = FALSE)
  Pred<-forecast.HoltWinters(HW,168)
  print("Accuracy")
  print(accuracy(Pred,DfReal))
  Box1<-Box.test(Pred$residuals,type="Ljung-Box")
  P<-Box1$p.value
  return (P)
}

This is the comparison 在此处输入图片说明 where Blue line are simulated value and Red line are observed value.

The problem is , why simulated value don't follow the red line when timeseries got the lowest value on saturday and sunday? Is there a way to get more accuracy and let prediction to be more similar to observed?

Update:

在此处输入图片说明

你可以试试

x<-ts(data=DfIn,frequency=7*24)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM