我正在使用R中的auto.arima包为我的公司创建预测模型。
每次运行模型时都会出现此错误,并且似乎找不到有关该操作的资源
Warning in value[[3L]](cond): The chosen test encountered an error, so no seasonal differencing is selected. Check the time series data.
有人知道此错误的含义吗?我要检查什么时间序列数据?任何帮助将不胜感激,我已经在互联网上搜寻有关此问题的答案,但没有提出任何建议。
这是我使用的代码,我无法发布数据,因为它是机密的。但是我按周总结了数百种不同风格的销售时间序列
library(forecast)
new <- split(fctts, fctts$opt)
mod1 <- lapply(new, function(x) ts(x$sales, frequency = 52))
mod <- lapply(mod1, function(x) auto.arima(x))
res <- mapply(function(mod, new) forecast(mod, h = 12), mod, new)
forecasts <- lapply(apply(res,2,list), function(x) x[[1]]$mean)
样本数据:
fctts <- read.table(text='
_week opt sales
4/30/2017 Style_A 13
5/7/2017 Style_A 13
5/14/2017 Style_A 13
5/21/2017 Style_A 12
5/28/2017 Style_A 8
6/4/2017 Style_A 17
6/11/2017 Style_A 10
6/18/2017 Style_A 8
6/25/2017 Style_A 8
7/2/2017 Style_A 10
7/9/2017 Style_A 9
7/16/2017 Style_A 11
7/23/2017 Style_A 7
7/30/2017 Style_A 5
8/6/2017 Style_A 15
8/13/2017 Style_A 23
8/20/2017 Style_A 20
8/27/2017 Style_A 24
9/3/2017 Style_A 45
9/10/2017 Style_A 39
9/17/2017 Style_A 28
9/24/2017 Style_A 22
10/1/2017 Style_A 51
10/8/2017 Style_A 43
10/15/2017 Style_A 28
10/22/2017 Style_A 30
10/29/2017 Style_A 40
11/5/2017 Style_A 14
11/12/2017 Style_A 44
11/19/2017 Style_A 14
11/26/2017 Style_A 28
12/3/2017 Style_A 31
12/10/2017 Style_A 15
12/17/2017 Style_A 23
12/24/2017 Style_A 11
12/31/2017 Style_A 12
1/7/2018 Style_A 15
1/14/2018 Style_A 21
1/21/2018 Style_A 23
1/28/2018 Style_A 20
2/4/2018 Style_A 27
2/11/2018 Style_A 33
2/18/2018 Style_A 24
2/25/2018 Style_A 31
3/4/2018 Style_A 35
3/11/2018 Style_A 19
3/18/2018 Style_A 37
3/25/2018 Style_A 47
4/1/2018 Style_A 32
4/8/2018 Style_A 52
4/15/2018 Style_A 44
4/22/2018 Style_A 33
4/29/2018 Style_A 52
5/6/2018 Style_A 31
10/8/2017 Style_B 4
10/15/2017 Style_B 4
10/22/2017 Style_B 6
10/29/2017 Style_B 8
11/5/2017 Style_B 1
11/12/2017 Style_B 7
11/19/2017 Style_B 2
11/26/2017 Style_B 2
12/3/2017 Style_B 5
12/10/2017 Style_B 1
12/17/2017 Style_B 4
12/24/2017 Style_B 3
12/31/2017 Style_B 2
1/7/2018 Style_B 7
1/14/2018 Style_B 4
1/21/2018 Style_B 10
1/28/2018 Style_B 4
2/4/2018 Style_B 8
2/11/2018 Style_B 6
2/18/2018 Style_B 9
2/25/2018 Style_B 10
3/4/2018 Style_B 18
3/11/2018 Style_B 9
3/18/2018 Style_B 14
3/25/2018 Style_B 24
4/1/2018 Style_B 5
4/8/2018 Style_B 12
4/15/2018 Style_B 9
4/22/2018 Style_B 15
4/29/2018 Style_B 16
5/6/2018 Style_B 15
4/30/2017 Style_C 7
5/7/2017 Style_C 1
5/14/2017 Style_C 0
5/21/2017 Style_C 5
5/28/2017 Style_C 1
6/4/2017 Style_C 1
6/11/2017 Style_C 5
6/18/2017 Style_C 1
6/25/2017 Style_C 1
7/2/2017 Style_C 0
7/9/2017 Style_C 2
7/16/2017 Style_C 3
7/23/2017 Style_C 6
7/30/2017 Style_C 2
8/6/2017 Style_C 5
8/13/2017 Style_C 14
8/20/2017 Style_C 7
8/27/2017 Style_C 1
9/3/2017 Style_C 1
9/10/2017 Style_C 7
9/17/2017 Style_C 0
9/24/2017 Style_C 2
10/1/2017 Style_C 5
10/8/2017 Style_C 2
10/15/2017 Style_C 0
10/22/2017 Style_C 2
10/29/2017 Style_C 1
11/5/2017 Style_C 1
11/12/2017 Style_C 1
11/19/2017 Style_C 4
11/26/2017 Style_C 13
12/3/2017 Style_C 4
12/10/2017 Style_C 7
12/17/2017 Style_C 5
12/24/2017 Style_C 2
12/31/2017 Style_C 4
1/7/2018 Style_C 6
1/14/2018 Style_C 4
1/21/2018 Style_C 7
1/28/2018 Style_C 5
2/4/2018 Style_C 19
2/11/2018 Style_C 45
2/18/2018 Style_C 33
2/25/2018 Style_C 37
3/4/2018 Style_C 36
3/11/2018 Style_C 44
3/18/2018 Style_C 22
3/25/2018 Style_C 54
4/1/2018 Style_C 35
4/8/2018 Style_C 41
4/15/2018 Style_C 26
4/22/2018 Style_C 25
4/29/2018 Style_C 52
5/6/2018 Style_C 37
', header=TRUE)
答案 0 :(得分:1)
此警告(不是错误)通知您季节性单位根检验(用于选择季节性差异数D)已错误。
诚然,该消息对于发生这种情况的信息不是很丰富。对于您而言,无法执行STL分解,因为您的数据包含少于两个季节性窗口。必须使用都是默认值的nsdiffs(y, test = "seas")
或auto.arima(y, seasonal.test = "seas")
。
对于没有完整季节的数据集,可以通过在seasonal = FALSE
中设置auto.arima()
来考虑不使用SARIMA模型。
我现在对此消息进行了改进,现在还包括测试失败的错误消息:https://github.com/robjhyndman/forecast/commit/eebea5ee93cd8b125d5220c54721895b57396157
library(forecast)
new <- split(fctts, fctts$opt)
mod1 <- lapply(new, function(x) ts(x$sales, frequency = 52))
mod <- lapply(mod1, function(x) auto.arima(x))
#> Warning: The chosen seasonal unit root test encountered an error when testing for the first difference.
#> From stl(): series is not periodic or has less than two periods
#> 0 seasonal differences will be used. Consider using a different unit root test.
#> Warning: The chosen seasonal unit root test encountered an error when testing for the first difference.
#> From stl(): series is not periodic or has less than two periods
#> 0 seasonal differences will be used. Consider using a different unit root test.
res <- mapply(function(mod, new) forecast(mod, h = 12), mod, new)
forecasts <- lapply(apply(res,2,list), function(x) x[[1]]$mean)
由reprex package(v0.2.1)于2019-04-24创建
答案 1 :(得分:0)
应用如下:
mod <- lapply(mod1, function(x) auto.arima(x, seasonal = F))