Search code examples
rtime-seriesforecastingtsibblefable-r

Fitting a model to a high frequency timeseries and forecasting on the short term using fable


I have a timeseries of a value with a fairly high frequency (15 minutes). The timeseries has no missing values and shows some daily and weekly periodic components.

I'm trying to model it using fable in R, but I can't seem to find any decent result, and I wonder if I`m doing something wrong.

Here`s my code, using an example dataset that can be downloaded:

library(tsibble)
library(fable)
library(dplyr)
library(lubridate)

download.file("https://srv-file7.gofile.io/download/9yo0cg/so_data.csv", destfile = "so_data.csv", method = "wget")
csv = read.csv("so_data.csv") %>%
    mutate(time = ymd_hms(time)) %>%
    as_tsibble(index = time)

# Take a look
csv %>% summary
csv %>% autoplot

This is the timeseries: enter image description here As you can see it is pretty regular, with good daily periodicity. Let's try to model it using the default settings for a few models:

csv %>%
    model(
        ets = ETS(value),
        arima = ARIMA(value),
        snaive = SNAIVE(value)
    ) %>%
    forecast(h = "1 week") %>%
    autoplot(csv)

All of them fail spectacularly: enter image description here

My limited understanding of this process is clearly at fault here, and default values are not useful in this situation. However I tried tuning them, unfortunately, I was unable to capture anything better. Anyway, as I am a noob in the field I do not understand if this is due to:

  • me not setting proper default parameters (I should dive much deeper into fable's reference book)
  • the limited data I have available (short time series, only a few months)
  • approach not suitable to fast-varying data (daily and weekly recurring patterns)
  • issues in my code

Solution

  • Your 15-minute frequency data exhibits multiple seasonal patterns. The models are producing poor quality forecasts as they are not designed to capture these patterns (and so they are not).

    Your code looks good and (visually) the data appears to have strong patterns that an appropriate model should capture.

    There are currently two more sophisticated models which work with fable that should be able to capture multiple seasonal patterns to give you better forecasts. They are: