I am trying to implement Holt-Winters exponential smoothing in Java program (I understand that R and Python have implementations of these algorithms, but I can't use those due to other reasons, so they are ruled out).

I have been going through Rob J. Hyndman's book and formula. I am trying to execute the following formula on my sample data manually, but I'm having a hard time understanding some of the notations. If I can run it manually, I can start implementing in code:

Let us say we have 12 data points (Monthly data for a year): 8,9,10,7,9,10,9,8,9,8

The last 8 in this data represents current month data, and I want to forecast the next 3 months' values (which will be something like 9,9,8, I assume). How can I use the formula listed in the above link to get these values is the part with which I am struggling.

Specially I am not clear with two things:

  1. What does $\hat{y}_{t+h|t}$ represent? Is it next month's value (or) next value from the starting point?

  2. How can I calculate the $s_{t-m+h_m^+}$ value?

Any pointers to get started on manual calculation would be appreciated. Thanks for your time and help.

  • $\begingroup$ $\hat{y}_{t+h|t}$ means "the forecast at time $t+h$, given data up to time $t$". So no, it's not the next-period forecast (unless $h=1$), it's the forecast for $h$ periods ahead from time $t$, using information available at time $t$. $\endgroup$ – Glen_b Feb 26 '14 at 4:44
  • $\begingroup$ @Glen_b: Thank you! I will work on this tomorrow. Hopefully I can finish this time. $\endgroup$ – kosa Feb 26 '14 at 4:49
  • $\begingroup$ I'd use the error-correction formula, and the starting values from table 7.9. The $s$ term is easier to understand if you follow through the example. $\endgroup$ – Glen_b Feb 26 '14 at 4:53
  • $\begingroup$ @Glen_b: I think I am getting clarity on what is going on here, but stuck at point on how s(t) is 10.3 for first row in this case? Based on formula, I think L(t-1), b(t-1) and s(t-m) are zero for this row right? Which should bring s(t) to ZERO. Any input here? $\endgroup$ – kosa Feb 26 '14 at 18:39

I made code for python that can be found here if you want to check it out. It is fairly easy to understand.

y(t+h) is the last point of data you have with the addition of h steps ahead. For example if you forecast 3 months ahead it would be at point t +3

What I used to make my code was the NIST site.

For your second question I think you are calculating the seasonal data. I am not sure what you mean by s((t-m)+hm+).

If you do not want to implement it yourself here is a java implementation I found

  • 1
    $\begingroup$ s((t-m)+hm+) referred to $s_{t-m+h_m^+}$ in $\hat{y}_{t+h|t} = \ell_{t} + hb_{t} + s_{t-m+h_m^+}$. $\endgroup$ – Nick Stauner Feb 26 '14 at 2:27
  • $\begingroup$ @ccsv: Thanks for the java implementation link, I found few other implementations too. To be frank I want to do it manually on paper before to understand the algorithm before picking on any implementation, that gives me flexibility to modify code as required. Thanks for your links though. If any other links which explains algorithm step by step, that would be really helpful. $\endgroup$ – kosa Feb 26 '14 at 3:49
  • $\begingroup$ @Nambari Then basically follow the NIST site Here: itl.nist.gov/div898/handbook/pmc/section4/pmc435.htm $\endgroup$ – ccsv Feb 26 '14 at 3:58
  • 1
    $\begingroup$ @Nambari You will want to have a way to deal with remainders in step 2 and 3 for seasonal data or else you will only be able to predict X steps at a time, where X is the length of your period. I fixed this at line 180 of my code. That is the only different thing $\endgroup$ – ccsv Feb 26 '14 at 4:05
  • $\begingroup$ @ccsv: Thanks for those valuable pointers. I will work on these tomorrow. $\endgroup$ – kosa Feb 26 '14 at 4:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.