Examples / GRAPHFORECAST.RPF |
GRAPHFORECAST.RPF is an example of graphical display of forecasts.
It uses ESMOOTH (exponential smoothing) to forecast Japanese total retail sales. The data are monthly from 1960:1 to 2006:12.
cal(m) 1960:1
open data oecdsample.rat
data(format=rats) 1960:1 2006:12 jpniptotrs
This uses ESMOOTH with an automatically selected model to forecast 24 periods out-of-sample. The forecasts are put into the series JPNFORE.
esmooth(trend=select,seasonal=select,forecast=jpnfore,steps=24) jpniptotrs
This inserts the final actual value of the data at the beginning for the JPNFORE series:
set jpnfore 2006:12 2006:12 = jpniptotrs
Finally, this forecasts the actual data from the final three years (2004:1 to 2006:12), with the forecast data starting at 2006:12 (which was the final actual) through 2008:12. A vertical grid line is added at the 2006:12 entry to show the end of the data.
graph(header="Forecasts of Japanese IP",grid=(t==2006:12)) 2
# jpniptotrs 2004:1 2006:12
# jpnfore 2006:12 2008:12
Full Program
cal(m) 1960:1
open data oecdsample.rat
data(format=rats) 1960:1 2006:12 jpniptotrs
*
* Use ESMOOTH with automatically selected model to forecast 24 periods
* out of sample. Add the final actual to the period before the forecasts
* start and put a grid line at the last actual data point.
*
esmooth(trend=select,seasonal=select,forecast=jpnfore,steps=24) jpniptotrs
set jpnfore 2006:12 2006:12 = jpniptotrs
graph(header="Forecasts of Japanese IP",grid=(t==2006:12)) 2
# jpniptotrs 2004:1 2006:12
# jpnfore 2006:12 2008:12
Graph
Output (from the ESMOOTH choosing the model)
Exponential Smoothing for Series JPNIPTOTRS
Model Selection
TREND SEASONAL SumSquares SBC
None None 3668.45317 1062.4
None Additive 3827.11790 1092.6
None Multiplicative 4182.33142 1142.7
Linear None 551.21387 -0.3
Linear Additive 541.19230 -4.3
Linear Multiplicative 577.28163 32.1
Exponential None 630.73239 75.7
Exponential Additive 642.43559 92.4
Exponential Multiplicative 650.68991 99.6
Model with TREND=Linear , SEASONAL=Additive
Alpha (level) 0.631238
Gamma (trend) 0.285467
Delta (seasonal) -0.045443
Copyright © 2025 Thomas A. Doan