Search code examples
rtime-seriesdecompositionstl-decomposition

How to apply STL decomposition on a quarterly time series data using feasts package in R?


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?


Solution

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