My friends and I shared the simple exponential smoothing method, simple exponential smoothing can only predict those at a constant level and no seasonal changes in the time series, today and you share the non-constant level of growth or reduce the trend, The time series prediction algorithm without seasonal additive model---Holt exponential smoothing (Holt).
The Holt exponential smoothing method estimates the current time level and slope. Its smoothing level is controlled by two parameters, Alpha: Estimates the current point level, and beta: estimates the current point trend portion of the slope. Two parameters are between 0-1, and when the parameter is closer to 0, the weights of most recent observations will be smaller.
We use the 1866 to 1911 ladies skirt diameter as a case, we first input the data and draw out the sequence:
Skirts <-Scan ("Http://robjhyndman.com/tsdldata/roberts/skirts.dat", skip=5) skirtsseries <-ts (skirts,start=c (1866)) Plot.ts (skirtsseries)
It was observed that the sequence rose from 600 in 1866 to 1050 in 1880 and then down to 520 in 1911, again using the Holtwinters () in R for the Holt Exponential smoothing Prediction (gamma=false), and plotting the graphs of predictions and observations, To see the results of the predictions
Skirtsseriesforecasts <-holtwinters (skirtsseries, Gamma=false) plot (skirtsseriesforecasts)
Overall, the predictions are good (black is the original sequence, red is the predicted value), although they have a little delay in the observations. Also, we can view the sum of squared errors in the sample by variable Skirtsseriesforecasts$sse
The relevant predictive values are, for example, The alpha value is 0.84;beta with a predicted value of 1.0, these are very high values, fully showing the slope of the horizontal or the trend, the current value on the time series of the most recent observations on the dependence of heavy, the result is also consistent with our expectations, because the time series of the level and slope over the entire time period has undergone great changes. In addition we can specify the initial value of the level and trend through the parameters of "L.start" and "B.start" in the Holtwinters () function, the common set level initial value is the first value of the time series (608), the initial value of the slope is its second value minus the first value (9), The settings are as follows:
Holtwinters (Skirtsseries, Gamma=false, l.start=608, b.start=9)
We also use the forecast package to predict the values of future time nodes, assuming we predict the next 19 periods of data, the specific implementation and results are shown below:
Library ("forecast") skirtsseriesforecasts2 <-forecast. Holtwinters (skirtsseriesforecasts, h=19) plot.forecast (SKIRTSSERIESFORECASTS2)
The forecast section is marked with a blue line, a dark gray shaded area of 80%, and a light gray shaded area of 95%.
To test the results of the predictions, we also examined whether the prediction errors in the delay 1-20 order were non-zero autocorrelation, and continued to use the Ljung-box test:
ACF (Skirtsseriesforecasts2$residuals, lag.max=20) box.test (Skirtsseriesforecasts2$residuals, lag=20, type= " Ljung-box ")
The correlation diagram shows that the prediction error in the sample exceeds the confidence boundary in the 5-order lag, and the others are more than that, we think there are some occasional factors.
Ljung-box Test, p = 0.4749, meaning that the confidence level only 53% Such a value is not enough to reject the "prediction error in the 1-20 Order is non-zero autocorrelation, then we accept the prediction error in the 1-20 Order is non-zero autocorrelation.
also we verify that the test error conforms to the 0 mean normal distribution, we draw a time prediction error graph and a histogram with a normal curve prediction error distribution (this part borrows the plotforecasterrors function that we wrote last time ):
Plot.ts (skirtsseriesforecasts2$residuals) source ("PLOTFORECASTERRORS.R") plotforecasterrors ( Skirtsseriesforecasts2$residuals)
It is shown that the variance of the predicted error is roughly the same throughout the time period.
The prediction error is a normal distribution of 0 mean value by the prediction error histogram.
R language and Data analysis eight: Holt exponential smoothing method