# Holt-Winters function hw() in R

I would like to use the hw method from the R forecast package to predict electricity consumption. I tried to use it on the taylor dataset available in the package. I'm trying to get the same results reported in the paper Taylor, J.W. (2003) Short-term electricity demand forecasting using double seasonal exponential smoothing. Journal of the Operational Research Society, 54, 799-805., but when I use function ts() with frequency $= 48$ (daily seasonality, half-hourly data) I get the error

"Error in ets(x, "MAM", alpha = alpha, beta = beta, gamma = gamma, phi = phi,  :
Frequency too high"


I found that function ets() can just deal with maximum frequency $= 24$, but I would like to know how to solve this, which other function can I use or how can I get the results shown in Taylor 2003.

The author of ets() discusses why it limits seasonality to length 24 here.

You can try using ARIMA instead, per Hyndman. I believe you want to model two different seasonal cycles-- hourly, with seasonal length of 48, and day of week, with seasonal length of 7. Combining those and having one seasonal cycle of 336 probably won't work well, per Hyndman.

To get ets() to work, you could split your data into AM/PM. That will reduce each to 24 periods.

• Very helpful. Also I think I could use HoltWinters() function and then predict 1 day-ahead (48 observations) and calculate the MAPE to compare with the ARIMA. Thanks! Aug 10 '18 at 18:50

The Taylor paper uses double seasonal Holt Winters models, which are implemented in the dshw() function in the forecast package. The help file provides an example applying dshw() to the taylor data set:

library(forecast)
fcast <- dshw(taylor)
autoplot(fcast)


• Great. The Taylor paper also uses a training set of 8 weeks and a testing set of 4 weeks, and the calculates the MAPE for h=1,...48 periods ahead. How can I make the code in R to obtain the same results of that paper? I was reading your book, otexts.org/fpp2/forecasting-on-training-and-test-sets.html and trying to do something similar, but I'm not sure Aug 11 '18 at 9:19