如何解决时间序列预测中的预测不足
我的时间序列有上升趋势并且是季节性的。我用TSLM
和trend()
建立了一个season()
模型。现在,当我使用此时间序列模型对测试数据进行预测时,这些预测始终处于实际情况之下。下面是可复制的代码。我注意到,即使我在不同的年份进行测试,预测仍将始终在3月到6月之间。我还尝试将knots
的趋势添加1913
。
数据来自商品(冷饮)的销售。
library(lubridate)
library(forecast)
library(tsibble)
library(fable)
library(feasts)
library(tidyverse)
df <- read_csv("https://raw.githubusercontent.com/amandeepfj/RawData/master/time-series.csv") %>%
mutate(year_mon = yearmonth(year_mon)) %>%
as_tsibble()
dts_train <- df %>% head(-6)
fable_models <- dts_train %>%
model(
tslm = TSLM(y ~ trend() + season())
)
fable_models %>% gg_tsresiduals()
augment(fable_models)
dts_test <- df %>% tail(6)
forecast(fable_models,new_data = dts_test,level = 95) %>% as_tibble() %>%
select(year_mon,.model,predicted = .mean) %>%
inner_join(dts_test,by = c("year_mon")) %>%
mutate(.resid = y - predicted)
时间序列的分解表明趋势分量在1914
之前具有周期。
dts_train %>%
model(
STL(y ~ trend() + season(window='periodic'),robust = TRUE)) %>%
components() %>%
autoplot()
不是编程语言专用的问题,位于R
中的工作示例之上。
链接到数据:https://raw.githubusercontent.com/amandeepfj/RawData/master/time-series.csv
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。