简体   繁体   English

R中的HoltWinters预测

[英]HoltWinters forecast in R

I have a time series divided in 30 days and hour , so 720 values (24h*30). 我有一个按30天和小时划分的时间序列 ,所以有720个值(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. 我将时间序列分为3周进行“训练”,将时间序列进行1和4的测试。 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. 我在最初的3周使用HoltWinters方法,然后在第4周进行了预测,并在观察值和模拟值之间进行了比较。

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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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