指数平滑预测与%Y-%间 - %d%H:%M的时间序列中的R格式

问题描述 投票:1回答:1

我有流量短的时间序列和我想用用ARIMA模型比较简单指数平滑法来预测交通流量。

我已经完成ARIMA模型的一部分,但我坚持着如何以应用简单的指数平滑模型的数据格式。

为什么我使用简单指数平滑的原因是因为我读它与短的时间序列那里没有趋势或季节性。我的时间序列为4个月,有每小时阅读。

我的数据是这样的:

       Date_Hour       Traffic_Flow      
2017-07-17 00:00:00         50 
2017-07-17 01:00:00         80 
2017-07-17 02:00:00         77 
2017-07-17 03:00:00         89 
2017-07-17 04:00:00         61 
2017-07-17 05:00:00         64

我有2175点的观测,并为培训将使用数据的1522个观测(3/4),并为测试将使用653层的意见。

View(SES_Data)
SES_DataXTS <- as.xts(x= SES_Data[,-1], order.by = as.POSIXct(SES_Data$Date_Hour), frequency = 4)
# Split the Data
training_indices <- 1:floor(0.7 * nrow(SES_DataXTS))
training_data <- SES_DataXTS[training_indices]
test_data <- SES_DataXTS[-training_indices]
#Fit mode:
fit_Model_SES <- ses(training_data ,beta=FALSE, gamma=FALSE)
# Do forecasting
forecast_SES <- forecast(fit_Model_SES,h=653)

当我做预测,我得到这个错误:

Error in forecast.forecast(fit_Model_SES, h = 653) : 
  Please select a longer horizon when the forecasts are first computed

如何指定的开始和结束时,我已经在每小时我的数据读取?我找不到例如如何使用简单指数平滑与XTS和动物园的对象。如果我将我的数据为TS(),它会忽略每小时读数。

我试过这个命令,但我不认为这是正确的。

tsfunction <- ts(SES_Data, frequency=24, start=2017-07-17 00:00:00, end= 2017-10-15 14:00:00, beta=FALSE, gamma=FALSE)

有什么建议吗?或任何其他的预测方法,我可以用很短的时间序列使用它与ARIMA比较

更新:

所以编辑我的命令为:

#Fit mode:
fit_Model_SES <- ses(SES_DataXTS ,beta=FALSE, gamma=FALSE, h=653)
#fit_Model_SES <- ses(training_data1 ,beta=FALSE, gamma=FALSE, h = 653)    
#Model 1: Exponential State Smoothing
f_ets = forecast(fit_Model_SES) # forecast 4 months into the future
plot(f_ets, col="blue")

但是,当我绘制我预测它会读取我的日期时间格式不正确。

像这样:enter image description here

我在寻找我用这样相同的数据ARIMA模型做策划我的预测:

enter image description here

r time-series xts forecasting smoothing
1个回答
0
投票

你需要指定的功能hses()参数(这将计算的预测)。对于某些功能,如ses(),你不需要之后调用forecast()

forecast_SES <- forecast(fit_Model_SES, h = 600)

来源:Forecast package Prediction Horizon issue in R

© www.soinside.com 2019 - 2024. All rights reserved.