Thanks @mitchelloharawild!
Below is the small dataset I have created from my original data. I am getting different error while modeling all time series...but I am getting error in the same place. With my entire dataset being used, I get the below error. But when I try to model only a specific brand and location with original data, no errors are seen and a nice forecasting plot was also made. But I tried only with one particular time series.
Error with original or entire dataset:
8 errors (1 unique) encountered for snaive
[8] .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.
8 errors (1 unique) encountered for ets
[8] .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.
8 errors (1 unique) encountered for arima
[8] .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.
library(tidyverse)
library(readxl)
library(tsibble)
library(fable)
#> Loading required package: fabletools
library(urca)
# Sample dataset with just first few rows
df <- data.frame(
stringsAsFactors = FALSE,
Date = c("01/01/2015","01/01/2015",
"01/01/2015","01/01/2015","01/01/2015",
"01/01/2015","01/01/2015","01/01/2015",
"01/01/2015","01/01/2015"),
Location = c("Brazil","Brazil","Brazil",
"Brazil","Canada","Canada","Canada",
"Canada","Ecuador","Ecuador"),
Brands = c("B","C","G","O","B","C","G",
"O","B","C"),
Sales = c(86056,76479,140247,116197,981,
54881,46822,-6491,16525,17043)
)
# Separating Date into Year and Month
df <- df%>%
separate(Date, into = c("Month", "Day", "Year"), sep = '/')%>%
select(-Day)%>%
unite(Date, Year, Month, sep = " " )
## Creating tsibble object
df <- df%>%
mutate(Date = yearmonth(as.character(Date)))%>%
as_tsibble(key = c(Location, `Brands`), index = Date)
# Modeling all the series
fit <- df %>%
model(
snaive = SNAIVE(Sales ~ lag("year")),
ets = ETS(Sales),
arima = ARIMA(Sales)
)
#> Warning: 10 errors (1 unique) encountered for snaive
#> [10] invalid 'times' argument
#> Warning: 10 errors (1 unique) encountered for ets
#> [10] only 1 case, but 2 variables
#> Warning: 10 errors (1 unique) encountered for arima
#> [10] missing value where TRUE/FALSE needed
fit
#> Warning: `...` is not empty.
#>
#> We detected these problematic arguments:
#> * `needs_dots`
#>
#> These dots only exist to allow future extensions and should be empty.
#> Did you misspecify an argument?
#> # A mable: 10 x 5
#> # Key: Location, Brands [10]
#> Location Brands snaive ets arima
#> <chr> <chr> <model> <model> <model>
#> 1 Brazil B <NULL model> <NULL model> <NULL model>
#> 2 Brazil C <NULL model> <NULL model> <NULL model>
#> 3 Brazil G <NULL model> <NULL model> <NULL model>
#> 4 Brazil O <NULL model> <NULL model> <NULL model>
#> 5 Canada B <NULL model> <NULL model> <NULL model>
#> 6 Canada C <NULL model> <NULL model> <NULL model>
#> 7 Canada G <NULL model> <NULL model> <NULL model>
#> 8 Canada O <NULL model> <NULL model> <NULL model>
#> 9 Ecuador B <NULL model> <NULL model> <NULL model>
#> 10 Ecuador C <NULL model> <NULL model> <NULL model>
Created on 2020-07-16 by the reprex package (v0.3.0)