Holt-Winters filtering

We can similarly remove the seasonal effects of a time-series by Holt-Winters filtering. Setting the beta parameter of the HoltWinters function to FALSE will result in a model with exponential smoothing practically suppressing all the outliers; setting the gamma argument to FALSE will result in a non-seasonal model. A quick example:

> nts <- ts(daily$N, frequency = 7)
> fit <- HoltWinters(nts, beta = FALSE, gamma = FALSE)
> plot(fit)
Holt-Winters filtering

The red line represents the filtered time-series. We can also fit a double or triple exponential model on the time-series by enabling the beta and gamma parameters, resulting in a far better fit:

> fit <- HoltWinters(nts)
> plot(fit)
Holt-Winters filtering

As this model provides extremely similar values compared to our original data, it can be used to predict future values as well. For this end, we will use the forecast package. By default, the forecast function returns a prediction for the forthcoming 2*frequency values:

> library(forecast)
> forecast(fit)
         Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95
53.14286       634.0968 595.4360 672.7577 574.9702 693.2235
53.28571       673.6352 634.5419 712.7286 613.8471 733.4233
53.42857       628.2702 588.7000 667.8404 567.7528 688.7876
53.57143       642.5894 602.4969 682.6820 581.2732 703.9057
53.71429       678.2900 637.6288 718.9511 616.1041 740.4758
53.85714       685.8615 644.5848 727.1383 622.7342 748.9889
54.00000       541.2299 499.2901 583.1697 477.0886 605.3712
54.14286       641.8039 598.0215 685.5863 574.8445 708.7633
54.28571       681.3423 636.8206 725.8639 613.2523 749.4323
54.42857       635.9772 590.6691 681.2854 566.6844 705.2701
54.57143       650.2965 604.1547 696.4382 579.7288 720.8642
54.71429       685.9970 638.9748 733.0192 614.0827 757.9113
54.85714       693.5686 645.6194 741.5178 620.2366 766.9005
55.00000       548.9369 500.0147 597.8592 474.1169 623.7570

These are estimates for the first two weeks of 2012, where (besides the exact point predictions) we get the confidence intervals as well. Probably it's more meaningful at this time to visualize these predictions and confidence intervals:

> plot(forecast(HoltWinters(nts), 31))
Holt-Winters filtering

The blue points shows the estimates for the 31 future time periods and the gray area around that covers the confidence intervals returned by the forecast function.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.247.11