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

查看:21
本文介绍了使用 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() 更好"的原因,请参阅 Journal of Statistical Software of July 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() 和结构TS().

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() 充当 predict() 的包装器,并将以通用格式(预测类)获得的信息.我们也定义一个默认的 predict() 方法,该方法在不存在时使用predict() 函数存在,并调用相关的 predict() 函数.因此,predict() 方法与 predict() 方法并行,但后者提供更有用的一致输出.

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天全站免登陆