简体   繁体   中英

Auto Arima in R error: no seasonal differencing is selected

I am working on creating a forecasting model for my company using the auto.arima package in R.

Everytime I run the model get this error, and can't seem to find any resources on what to do about this

Warning in value[[3L]](cond): The chosen test encountered an error, so no seasonal differencing is selected. Check the time series data.

Does anyone know the meaning of this error? What do I check my time series data for? Any help would be greatly appreciated I have scoured the internet for answers on this and have came up with nothing.

Here is the code I am using, I can't post data because it is confidential. But I have hundreds of time series of sales for different styles summarized by week

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)

SAMPLE DATA:

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)

This warning (not an error) is informing you that the seasonal unit root test (used to select the number of seasonal differences, D) has errored.

Admittedly, the message is not very informative for why this has happened. In your case, an STL decomposition cannot be performed because your data contains less than two seasonal windows. This is necessary to use the nsdiffs(y, test = "seas") , or auto.arima(y, seasonal.test = "seas") which are both defaults.

For datasets without a full seasonal period, you can consider not using a SARIMA models by setting seasonal = FALSE in auto.arima() .

I've now improved this message to now also include the error message for why the test has failed: 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)

Created on 2019-04-24 by the reprex package (v0.2.1)

申请如下:

 mod <- lapply(mod1, function(x) auto.arima(x, seasonal = F))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM