2

My data structure is in the image below and has hourly intervals. I need to forecast the Demand.

# A tsibble: 23,400 x 6 [1h] <UTC>
          Date           Demand WeekDay DaysAfterHoliday Influenza MAX_Temperature
        <dttm>            <int>   <int>            <int>     <dbl>           <dbl>
 1 2017-05-01 00:00:00    122       1                0      1               19.2
 2 2017-05-02 01:00:00    124       2                1      3.04            25.3

...

I know that in a day after a holiday the number of patients in the ED is higher than usual but I can't make sure that the model is taking that into account. The data has daily, weekly and annual seasonality (especially for fixed holidays).

For multiple seasonality I can use FASSTER to handle holiday effects. I read the r documentation page on this and some presentation but in those cases the seasonality and the formula of the forecast is given to the function like this:

# NOT RUN {
cbind(mdeaths, fdeaths) %>%
  as_tsibble %>%
  model(FASSTER(mdeaths ~ fdeaths + poly(1) + trig(12)))

# }

Is there a way to make FASSTER search the most adequate formula? If not how can I know which is the best approach?

Thank you in advance!

1 Answers1

2

The fasster package currently doesn't provide any facilities for automatic model selection (https://github.com/tidyverts/fasster/issues/50).

To identify an appropriate fasster model specification, you can start by graphically exploring your data to identify its structure. Some questions you may consider include:

  • Is your data seasonal? Which seasonal periods are required?
    Include seasonality with fourier terms via fourier(period, K) or season(period). Generally using fourier() terms are better, as being able to specify the number of harmonics (K) allows you to control the smoothness of the seasonality and reduce model parameters.
  • Does your data include an level or local trends?
    Include a level with poly(1) or a trend with poly(2).
  • Are there potential exogenous regressors (a good example of this is temperature in electricity demand).
    Include exogenous regressors in the same way as you would in lm().
  • Do the patterns in your data alternate in predictable ways (for example, seasonality on weekdays and weekends.)
    Use %S% to switch between these patterns. For example to have a different seasonal pattern for weekdays and weekends you may consider day_type %S% (fourier("day", K = 7)), where day_type is a variable in your model that specifies if the day is a weekday or weekend.

A simple approach to capturing the increase in patients after a holiday would be to include DaysAfterHoliday as an exogenous regressor. As this relationship is likely non-linear, you may need to also include some non-linear transformations of this variable as exogenous regressors.

  • is there an estimation for the release of the automatic fasster? My data has a week seasonality but for the holidays the seasonality is annual (since it depends on the day of the year). Using your example for weekdays vs weekends I created the needed variable (with 1 and 0 for holidays and non-holidays. However, it doesn't work since it isn't something that happens every week! How can I specify an annual seasonality for holidays (and the day after) using the '%S%'? Like in your example you use k=7. The "day" in the fourier is correct for the code or is a simplification? – Diana Serrano Mar 13 '20 at 13:33
  • 1
    Automatic modelling for fasster is not planned yet, so I can't provide an estimate. I would consider your holidays as events rather than an annual seasonality. Accordingly it may be better to specify these events via exogenous regressors. Using "day" in `fourier()` is valid code, annual seasonality can be specified with `fourier("year", K = ???)`. – Mitchell O'Hara-Wild Mar 14 '20 at 02:06
  • @MitchellO'Hara-Wild, with exogenous regressors, does FASSTER provide any helper function to forecast each exogenous regressor before we can forecast the target variable? For example, I'm including Covid-19 cases number as a regressor to forecast target variable Y. How can I also forecast Covid-19 cases to then use as input to forecast target variable Y? – Afiq Johari Aug 07 '20 at 02:49
  • You'll need to produce a separate forecasting model for COVID-19 cases. You can then use the forecasts from that model as predictors of your new model. Note however, that the added uncertainty from the forecasted regressor will not be represented in the forecasts for Y. – Mitchell O'Hara-Wild Aug 09 '20 at 03:39