使用 HoltWinters 预测每日数据
Forecasting Daily Data using HoltWinters
首先,我已经咨询过这个 article and this 但无法让它工作。
我有从 28-03-2015
到 27-02-2017
的每日数据。
我的 TS object
看起来像这样:
bvg11_prod_ts <- ts(bvg11_data$MA_PROD, freq=365, start=c(2015, 87), end=c(2017, 58))
下图显示每日值:
autoplot(bvg11_prod_ts)
我还尝试通过以下方式创建每日 ts 对象:
bvg11_prod_ts <- ts(bvg11_data$MA_PROD, freq=7, start=c(2015, 3), end=c(2017, 02))
autoplot(bvg11_prod_ts)
这导致了这个情节:
如您所见,两个图表完全不同,但是,第一个更准确!
现在当我尝试使用 bvg11_prodsTSHoltWinter <- HoltWinters(bvg11_prod_ts)
时出现错误:
Error in decompose(ts(x[1L:wind], start = start(x), frequency = f), seasonal) : time series has no or less than 2 periods
怎么了?
错误消息非常清楚:频率为 365 时,您至少需要 2*365 = 730 个数据点。
x_err = ts(runif(729), freq = 365)
# this gives an error
fit = HoltWinters(x_err)
# this will work
x = ts(runif(730), freq = 365)
fit = HoltWinters(x)
首先,我已经咨询过这个 article and this 但无法让它工作。
我有从 28-03-2015
到 27-02-2017
的每日数据。
我的 TS object
看起来像这样:
bvg11_prod_ts <- ts(bvg11_data$MA_PROD, freq=365, start=c(2015, 87), end=c(2017, 58))
下图显示每日值:
autoplot(bvg11_prod_ts)
我还尝试通过以下方式创建每日 ts 对象:
bvg11_prod_ts <- ts(bvg11_data$MA_PROD, freq=7, start=c(2015, 3), end=c(2017, 02))
autoplot(bvg11_prod_ts)
这导致了这个情节:
如您所见,两个图表完全不同,但是,第一个更准确!
现在当我尝试使用 bvg11_prodsTSHoltWinter <- HoltWinters(bvg11_prod_ts)
时出现错误:
Error in decompose(ts(x[1L:wind], start = start(x), frequency = f), seasonal) : time series has no or less than 2 periods
怎么了?
错误消息非常清楚:频率为 365 时,您至少需要 2*365 = 730 个数据点。
x_err = ts(runif(729), freq = 365)
# this gives an error
fit = HoltWinters(x_err)
# this will work
x = ts(runif(730), freq = 365)
fit = HoltWinters(x)