I’m currently using PROC ESM for exponential smoothing modeling using Holt-Winters “Additive” type methods for time series data sets with (and without) trend and with (and without) seasonality.
Question: Is there an ESM option (or another procedure) that will print out the “back-casting” details in a similar manner as with using the ESM’s “print=forecast” option?
For no-trend (model=simple) and no-trend w/seasonality (model=addseasonal), my EXCEL calculations always match the back-casting “state” values that I get from my SAS program. However, when I add a trend component to the model, my “final” back-casting state values no longer match – even assuming the same alpha, gamma and delta parameters, and starting values as SAS. I’ve already read the “Smoothing State Initialization” documentation.
My Code:
proc esm data=a print=(estimates forecasts performance statistics states) printdetails
lead=1
out=out_a outest=outest_a outfor=outfor_a outstat=outstat_a;
forecast customers / model=linear;
title3 'ESM Procedure';
run;
State Level Trend
Backcast 4,021 185.963235
Starting 810.20902 185.832622
Final 3,990.30259 185.849896
Using the above example for reference, what I need to see is SAS’s calculation flow from the initial Backcast state (4021/185.963235) to the “starting” forward’s modeling values at t=0 (810.20902/185.832622).
Thanks in advance!
Hi Dwayne,
PROC ESM does not provide a way to output the backcast values used to obtain the Starting Level and Trend values for the Linear exponential smoothing model, however, the smoothing calculations for the backcasts are essentially the same as the smoothing calculations for the "forwards casting". These smoothing calculations are described in the following section of the SAS/ETS User's Guide:
Equations for the Smoothing Models:
Please note, however, that for backcasting, the sign of the initial trend parameter is reversed, since the series is sorted in reverse order. Following, please find a description of the methodology used to compute the backcasts for MODEL=LINEAR in PROC ESM:
1) Add a time trend variable to the original data set, for example, "t", which is simply the observation number 1, 2, ..., n.
2) Obtain the initial Level and Slope values:
3) Sort the data, descending, by the time trend variable.
4) Backcast using the reverse-ordered data:
5) Continue with smoothing computations through reverse ordered series using the equations noted in the above link.
6) To obtain the Starting Level and Trend values from the backcasts, go to the last observation from step 5)
I hope this description helps, Dwayne!
DW
Hi Dwayne,
PROC ESM does not provide a way to output the backcast values used to obtain the Starting Level and Trend values for the Linear exponential smoothing model, however, the smoothing calculations for the backcasts are essentially the same as the smoothing calculations for the "forwards casting". These smoothing calculations are described in the following section of the SAS/ETS User's Guide:
Equations for the Smoothing Models:
Please note, however, that for backcasting, the sign of the initial trend parameter is reversed, since the series is sorted in reverse order. Following, please find a description of the methodology used to compute the backcasts for MODEL=LINEAR in PROC ESM:
1) Add a time trend variable to the original data set, for example, "t", which is simply the observation number 1, 2, ..., n.
2) Obtain the initial Level and Slope values:
3) Sort the data, descending, by the time trend variable.
4) Backcast using the reverse-ordered data:
5) Continue with smoothing computations through reverse ordered series using the equations noted in the above link.
6) To obtain the Starting Level and Trend values from the backcasts, go to the last observation from step 5)
I hope this description helps, Dwayne!
DW
Thank you for the quick response. I tried what you said, but the sum of the adjusted seasonal index values is not zero. Here is my time series:
z | t | s1 | s2 | s3 |
17754 | 1 | 1 | 0 | 0 |
18220 | 2 | 0 | 1 | 0 |
18223 | 3 | 0 | 0 | 1 |
18047 | 4 | 0 | 0 | 0 |
19030 | 5 | 1 | 0 | 0 |
19122 | 6 | 0 | 1 | 0 |
18921 | 7 | 0 | 0 | 1 |
19023 | 8 | 0 | 0 | 0 |
19147 | 9 | 1 | 0 | 0 |
19397 | 10 | 0 | 1 | 0 |
19405 | 11 | 0 | 0 | 1 |
19605 | 12 | 0 | 0 | 0 |
20181 | 13 | 1 | 0 | 0 |
20067 | 14 | 0 | 1 | 0 |
20708 | 15 | 0 | 0 | 1 |
20476 | 16 | 0 | 0 | 0 |
20247 | 17 | 1 | 0 | 0 |
20351 | 18 | 0 | 1 | 0 |
21393 | 19 | 0 | 0 | 1 |
21590 | 20 | 0 | 0 | 0 |
21236 | 21 | 1 | 0 | 0 |
The regression results are:
Coeffients | |
b0 | 17669,01053 |
b1 | 173,2657895 |
s1 | 24,23245614 |
s2 | 29,73157895 |
s3 | 155,0657895 |
Adjusted seasonal index values:
unadjusted | adjusted | |
24,23245614 | 93,90906433 | s1 |
29,73157895 | 99,40818713 | s2 |
155,0657895 | 224,7423977 | s3 |
-69,67660819 | s4 | |
mean | ||
69,67660819 |
Am I doing something wrong?
Thanks again. Now I have my backcasting results (attached as an excel file) and need the initial values for Level, Trend, and Seasonal Index Values in the forecasting step. I know that I will use the original order of my time series. What should the initial values be regarding to the backcasting results?
Thanks again, but why is that your backcasting results are different than mine? Were there any mistakes in my excel file? You say the following, but how did you get those values?
From My EXECL calculations:
S1 = -27.13818
S2 = -21.86446
S3 = 103.519
S4 = -51.49149
Even if I use the weights you mention, I cannot get those results. My trend value after backcasting is also different than yours (Mine is 173.248441693523, yours is 173.081). Am I missing some point? Could you explain it by looking at backcasting results?
Question: Did you create a SAS program / PROC ESM to double check your calculations? If not, I highly recommend that you do so. While SAS doesn’t provide a detailed running calculation summary for it’s backcasting, it does do so for the “foreward casting” portion of the analysis. You can use that to double check that your EXCEL formulas are correct, since the only difference is that the trend must be multiplied by -1 and – instead – of calculating things for observations 21 to 1, calculations are given for observations 1 to 21.
I have attached the SAS output.
BACKCASTING (Partial EXCEL)
ꚙ (constant) | ϒ (trend) | ꝺ (seasonal) | ❺-❶ | |||||||||
.072110 | .001000 | .001000 | ||||||||||
Year | Time Period | Time Index | Actual #Disks Sold (y) | Projected #Disks Sold (ŷ) | et | Model Constant (at T) | Trend (at T) | Seasonal Time Index | Seasonal Index (Additive) | Model Constant - Trend (at T+1) | Projected Sales (ŷ)T+1 | |
1 | -28.025000 | |||||||||||
4 | -52.257456 | |||||||||||
3 | 102.808333 | |||||||||||
21236.000 | -173.26579 | 2 | -22.525877 | 21062.734 | 21034.709 | |||||||
2021 | I | 21 | 21236 | 21034.709 | 201.29079 | 21077.249 | -173.251 | 1 | -27.83822 | 20903.998 | 20851.741 | |
2020 | IV | 20 | 21590 | 20851.741 | 738.25944 | 20957.234 | -173.198 | 4 | -51.57243 | 20784.036 | 20886.844 | |
2020 | III | 19 | 21393 | 20886.844 | 506.15580 | 20820.535 | -173.162 | 3 | 103.27799 | 20647.373 | 20624.847 | |
2020 | II | 18 | 20351 | 20624.847 | -273.84734 | 20627.626 | -173.181 | 2 | -22.77998 | 20454.445 | 20426.607 |
......
2016 | IV | 4 | 18047 | 18312.625 | -265.62512 | 18344.716 | -173.041 | 4 | -51.49149 | 18171.675 | 18275.243 | |
2016 | III | 3 | 18223 | 18275.243 | -52.24284 | 18167.908 | -173.044 | 3 | 103.51900 | 17994.864 | 17972.770 | |
2016 | II | 2 | 18220 | 17972.770 | 247.23005 | 18012.692 | -173.026 | 2 | -21.86446 | 17839.665 | 17812.581 | |
2016 | I | 1 | 17754 | 17812.581 | -58.58127 | 17835.441 | -173.031 | 1 | -27.13818 | 17662.410 | 17610.919 | |
Re-Normalization | 3.024881 |
FORECASTING (PARTIAL EXCEL)
(note the sign reversal in the trend and the required adjustment in the seasonal values)
Year | Time Period | Time Index | Actual Hits (y) | Projected Hits (ŷ) | et | Model Constant (at T) | Trend (at T) | Seasonal Time Index | Seasonal Index (Additive) | Model Constant + Trend (at T+1) | Projected Hits (ŷ)T+1 | |
-27.8944 | 1 | -27.894400 | ||||||||||
-22.62068 | 2 | -22.620700 | ||||||||||
102.76278 | 3 | 102.762800 | ||||||||||
-52.24771 | 17663.159 | 173.0307 | 4 | -52.247700 | 17836.190 | 17808.296 | ||||||
2016 | I | 1 | 17754 | 17808.296 | -54.296 | 17832.275 | 173.0268 | 1 | -27.94478 | 18005.301 | 17982.681 | |
2016 | II | 2 | 18220 | 17982.681 | 237.319 | 18022.415 | 173.0439 | 2 | -22.40049 | 18195.458 | 18298.221 | |
2016 | III | 3 | 18223 | 18298.221 | -75.221 | 18190.034 | 173.0385 | 3 | 102.69300 | 18363.073 | 18310.825 | |
2016 | IV | 4 | 18047 | 18310.825 | -263.825 | 18344.048 | 173.0195 | 4 | -52.49250 | 18517.068 | 18489.123 |
........
2020 | II | 18 | 20351 | 20783.704 | -432.704 | 20774.558 | 173.0271 | 2 | -22.45757 | 20947.585 | 21050.184 | |
2020 | III | 19 | 21393 | 21050.184 | 342.816 | 20972.305 | 173.0518 | 3 | 102.91754 | 21145.357 | 21092.792 | |
2020 | IV | 20 | 21590 | 21092.792 | 497.208 | 21181.210 | 173.0876 | 4 | -52.10312 | 21354.298 | 21326.674 | |
2021 | I | 21 | 21236 | 21326.674 | -90.674 | 21347.760 | 173.0811 | 1 | -27.70850 | 21520.841 | 21498.383 |
After your detailed message, I noticed that I made 2 big mistakes. They can be seen from the excel file I uploaded in my previous message.
1) The order of the seasonal index values was wrong.
2) The formula for Model Constant was wrong.
Now, I have the same results with you. Thanks a lot.
Could you please suggest me a source about this subject? Do you figure out the formulas just by looking at the SAS results? Do you follow a source to solve the problem?
Thanks again. I am sorry that I have taken lots of your time.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.
Find more tutorials on the SAS Users YouTube channel.