R、时代序列、华宇模型、预测、每日数据 [英] R, Times Series, Arima Model, Forecasting, Daily data

查看:16
本文介绍了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.

方法一:使用 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:使用傅立叶作为 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天全站免登陆