rtime-seriesarimaforecastfable-r

How to specify annual seasonality for an ARIMA model of fable


I am having trouble specifying seasonality in an ARIMA model of the fable package. I have a dataset with daily data and want to take into account annual seasonality. I make use of the Daily Electricity Price and Demand Data which can be found on Kaggle.

df <- read.csv("complete_dataset.csv")
df <- as_tibble(df)

df_t <- df %>% mutate(date = as_date(date),
                    school_day = if_else(school_day == "Y", 1, 0),
                    holiday = if_else(holiday == "Y", 1, 0))
df_ts <- as_tsibble(df_t, index = date)

arima_model2 <- df_ts %>% model(ARIMA(demand ~ max_temperature + PDQ(period=365.25)))
report(arima_model2)

## Warning: 1 error encountered for ARIMA(demand ~ max_temperature + PDQ(period = 365.25))
## [1] not all series have the same phase

## Series: demand 
## Model: NULL model 
## NULL model

I've also tried period = "1 year", but that gives the same error.

Is there a way to fix this? Or should this be specified in another way?

Thanks!


Solution

  • Without a reproducible example, it is hard to know what has happened here.

    To take account of annual seasonality in an ARIMA model for daily data, you would be much better off using Fourier terms than trying to add seasonal ARIMA terms with a large period. For a start, seasonal ARIMA components need an integer period. Also, they use lagged values at multiples of the seasonal period, and referencing observations a year (or several years) in the past is a very inefficient way to handle seasonality. Finally, the estimation is exceedingly slow (or will return an error) for ARIMA models with large seasonal periods.

    There is an example that uses Fourier terms with half-hourly electricity demand data at https://otexts.com/fpp3/complexseasonality.html#example-electricity-demand. You could easily adapt that to your situation with daily data.