'Hourly Forecasting using ARIMA
I want to forecast the hourly rate of electricity using ARIMA. But, I won't be able to set the ts function correctly which results in no forecasting in Arima. My data has 24 entries per day. My aim is to predict 2022-05-01 18:00:00
Please help.
Here is code: start date: 07/01/2015 1:00, end date: 4/26/2022 15:00
data$Category <- as.Date(data$Category, format = "%m/%d/%Y")
data <- data[order(data$Category), ]
Y <- ts(data[,2], start = c(2015,07,01), frequency = 365*23)
fit_arima <- auto.arima(Y, d=1, D=1, stepwise = FALSE, approximation = FALSE, trace = TRUE)
print(summary(fit_arima))
checkresiduals(fit_arima)
Data sample:
Category Series ID
07/01/2015 1:00 5244
07/01/2015 2:00 5152
07/01/2015 3:00 4948
07/01/2015 4:00 4485
07/01/2015 5:00 4231
07/01/2015 6:00 4158
07/01/2015 7:00 4324
07/01/2015 8:00 4686
07/01/2015 9:00 5060
07/01/2015 10:00 5347
07/01/2015 11:00 5504
07/01/2015 12:00 4368
07/01/2015 13:00 5440
07/01/2015 14:00 5280
07/01/2015 15:00 5227
07/01/2015 16:00 5195
07/01/2015 17:00 5195
07/01/2015 18:00 5252
07/01/2015 19:00 5200
07/01/2015 20:00 5228
07/01/2015 21:00 5244
07/01/2015 22:00 5277
07/01/2015 23:00 4517
08/01/2015 0:00 4629
08/01/2015 1:00 4996
08/01/2015 2:00 4910
08/01/2015 3:00 4655
08/01/2015 4:00 4230
08/01/2015 5:00 4000
08/01/2015 6:00 3943
08/01/2015 7:00 3907
08/01/2015 8:00 4830
08/01/2015 9:00 5298
08/01/2015 10:00 5638
08/01/2015 11:00 5874
08/01/2015 12:00 3910
08/01/2015 13:00 5864
08/01/2015 14:00 5943
08/01/2015 15:00 5893
08/01/2015 16:00 5744
08/01/2015 17:00 5573
08/01/2015 18:00 5392
08/01/2015 19:00 5290
08/01/2015 20:00 5231
08/01/2015 21:00 5152
08/01/2015 22:00 5063
08/01/2015 23:00 4125
Solution 1:[1]
The issue you may be having is that the frequency should be 24, not 365*23 since the cycle repeats every 24 rows/observations.
As a suggestion ARIMA has trouble with daily/hourly/yearly seasonality which is more than likely present with electricity usage.
If you are looking for an easy to operate forecasting model for hourly data consider TBATS (also in the forecast Package). It's a bit slow but it is very simple to use and handles multiple seasonality better. You could run both and see which one gives better forecast accuracy.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | alexrai93 |
