时间序列预测中的预测不足

时间:2020-08-14 19:28:16

标签: r time-series fable-r tsibble

我的时间序列有上升趋势并且是季节性的。我用TSLMtrend()建立了一个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()

enter image description here

不是编程语言专用的问题,位于R中的工作示例之上。

链接到数据:https://raw.githubusercontent.com/amandeepfj/RawData/master/time-series.csv

0 个答案:

没有答案