0

I have to create hourly forecasts for 2000 different time series. And I have strong hourly and weekly seasonality in my series. To deal with hourly seasonality I used season("day") option. However, I suppose season("week") would create 168 weekly dummies and that would be problem on computional problem.

Do you know a quick way to create dayofweek dummies using tsibble or fabletools packages.

ts_forecast1 <- train%>% filter(store_number==288) %>% collect()%>% 
mutate(store_number = factor(store_number)) %>% group_by(store_number) %>%  
filter(sales!=0) %>% tsibble::fill_gaps(sales=100) %>%
fabletools::model(Arima = ARIMA(log(sales) ~  season("day") +fourier("week", K = 8)))
omzeybek
  • 305
  • 2
  • 14

1 Answers1

2

Your code already contains the answer.

season("day") will create 23 dummy variables since there are 24 hours in a day. season("week") will create 167 dummy variables for the 168 hours in a week. To use fewer coefficients, replace season() with fourier() and use K to control the number of coefficients (equal to twice K).

Rob Hyndman
  • 30,301
  • 7
  • 73
  • 85
  • I think most important problem here is to finding right K for the algorithm. There were some examples on solving seasonality issues with fourier() on your book, https://otexts.com/fpp2/complexseasonality.html/ but I am still unsure for the right level. Although I have used the for loop given in the book to find most accurate K I couldn't run the loop because of number of coefficient restrictions. I am using tsibble object with hourly data but I am still receiving K must be not be greater than period/2 error – omzeybek Nov 01 '20 at 08:13