R Language and Data Analysis IX: Holtwinters Exponential Smoothing method

Source: Internet
Author: User

Today goes on to the most complex time series in exponential smoothing: a predictive algorithm that has a time series of increasing or decreasing trends and having seasonal fluctuations is holt-winters and shared with everyone. This sequence can be decomposed into the horizontal trend part, the seasonal fluctuation part, therefore these two factors should have the corresponding parameter to control in the algorithm.

The holt-winters algorithm provides alpha, beta, and gamma to correspond to the horizontal, trend, and seasonal portions of the current point, respectively, and the parameter's de-enforcement range is 0-1, and the parameters are close to 0 o'clock, and the less powerful the recent observations are. We take the Australian Queensland, State Of Seaside commemorative merchandise monthly sales day as the analysis object, the old routine, we first input the data, and draw out this time series, fished a whole impression:

Souvenir <-Scan ("Http://robjhyndman.com/tsdldata/data/fancy.dat") souvenirtimeseries <-ts (Souvenir, Frequency=12, Start=c (1987,1)) logsouvenirtimeseries <-log (souvenirtimeseries) plot.ts (logsouvenirtimeseries)


We use the Holtwinters algorithm provided in R to predict, achieve and result as follows:

Souvenirtimeseriesforecasts <-holtwinters (logsouvenirtimeseries)

alpha=0.4 means that the current forecast is based on a balance between the most recent and long-term observations. Beta 0 indicates that the slope of the trend part is listed unchanged throughout the time series and is equal to the initial value, this also conforms to our intuitive feeling, the level changes very much, but the trend part slope is basically invariable, on the contrary gamma=0.96 indicates that the current season partial forecast is based only on the nearest observation value.

We also draw the predicted values and observations to see how the predictions are performing:

Plot (souvenirtimeseriesforecasts)

The holt-winters algorithm is very successful in predicting seasonal peaks, and in order to predict the value of future periods, we also use the forecast function package to predict sales for the next 48 months as an example:

Library ("forecast") souvenirtimeseriesforecasts2 <-forecast. Holtwinters (souvenirtimeseriesforecasts, h=48) plot.forecast (SOUVENIRTIMESERIESFORECASTS2)


The Blue line in the figure shows the predicted value, the dark gray part is 80% confidence interval, the light gray is 95 confidence interval.

The next old routine use Ljung-box and draw histogram to check the randomness of the prediction error, do not repeat the code, there are forgotten children shoes Please turn the first two, I here directly paste the results of the map:

The result of the three graph shows that the holt-winters () algorithm provided by us is a special bull break, and the exponential smoothing is completely over.



R Language and Data Analysis IX: Holtwinters Exponential Smoothing method

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.