[R] HoltWinters Forecasting

RobertNZ rabbi021 at gmail.com
Mon Jan 11 23:50:19 CET 2010


Hi R-users,

I have a question relating to the HoltWinters() function.  I am trying to
forecast a series using the Holt Winters methodology but I am getting some
unusual results. I had previously been using R for Windows version 2.7.2 and
have just started using R 2.9.1.  While using version 2.7.2 I was getting
reasonable results however upon changing versions I found I started to see
unusual results.  If anybody would be able provide assistance with this it
would be much appreciated!

The series in question is ‘x’ below.

x = c(18, 18, 16, 19, 12, 12, 13, 12, 7, 9, 9, 9, 12.5, 16, 20,
    22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23,
    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
    23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 22, 17, 10,
    10, 10, 10, 10, 10, 10, 10, 10, 10, 14, 14, 14, 14, 14, 14,
    14, 14, 14, 14, 14, 14, 14, 14, 14, 14.5, 15, 14, 14, 14,
    14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
    14, 14, 14, 14, 14, 14, 14, 14, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
    9, 9, 9, 9, 9, 9, 6, 5, 5, 5)

x.ts = ts(data = x, start = c(1999,1), frequency = 12)

## USING R 2.9.1 I get the following results using HoltWinters().  I see
that the smoothing parameters are greater than 1 for alpha and beta which I
believe is unusual as I think the optim() function that is used to calculate
these  
## parameters in HoltWinters() should constrain the results to [0,1]? 

hw.ts = HoltWinters(x.ts)
hw.ts

Holt-Winters exponential smoothing with trend and additive seasonal
component.

Call:
 HoltWinters(x = x.ts) 

Smoothing parameters:
 alpha:  1.046340 
 beta :  3.198345 
 gamma:  1 

Coefficients:
             [,1]
a   -6.491044e+44
b   -3.313740e+46
s1  -4.035877e+40
s2   9.734997e+40 
s3  -2.348192e+41
s4   5.664108e+41
s5  -1.366248e+42
s6   3.295545e+42
s7  -7.949232e+42
s8   1.917446e+43
s9  -4.625098e+43
s10  1.115626e+44
s11 -2.691018e+44
s12  6.491044e+44

Subsequently using the predict() function the following results are produced
which are quite unusual.

> x.pred = predict(hw.ts, n.ahead = 10,
+          prediction.interval = T, conf.level = 0.8)
> 
> x.pred
                   fit           upr           lwr
Jan 2010 -3.378655e+46 -3.102583e+46 -3.654726e+46
Feb 2010 -6.692381e+46 -5.448602e+46 -7.936160e+46
Mar 2010 -1.000615e+47 -7.533863e+46 -1.247845e+47
Apr 2010 -1.331981e+47 -9.385468e+46 -1.725416e+47
May 2010 -1.663375e+47 -1.103422e+47 -2.223327e+47
Jun 2010 -1.994702e+47 -1.250080e+47 -2.739324e+47
Jul 2010 -2.326189e+47 -1.380352e+47 -3.272025e+47
Aug 2010 -2.657291e+47 -1.494943e+47 -3.819640e+47
Sep 2010 -2.989320e+47 -1.596167e+47 -4.382472e+47
Oct 2010 -3.319116e+47 -1.681697e+47 -4.956534e+47


### Applying the same code to time series x.ts using R 2.7.2 yields the
following results

> hw.ts = HoltWinters(x.ts)
> hw.ts
Holt-Winters exponential smoothing without trend and with additive seasonal
component.

Call:
 HoltWinters(x = x.ts) 

Smoothing parameters:
 alpha:  0.8560487 
 beta :  0 
 gamma:  1 

Coefficients:
          [,1]
a    6.3820972
s1  -1.6592841
s2  -1.4172832
s3  -0.3896275
s4   1.1195576
s5   1.3899338
s6   1.8304666
s7   1.3751008
s8   0.5919732
s9  -0.5971810
s10 -0.7390197
s11 -1.0104958
s12 -1.3820972

The subsequent forecast this time is more reasonable

> x.pred
              fit       upr        lwr
Jan 2010 4.722813  7.943789  1.5018372
Feb 2010 4.964814  9.204797  0.7248308
Mar 2010 5.992470 11.050160  0.9347798
Apr 2010 7.501655 13.262123  1.7411862
May 2010 7.772031 14.158405  1.3856573
Jun 2010 8.212564 15.168751  1.2563766
Jul 2010 7.757198 15.239932  0.2744638
Aug 2010 6.974070 14.948660 -1.0005194
Sep 2010 5.784916 14.222739 -2.6529065
Oct 2010 5.643078 14.519993 -3.2338377


It would be much appreciated if anyone could help me with understanding why
I am seeing these unusual results when using R 2.9.1 compared with R 2.7.2?
I wonder if there is something that I have not considered or if there are
any remedies that I could take to fix this? 

Thanks in advance,
Robert

-- 
View this message in context: http://n4.nabble.com/HoltWinters-Forecasting-tp1011652p1011652.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list