小时间序列分析
small Time Series Analysis
我需要对未来两年做出预测。但是,我的数据量非常小。
数据:
structure(list(BelegDat = structure(c(16801, 16832, 16861, 16892,
16922, 16953, 16983, 17014, 17045, 17075, 17106, 17136, 17167,
17198, 17226, 17257, 17287, 17318, 17348, 17379, 17410, 17440,
17471, 17501, 17532, 17563, 17591, 17622, 17652, 17683, 17713,
17744, 17775, 17805, 17836, 17866, 17897, 17928, 17956, 17987,
18017, 18048, 18078, 18109, 18140, 18170, 18201, 18231), class = "Date"),
Value = c(37, 28, 37, 47, 37, 28, 37, 37, 19, 37, 37, 28,
40, 30, 40, 50, 40, 30, 40, 40, 20, 40, 40, 30, 30, 40, 30,
30, 40, 30, 30, 50, 30, 50, 20, 20, 60, 20, 60, 40, 20, 10,
40, 20, 20, 10, 44, 33)), row.names = c(NA, -48L), class = "data.frame")
我正在使用 ARIMA:
myts <- ts(df_ready[,2], start=c(2016,01), end=c(2019,12), frequency = 12)
fit <- auto.arima(myts)
pred <- forecast(fit, 24) # next 2 years (24 Months)
plot(pred)
My output:
Output
你能告诉我我的错误/建议一些其他的方法来完成这个预测吗?
提前致谢!
auto.arima
中有一个名为 D
的参数。我们需要将其设置为 1
以强制 arima 使用季节性模型。在这种情况下,
m1 <- ts(df$Value, start = min(df$BelegDat), frequency = 12)
autoplot(forecast(auto.arima(m1, D = 1), 24))
这给出了,
您的数据不支持任何季节性证据;您的数据与经过偏移量偏移的白噪声一致。
强制使用特定的 SARIMA 结构,然后使用它根据您的白噪声数据进行预测是非常危险的。
为了演示,让我们反过来生成白噪声数据,这些数据移动了相同的偏移量并且与样本数据具有相同的方差。请记住,这是 设计的白噪声。
library(forecast)
library(ggplot2)
set.seed(2018)
ts <- ts(
rnorm(48, mean = 33.8750, sd = 11.15796),
start = c(2016, 1), frequency = 12)
autoplot(ts) + theme_minimal()
我们现在将 SARIMA(0, 0, 0)(0, 1, 0)12 模型拟合到数据。
fit <- arima(ts, order = c(0, 0 , 0), seasonal = list(order = c(0, 1, 0), period = 12))
fit
#
#Call:
#arima(x = ts, order = c(0, 0, 0), seasonal = list(order = c(0, 1, 0), period = 12))
#
#
#sigma^2 estimated as 283: log likelihood = -152.7, aic = 307.39
同样,请记住,数据是从 ARIMA(0,0,0) = SARIMA(0,0,0)(0,0,0) 生成的,即白噪声模型。
我们现在使用fit
来预测
autoplot(forecast(ts, h = 24, model = fit)) + theme_minimal()
所以我们在这里所做的是在假设不存在季节性影响的情况下基于白噪声数据进行预测。
是的,您可以做到这一点而无需在 forecast
内提出任何 warnings/flags。不,这些预测没有意义。
我需要对未来两年做出预测。但是,我的数据量非常小。 数据:
structure(list(BelegDat = structure(c(16801, 16832, 16861, 16892,
16922, 16953, 16983, 17014, 17045, 17075, 17106, 17136, 17167,
17198, 17226, 17257, 17287, 17318, 17348, 17379, 17410, 17440,
17471, 17501, 17532, 17563, 17591, 17622, 17652, 17683, 17713,
17744, 17775, 17805, 17836, 17866, 17897, 17928, 17956, 17987,
18017, 18048, 18078, 18109, 18140, 18170, 18201, 18231), class = "Date"),
Value = c(37, 28, 37, 47, 37, 28, 37, 37, 19, 37, 37, 28,
40, 30, 40, 50, 40, 30, 40, 40, 20, 40, 40, 30, 30, 40, 30,
30, 40, 30, 30, 50, 30, 50, 20, 20, 60, 20, 60, 40, 20, 10,
40, 20, 20, 10, 44, 33)), row.names = c(NA, -48L), class = "data.frame")
我正在使用 ARIMA:
myts <- ts(df_ready[,2], start=c(2016,01), end=c(2019,12), frequency = 12)
fit <- auto.arima(myts)
pred <- forecast(fit, 24) # next 2 years (24 Months)
plot(pred)
My output: Output
你能告诉我我的错误/建议一些其他的方法来完成这个预测吗?
提前致谢!
auto.arima
中有一个名为 D
的参数。我们需要将其设置为 1
以强制 arima 使用季节性模型。在这种情况下,
m1 <- ts(df$Value, start = min(df$BelegDat), frequency = 12)
autoplot(forecast(auto.arima(m1, D = 1), 24))
这给出了,
您的数据不支持任何季节性证据;您的数据与经过偏移量偏移的白噪声一致。
强制使用特定的 SARIMA 结构,然后使用它根据您的白噪声数据进行预测是非常危险的。
为了演示,让我们反过来生成白噪声数据,这些数据移动了相同的偏移量并且与样本数据具有相同的方差。请记住,这是 设计的白噪声。
library(forecast)
library(ggplot2)
set.seed(2018)
ts <- ts(
rnorm(48, mean = 33.8750, sd = 11.15796),
start = c(2016, 1), frequency = 12)
autoplot(ts) + theme_minimal()
我们现在将 SARIMA(0, 0, 0)(0, 1, 0)12 模型拟合到数据。
fit <- arima(ts, order = c(0, 0 , 0), seasonal = list(order = c(0, 1, 0), period = 12))
fit
#
#Call:
#arima(x = ts, order = c(0, 0, 0), seasonal = list(order = c(0, 1, 0), period = 12))
#
#
#sigma^2 estimated as 283: log likelihood = -152.7, aic = 307.39
同样,请记住,数据是从 ARIMA(0,0,0) = SARIMA(0,0,0)(0,0,0) 生成的,即白噪声模型。
我们现在使用fit
来预测
autoplot(forecast(ts, h = 24, model = fit)) + theme_minimal()
所以我们在这里所做的是在假设不存在季节性影响的情况下基于白噪声数据进行预测。
是的,您可以做到这一点而无需在 forecast
内提出任何 warnings/flags。不,这些预测没有意义。