* * Example TABLE4-1.DAT from pp 149-159 * open data table4-1.dat data(format=free,org=columns) 1 24 time data * filter(type=lagging,width=2) data / ma2 filter(type=lagging,width=4) data / ma4 filter(type=lagging,width=8) data / ma8 * * The forecasts are just the lagged smoothed value * set ma2fore = ma2{1} set ma4fore = ma4{1} set ma8fore = ma8{1} * * These compute the forecast error statistics over the period 9 to 24 (which is * common among all the MA forecasts. Note that the RMSE reported here is slightly * different from the one in the text, because it uses an n divisor, rather than * n-k. * @uforeerrors(title="MA(2) forecasts") data ma2fore 9 24 @uforeerrors(title="MA(4) forecasts") data ma4fore 9 24 @uforeerrors(title="MA(8) forecasts") data ma8fore 9 24 * * Figure 4-1. Graphs of the actual data along with the moving average forecasts. * graph(style=line,footer="Figure 4-1. Two-, four- and eight-period moving averages",key=loright) 4 # data 9 * # ma2fore 9 * # ma4fore 9 * # ma8fore 9 * * * The weighted moving average is done by using the option WEIGHTS=||list of * weights||. If you would rather just put in the shape of the weights, and have * them automatically scaled to sum to one, include the option UNITSUM. For * instance, here you could also do WEIGHTS=||4,3,2,1||,UNITSUM. * filter(type=lagging,weights=||.4,.3,.2,.1||) data / wma set wmafore = wma{1} @uforeerrors(title="Weighted MA") data wmafore 9 24 * * Figure 4-2 * graph(footer="Figure 4-2. Four-period simple versus four-period weighted moving average") 3 # data 9 * # ma4fore 9 * # wmafore 9 * * * Exponential smoothing is done with the instruction ESMOOTH. The in-sample * one-step forecasts are obtained with the FITTED option. (The FORECASTS option * is used for out-of-sample forecasts). * esmooth(alpha=0.1,fitted=es1fore) data esmooth(alpha=0.6,fitted=es6fore) data esmooth(alpha=0.9,fitted=es9fore) data * @uforeerrors(title="ES with alpha=.1") data es1fore 9 24 @uforeerrors(title="ES with alpha=.6") data es6fore 9 24 @uforeerrors(title="ES with alpha=.9") data es9fore 9 24 * graph(footer="Figure 4-3. Single exponential smoothing with various alpha values",key=upleft) 4 # data 9 * # es1fore 9 * # es6fore 9 * # es9fore 9 *