使用ARIMA预测一个月的每日数据的时间序列 [英] Time series prediction of daily data of a month using ARIMA

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

问题描述

我每个周期工作30天(每月),因此我的历史数据集中大约有2个周期.

I am working with 30 days (monthly) per cycle and thus have approximately 2 cycles in my historical dataset.

R脚本是

library(forecast)
value <- c(117.2 , 224.2 , 258.0 , 292.1 , 400.1 , 509.9 , 626.8 , 722.9 , 826.1 , 883.6,916.6, 1032.1, 1151.2, 1273.4 ,1391.8, 1499.2, 1532.5 ,1565.9 ,1690.9, 1813.6,1961.4 ,2102.8 ,2208.2, 2256.8, 2290.8 ,2413.7, 2569.4 ,2730.3, 2882.9 ,2977.5, 117.2 , 224.2 , 258.0 , 292.1 , 400.1 , 509.9 , 626.8 , 722.9 , 826.1 , 883.6,916.6, 1032.1, 1151.2, 1273.4 ,1391.8, 1499.2, 1532.5 ,1565.9 ,1690.9, 1813.6,1961.4 ,2102.8 ,2208.2, 2256.8, 2290.8 ,2413.7, 2569.4 ,2730.3, 2882.9 ,2977.5)

sensor<-ts(value,frequency=30)#daily data of month,here only 2 month's data
fit <- auto.arima(sensor)
LH.pred<-predict(fit,n.ahead=30)
plot(sensor,ylim=c(0,4000),xlim=c(0,5),type="o", lwd="1")
lines(LH.pred$pred,col="red",type="o",lwd="1")
grid()

结果图是

但是我对这个预测不满意.有什么方法可以使预测看起来像之前的价值趋势一样(见图)?

But I am not satisfied with the prediction. Is there any way to make the prediction look similar to the value trends preceding it (see graph)?

推荐答案

您要很多auto.arima()仅使用两个月的数据来查找模型.至少可以通过建议季节差异来有所帮助.此外,请勿使用predict. forecast函数要好得多.

You are asking a lot of auto.arima() to find a model using only two months of data. At least help it out a little by suggesting a seasonal difference. Further, don't use predict. The forecast function is much nicer.

出于为何forecast()是更精细"的原因,请参见 7月份的统计软件学报2008 ,尤其是第4.4节:

For reasons why forecast() is "nicer", see the Journal of Statistical Software of July 2008, in particular section 4.4:

Forecast()函数是通用函数,具有适用于广泛范围的S3方法 时间序列模型.它计算点预测和预测 时间序列模型的时间间隔.存在适用于模型的方法 使用ets(),auto.arima(),Arima(),arima(),ar(),HoltWinters()和 StructTS().

The forecast() function is generic and has S3 methods for a wide range of time series models. It computes point forecasts and prediction intervals from the time series model. Methods exist for models fitted using ets(), auto.arima(), Arima(), arima(), ar(), HoltWinters() and StructTS().

还有一种用于ts对象的方法.如果是时间序列 对象作为第一个参数传递给Forecast(),函数将 根据指数平滑算法生成预测 第2节.

There is also a method for a ts object. If a time series object is passed as the first argument to forecast(), the function will produce forecasts based on the exponential smoothing algorithm of Section 2.

在大多数情况下,存在现有的predict()函数 目的是做很多相同的事情.不幸的是, 来自predict()函数的结果对象包含不同的对象 每种情况下的信息,因此无法构建通用 结果的函数(例如plot()和summary()).所以与其, 预报()充当预报()的包装器,并将 以通用格式(预测类别)获得的信息.我们也 定义默认的predict()方法,该方法在不存在时使用 Forecast()函数存在,并调用相关的Forecast()函数. 因此,预报()方法与预报()方法并行,但后者 提供更有用的一致输出.

In most cases, there is an existing predict() function which is intended to do much the same thing. Unfortunately, the resulting objects from the predict() function contain different information in each case and so it is not possible to build generic functions (such as plot() and summary()) for the results. So, instead, forecast() acts as a wrapper to predict(), and packages the information obtained in a common format (the forecast class). We also define a default predict() method which is used when no existing predict() function exists, and calls the relevant forecast() function. Thus, predict() methods parallel forecast() methods, but the latter provide consistent output that is more usable.

尝试以下操作.

fit <- auto.arima(sensor,D=1)
LH.pred <- forecast(fit,h=30)
plot(LH.pred)
grid()

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

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