I'm trying to forecast the year-month data with one grouping variable which is "Actual Delivery location". I'm using ARIMA from Fable package for the forecasting but i'm getting the following error when I run the model
Error message : 3 errors (1 unique) encountered for ARIMA(Sales.Units, stepwise = F, approximation = F) [3] .data contains implicit gaps in time. You should check your data and convert implicit gaps into explicit missing values using tsibble::fill_gaps()
if required.
I have replaced the missing values with zero and I did the group_by with Actual Delivery location variable.
Could you please help to resolve this.
library(tidyverse)
library(tibbletime)
library(lubridate)
library(norm)
library(tibble)
library(tsibble)
library(fpp3)
Global.df<-structure(list(Actual.Delivery.Location = c("A324", "A324", "A324",
"A324", "A324", "A324", "A324", "A324", "A324", "A324", "A324",
"A324", "A324", "A324", "A324", "A324", "A324", "A324", "A324",
"A324", "A324", "A324", "A324", "A324", "A324", "A324", "A324",
"A324", "A324", "A324", "A324", "A324", "A324", "A324", "A324",
"A324", "A324", "A324", "A324", "A324", "A324", "A324", "A324",
"A324", "A324", "A324", "A324", "A324", "A324", "A324", "A324",
"A324", "A324", "A324", "A324", "A324", "A324", "A324", "A324",
"A324", "A324", "A324", "A324", "A324", "A324", "A324", "A324",
"A324", "A324", "A324", "A324", "A324", "A482", "A482", "A482",
"A482", "A482", "A482", "A482", "A482", "A482", "A482", "A482",
"A482", "A482", "A482", "A482", "A482", "A482", "A482", "A482",
"A482", "A482", "A482", "A482", "A482", "A482", "A482", "A482",
"A482", "A482", "A482", "A482", "A482", "A482", "A482", "A482",
"A482", "A482", "A482", "A482", "A482", "A482", "A482", "A482",
"A482", "A482", "A482", "A482", "A482", "A482", "A482", "A482",
"A482", "A482", "A482", "A482", "A482", "A482", "A482", "A482",
"A482", "A482", "A482", "A482", "A482", "A482", "A482", "A482",
"A482", "A482", "A482", "A482", "A482", "A999", "A999", "A999",
"A999", "A999", "A999", "A999", "A999", "A999", "A999", "A999",
"A999", "A999", "A999", "A999", "A999", "A999", "A999", "A999",
"A999", "A999", "A999", "A999", "A999", "A999", "A999", "A999",
"A999", "A999", "A999", "A999", "A999", "A999", "A999", "A999",
"A999", "A999", "A999", "A999", "A999", "A999", "A999", "A999",
"A999", "A999", "A999", "A999", "A999", "A999", "A999", "A999",
"A999", "A999", "A999", "A999", "A999", "A999", "A999", "A999",
"A999", "A999", "A999", "A999", "A999", "A999", "A999", "A999",
"A999", "A999", "A999", "A999", "A999"), YearMonth = c("Jan 2016",
"Feb 2016", "Mar 2016", "Apr 2016", "May 2016", "Jun 2016", "Jul 2016",
"Aug 2016", "Sep 2016", "Oct 2016", "Nov 2016", "Dec 2016", "Jan 2017",
"Feb 2017", "Mar 2017", "Apr 2017", "May 2017", "Jun 2017", "Jul 2017",
"Aug 2017", "Sep 2017", "Oct 2017", "Nov 2017", "Dec 2017", "Jan 2018",
"Feb 2018", "Mar 2018", "Apr 2018", "May 2018", "Jun 2018", "Jul 2018",
"Aug 2018", "Sep 2018", "Oct 2018", "Nov 2018", "Dec 2018", "Jan 2019",
"Feb 2019", "Mar 2019", "Apr 2019", "May 2019", "Jun 2019", "Jul 2019",
"Aug 2019", "Sep 2019", "Oct 2019", "Nov 2019", "Dec 2019", "Jan 2020",
"Feb 2020", "Mar 2020", "Apr 2020", "May 2020", "Jun 2020", "Jul 2020",
"Aug 2020", "Sep 2020", "Oct 2020", "Nov 2020", "Dec 2020", "Jan 2021",
"Feb 2021", "Mar 2021", "Apr 2021", "May 2021", "Jun 2021", "Jul 2021",
"Aug 2021", "Sep 2021", "Oct 2021", "Nov 2021", "Dec 2021", "Jan 2016",
"Feb 2016", "Mar 2016", "Apr 2016", "May 2016", "Jun 2016", "Jul 2016",
"Aug 2016", "Sep 2016", "Oct 2016", "Nov 2016", "Dec 2016", "Jan 2017",
"Feb 2017", "Mar 2017", "Apr 2017", "May 2017", "Jun 2017", "Jul 2017",
"Aug 2017", "Sep 2017", "Oct 2017", "Nov 2017", "Dec 2017", "Jan 2018",
"Feb 2018", "Mar 2018", "Apr 2018", "May 2018", "Jun 2018", "Jul 2018",
"Aug 2018", "Sep 2018", "Oct 2018", "Nov 2018", "Dec 2018", "Jan 2019",
"Feb 2019", "Mar 2019", "Apr 2019", "May 2019", "Jun 2019", "Jul 2019",
"Aug 2019", "Sep 2019", "Oct 2019", "Nov 2019", "Dec 2019", "Jan 2020",
"Feb 2020", "Mar 2020", "Apr 2020", "May 2020", "Jun 2020", "Jul 2020",
"Aug 2020", "Sep 2020", "Oct 2020", "Nov 2020", "Dec 2020", "Jan 2021",
"Feb 2021", "Mar 2021", "Apr 2021", "May 2021", "Jun 2021", "Jul 2021",
"Aug 2021", "Sep 2021", "Oct 2021", "Nov 2021", "Dec 2021", "Jan 2016",
"Feb 2016", "Mar 2016", "Apr 2016", "May 2016", "Jun 2016", "Jul 2016",
"Aug 2016", "Sep 2016", "Oct 2016", "Nov 2016", "Dec 2016", "Jan 2017",
"Feb 2017", "Mar 2017", "Apr 2017", "May 2017", "Jun 2017", "Jul 2017",
"Aug 2017", "Sep 2017", "Oct 2017", "Nov 2017", "Dec 2017", "Jan 2018",
"Feb 2018", "Mar 2018", "Apr 2018", "May 2018", "Jun 2018", "Jul 2018",
"Aug 2018", "Sep 2018", "Oct 2018", "Nov 2018", "Dec 2018", "Jan 2019",
"Feb 2019", "Mar 2019", "Apr 2019", "May 2019", "Jun 2019", "Jul 2019",
"Aug 2019", "Sep 2019", "Oct 2019", "Nov 2019", "Dec 2019", "Jan 2020",
"Feb 2020", "Mar 2020", "Apr 2020", "May 2020", "Jun 2020", "Jul 2020",
"Aug 2020", "Sep 2020", "Oct 2020", "Nov 2020", "Dec 2020", "Jan 2021",
"Feb 2021", "Mar 2021", "Apr 2021", "May 2021", "Jun 2021", "Jul 2021",
"Aug 2021", "Sep 2021", "Oct 2021", "Nov 2021", "Dec 2021"),
Sales.Units = c(2422, 1176, 2398, 2540, 3608, 4915, 3267,
4315, 2112, 3106, 1868, 2867, 2884, 555, 3208, 1732, 1180,
5911, 4082, 2992, 2173, 1974, 1665, 1997, 1989, 1382, 2074,
1433, 2537, 1869, 2106, 1923, 3410, 2035, 1174, 1462, 2372,
982, 4115, 2370, 3332, 983, 816, 2008, 3107, 4657, 1208,
1569, 1459, 1835, 1952, 337, 677, 4876, 2966, 2718, 6459,
1384, 1082, 2533, 1568, 1055, 1948, 1332, 2324, 3935, 2340,
1153, 1136, 491, 736, 802, 1303, 917, 683, 47, 847, 876,
196, 124, 620, 334, 114, 363, 592, 348, 842, 139, 747, 2242,
1653, 831, 105, 832, 400, 1026, 1053, 932, 998, 188, 334,
1418, 609, 300, 1097, 135, 549, 339, 1506, 1293, 76, 261,
97, 92, 678, 44, 697, 535, 203, 21, 135, 132, 259, 48, NA,
NA, 986, 985, 1340, 541, 211, 1018, 1810, 1028, 443, 1960,
114, 1342, 740, 73, 1512, 137, 169, 2308, 8324, 9000, 10006,
11553, 13637, 21684, 17027, 14328, 13915, 3828, 7620, 9405,
12086, 5963, 28456, 7933, 10039, 19783, 13488, 14828, 18563,
8864, 9995, 12951, 11156, 13203, 19383, 15198, 18466, 24225,
12761, 13580, 10387, 7638, 5584, 11093, 10959, 5781, 22894,
19559, 11428, 19135, 14153, 13864, 10961, 13355, 9454, 16976,
4837, 1077, 13443, 23364, 3667, 7469, 9465, 14030, 25455,
21555, 12228, 21354, 11829, 11518, 29550, 20653, 8949, 35923,
9466, 22290, 18310, 11170, 10732, 17269)), row.names = c(NA,
216L), class = "data.frame")
Global.df[is.na(Global.df)]<-0
Global.df$YearMonth<-lubridate::my(Global.df$YearMonth)
Global.df <- as_tibble(Global.df)
Global.df<- Global.df %>%
group_by(Actual.Delivery.Location) %>%
as_tsibble(key = Actual.Delivery.Location,
index = YearMonth)
Fit.Global.df<- Global.df %>%
group_by(Actual.Delivery.Location) %>%
model(ARIMA(Sales.Units,stepwise = F, approximation = F))