R,时间序列,有马模型,预测,每日数据 [英] R, Times Series, Arima Model, Forecasting, Daily data

查看:145
本文介绍了R,时间序列,有马模型,预测,每日数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用2012年1月16日至2013年10月10日的每日数据进行需求预测.但是,该预测只会返回可怕的结果.有什么线索吗?

I am trying to do some demand forecasting with daily data, from jan 16, 2012 to Oct 10, 2013. But the forecasting just returns awful results. Any clue why?

这是图中数据的样子:存在每周和每月的季节性.即:工作日的需求增加,周末的需求减少.

This is how the data looks like in a plot: There are weekly and monthly seasonalities exist. Ie: More demand during weekday and less demand during the weekend.

这是预测图的外观:黑线是实际数据,蓝线是预测数据.

Here is how the prediction plot looks: where the black line is the actual data and blue line is the predicted data.

 x = ts(data, freq=7, start=c(3,2))
 fit <- auto.arima(x)
 pred <- forecast(fit, h=300)

我做了很多关于如何使用Arima模型拟合日常数据的研究.而且由于每周都有季节性,所以我选择freq = 7.

I did a lot of research on how to fit daily data with arima model. And since there are weekly seasonality, so I chose freq=7.

但是,由于预测不好.有人很好地指出了Hyndman教授分享的关于拟合具有多个季节性的模型的一种方法.

However, since the predicts are bad. And someone was nice enough to pointing out one of the method Professor Hyndman shared about fitting models with multiple seasonalities.

https://stats.stackexchange.com/questions /74418/frequency-of-time-series-in-r/74426#74426

因此,我接受了好朋友的建议,并使用上面链接中给出的2种方法对模型进行了拟合.

So I took the good guys's advice and fit the models with the given 2 methods from the above link.

方法1:使用tbats()函数.

Method 1: Using tbats() function.

x_new <- msts(x, seasonal.periods=c(7,7*52))
fit <- tbats(x_new)
fc <- forecast(fit, h=7*52)

我使用了每周季节性7和每年季节性7 * 52.由于我还没有想出一种简单的方法来获取每月的季节性.根据结果​​,预测也不是很好.注意:如果我将7 * 4用作每月的第二个季节性周期,则会给出较差的预测.

I used the weekly seasonality 7 and annually seasonality 7*52. Since I haven't figure out an easy way to get the monthly seasonality. Based on the result, the prediction is not good either. Note: if I use 7*4 as the second seasonal period for monthly, it gives worse prediction.

方法2:将Fouriers用作xreg.

Method 2: Using fouriers as an xreg.

seas1 <- fourier(x, K=1)
seas2 <- fourier(ts(x,freq=7*52), K=1)
fit <- auto.arima(x, xreg=cbind(seas1,seas2))
seas1.f <- fourierf(x, K=1, h=7*52)
seas2.f <- fourierf(ts(x,freq=7*52), K=1, h=7*52)
fc1 <- forecast(fit, xreg=cbind(seas1.f, seas2.f))

我用不同的K尝试了一下,但它并不能改善预测.

I tried it with different K, and it doesn't improve the prediction.

因此,我被卡住了!由于预测还很遥远.谁能指出我的错误在哪里?还是应该改善我的模型?

Therefore, I am stuck! Since the forecasting is way off. Could anyone please point out where my mistakes are? Or how should I improve my model?

非常感谢!

推荐答案

您错过了假期的影响以及假期和离群值(脉冲离群值,水平移动,趋势变化,当日变化)周围的铅或铅的影响.周影响(即季节性变化).如果您处理这些事情,那么您将无法很好地阅读星期几模式.您可以将数据发布到dropbox.com,以便我看看吗?指定开始日期和数据来自的国家/地区.

You are missing the impacts of holidays and the lead orlag impacts around the holiday and outliers(pulse outliers, level shift, changes in trend, changes in day of the week impacts(ie seasonal pulse)). If you deal with these things then you can't get a good read on the day of the week patterns. Can you post your data to dropbox.com so I can take a look? Specify the beginning date and the country where the data is from.

这篇关于R,时间序列,有马模型,预测,每日数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆