0

The time series data is a quarterly sales data, that is recored in

Date Sales Q
2019Q1 2000
2019Q2 3000
2019Q3 2500
2019Q4 3200

I used the yq(date) function to convert Date in Character into Date format. Then, I tried

data %>%
model(feasts::STL(Actual, robust = TRUE)

It resulted in an error

[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.

Even I used fill_gap(data), it will not work.

How can I apply STL() on this kind of data?

KT.Thompson
  • 149
  • 1
  • 9
  • Try using `tsibble::yearquarter()` to create your time index. The error occurs when you have some gaps (missing quarters) in your data, you will need to replace them with a suitable value to use STL. Note that fill_gaps() isn't enough, as it uses NA and STL doesn't support missing (NA) values. You can replace the NA with tidyr::fill() or some other appropriate interpolation method. – Mitchell O'Hara-Wild Mar 31 '23 at 07:58
  • I have already tried, not work – KT.Thompson Mar 31 '23 at 16:41
  • Actually, if we use `year quarter()` we should meet the same issue. – KT.Thompson Mar 31 '23 at 17:03
  • COuld you please share your data using `dput`? – Quinten Apr 04 '23 at 16:42

1 Answers1

0

The solution is quite simple, just using tsibble::year_quarter(yq(Date))

KT.Thompson
  • 149
  • 1
  • 9