Data contains implicit gaps in time. You should check your data and convert implicit gaps into explicit missing values

Hello. Im doing a forecasting task, and have a problem that I really cant find a solution on. I get this message, when wanting to do a gg_season and even when wanting to do STL and ETS modelling / analyzing:

"[1] .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 cant really see any implicit gaps. I have imported a TS-dataset called "sales". I then made the dataset more tidy by making a pivot. This gives me a "month" column by character (Jan, Feb and so on), "year" column and a "sales" column.

I ran this code to create a new column with a YMD-variable by combining the year and month variables. This will first make the format like this "2007 Jan", "2007 Feb" and so on. I make a new dataset where i only include the sold and new month-variable.

sales$month <- paste(sales$year, sales$month, sep = " ")
sales <- subset(sold, select = c(sold, month))

Next im mutating the month-variable, where it formates it into YMD-format (2007-01-01, 2007-02-01) etc. The observations are per month. Im creating a tsibble with month variable as index.

sales <- sales %>%
mutate(month = ym(month)) %>%
as_tsibble(index = month)

I cant find the problem / solution.

Have you looked at the yearmonth() function in the tsibble package?

Where exactly?

I tried changing ym to yearmonth in the mutate chunk, but it doesn't change 2007 jan to 2007-01-01 when doing that.

UPDATE: Thanks. Now I can run at least gg_season without problems. Changed ym to yearmonth. Will it have any affect on the forecasting after, if the date-variable is in the year/month fx (2007 jan) format?

I strongly suggest you read Forecasting: Principles and Practice, particularly section 2.1 on tsibble objects.

Thanks. Will check it out.

I do have a different problem now. Im trying to forecast the demand for a product from 2022-08-24 to 2022-08-30 with a timeseries regression model. I found the tslm-function, but it keeps giving me an error when trying to forecast with it. It says that some objects (variables) are missing.

The tsibble has dates from 2022-04-01 to 2022-08-30. I created a training set with the observations from 2022-04-01 to 2022-08-23 and test set with the observations from 2022-08-24 to 2022-08-30 (forecasting for 7 days) - as I have to check the performance after. The train and test set are both tsibbles.

This is my tslm-model:
tslm <- train_data2 |>
model(tslm = TSLM(demand ~ temp_max_past1h + temp_gt25_3_days + weekend + month + stock))

So im forecasting with it for 7 days:
forecast_tslm <- forecast(tslm, h = 7)

I get this error:
Error in mutate():
! Problem while computing tslm = (function (object, ...) ....
Caused by error in value[[3L]]():
! object 'temp_max_past1h' not found
Unable to compute required variables from provided new_data.
Does your model require extra variables to produce forecasts?
Backtrace:

  1. generics::forecast(tslm, h = 7)
  2. fabletools:::forecast.lst_mdl(...)
  3. fabletools:::mapply_maybe_parallel(...)
  4. base::mapply(FUN = .f, ..., MoreArgs = MoreArgs, SIMPLIFY = SIMPLIFY)
  5. fabletools:::forecast.mdl_ts(...)
  6. base::tryCatch(...)
  7. base (local) tryCatchList(expr, classes, parentenv, handlers)
  8. base (local) tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  9. base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])

The object/variable "not found" is in the datasets - have checked many times. Ive tried everything even chatbot which keeps saying I have to check if the variable is spelled correctly etc.

Edit: Obviously its because its a regression model, so it needs the predictor variables values to forecast for the next days.. gotta find another way.

Assuming the data for 2022-08-24 to 2022-08-30 is in the tsibble test_data2, this should work:

forecast_tslm <- forecast(tslm, new_data = test_data2)

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.