The UCM Procedure

Example 42.3 Modeling Long Seasonal Patterns

(View the complete code for this example.)

This example illustrates some of the techniques you can use to model long seasonal patterns in a series. If the seasonal pattern is of moderate length and the underlying dynamics are simple, then it is easily modeled by using the basic settings of the SEASON statement and these additional techniques are not needed. However, if the seasonal pattern has a long season length and/or has a complex stochastic dynamics, then the techniques discussed here can be useful. You can obtain parsimonious models for a long seasonal pattern by using an appropriate subset of trigonometric harmonics, or by using a suitable spline function, or by using a block-season pattern in combination with a seasonal component of much smaller length. You can also vary the disturbance variances of the subcomponents that combine to form the seasonal component.

The time series used in this example consists of number of calls received per shift at a call center. Each shift is six hours long, and the first shift of the day begins at midnight, resulting in four shifts per day. The observations are available from December 15, 1999, to April 30, 2000. This series is seasonal with season length 28, which is moderate, and in fact there is no particular need to use pattern approximation techniques in this case. However, it is adequate for demonstration purposes. The plan of this example is as follows. First an initial model with a full seasonal component is created. This model is used as a baseline for comparing alternate models created by the techniques that are being illustrated. In practice any candidate model is first checked for adequacy by using various diagnostic procedures. In this illustration the main focus is on the different ways a long seasonal pattern can be modeled and no model diagnostics are done for the models being entertained. The alternate models are compared by using the sum of absolute prediction errors in the holdout region.

The following DATA step statements create the input data set used in this example:

data callCenter;
   input calls @@;
   label calls= "Number of Calls Received in a 6 Hour Shift";
   start = '15dec99:00:00'dt;
   datetime = INTNX( 'dthour6', start, _n_-1 );
   format datetime datetime10.;
datalines;
  18    122    244    128     19    113    230    119     17    112
 219     93     14     73    139     53     11     32     74     56
  15    137    289    153     20    125    227    106     16    101
 201     92     14     94    187     69     11     59     94     21

   ... more lines ...   

Initial exploration of the series clearly indicates that the series does not show any significant trend, and time of day and day of the week have a significant influence on the number of calls received. These considerations suggest a simple random walk trend model along with a seasonal component of season length 28, the total number of shifts in a week. The following statements specify this model. Note the PRINT=HARMONICS option in the SEASON statement, which produces a table that lists the full set of harmonics contributing to the seasonal along with the significance of their contribution. This table will be useful later in choosing a subset trigonometric model. The BACK=28 and LEAD=28 specifications in the FORECAST statement create a holdout region of 28 observations. The sum of absolute prediction errors (SAE) in this holdout region is used to compare the different models.

proc ucm data=callCenter;
   id datetime interval=dthour6;
   model calls;
   irregular;
   level;
   season length=28 type=trig
      print=(harmonics);
   estimate back=28;
   forecast back=28 lead=28;
run;

The forecasting performance of this model in the holdout region is shown in Output 42.3.1. The SAE is 516.22, which appears in the last row of the holdout analysis table.

Output 42.3.1: Predictions in the Holdout Region: Baseline Model

ObsdatetimeActualForecastErrorSAE
52524APR00:0012-4.00416.00416.004
52624APR00:06136110.82525.17541.179
52724APR00:12295262.82032.18073.360
52824APR00:18172145.12726.873100.232
52925APR00:00202.18817.812118.044
53025APR00:06127105.44221.558139.602
53125APR00:12236217.04318.957158.559
53225APR00:18125114.31310.687169.246
53326APR00:00162.85513.145182.391
53426APR00:0610895.20212.798195.189
53526APR00:12207194.18412.816208.005
53626APR00:1811297.68714.313222.317
53727APR00:00151.27013.730236.047
53827APR00:069885.87512.125248.172
53927APR00:12200184.89115.109263.281
54027APR00:1811393.11319.887283.168
54128APR00:0015-1.12016.120299.288
54228APR00:0610484.98319.017318.305
54328APR00:12205177.94027.060345.365
54428APR00:188964.29224.708370.073
54529APR00:0012-6.02018.020388.093
54629APR00:066846.28621.714409.807
54729APR00:12116100.33915.661425.468
54829APR00:185434.70019.300444.768
54930APR00:0010-6.20916.209460.978
55030APR00:063012.16717.833478.811
55130APR00:126649.52416.476495.287
55230APR00:186140.07120.929516.216


Now that a baseline model is created, the exploration for alternate models can begin. The review of the harmonic table in Output 42.3.2 shows that all but the last three harmonics are significant, and deleting any of them to form a subset trigonometric seasonal component will lead to a poorer model. The last three harmonics, 12th, 13th, and 14th, with periods of 2.333, 2.15 and 2.0, respectively, do appear to be possible choices for deletion. Note that the disturbance variance of the seasonal component is not very insignificant (see Output 42.3.3); therefore the seasonal component is stochastic and the preceding logic, which is based on the final state estimate, provides only a rough guideline.

Output 42.3.2: Harmonic Analysis of the Season: Initial Model

The UCM Procedure

Harmonic Analysis of Trigonometric Seasons (Based on the Final State)
NameSeason LengthHarmonicPeriodChi-SquareDFPr > ChiSq
Season28128.00000234.192<.0001
Season28214.00000264.192<.0001
Season2839.3333395.652<.0001
Season2847.00000105.642<.0001
Season2855.60000146.742<.0001
Season2864.66667121.932<.0001
Season2874.000004299.122<.0001
Season2883.50000150.792<.0001
Season2893.1111189.682<.0001
Season28102.800008.9520.0114
Season28112.545456.1420.0464
Season28122.333332.2020.3325
Season28132.153853.4020.1828
Season28142.000002.3310.1272


Output 42.3.3: Parameter Estimates: Initial Model

Final Estimates of the Free Parameters
ComponentParameterEstimateApprox
Std Error
t ValueApprox
Pr > |t|
IrregularError Variance92.1459113.109867.03<.0001
LevelError Variance44.8359510.654654.21<.0001
SeasonError Variance0.012500.00651531.920.0551


The following statements fit a subset trigonometric model formed by dropping the last three harmonics by specifying the DROPH= option in the SEASON statement:

proc ucm data=callCenter;
   id datetime interval=dthour6;
   model calls;
   irregular;
   level;
   season length=28 type=trig droph=12 13 14;
   estimate back=28;
   forecast back=28 lead=28;
run;

The last row of the holdout region prediction analysis table for the preceding model is shown in Output 42.3.4. It shows that the subset trigonometric model has better prediction performance in the holdout region than the full trigonometric model; its SAE is 471.53, compared to an SAE of 516.22 for the full model.

Output 42.3.4: SAE for the Subset Trigonometric Model

ObsdatetimeActualForecastErrorSAE
55230APR00:186140.83620.164471.534


The following statements illustrate a spline approximation to this seasonal component. In the spline specification the knot placement is quite important, and usually some experimentation is needed. In the following model the knots are placed at the beginning and the middle of each day. Note that the knots at the beginning and end of the season, 1 and 28 in this case, should not be listed in the knot list because knots are always placed there anyway.

proc ucm data=callCenter;
   id datetime interval=dthour6;
   model calls;
   irregular;
   level;
   splineseason length=28
      knots=3 5 7 9 11 13 15 17 19 21 23 25 27
      degree=3;
   estimate back=28;
   forecast back=28 lead=28;
run;

The spline season model takes about half the time to fit that the baseline model takes. The last row of the holdout region prediction analysis table for this model is shown in Output 42.3.5, which shows that the spline season model performs even better than the previous two models in the holdout region; its SAE is 313.79, compared to an SAE of 471.53 for the previous model.

Output 42.3.5: SAE for the Spline Season Model

ObsdatetimeActualForecastErrorSAE
55230APR00:186123.35037.650313.792


The following statements illustrate yet another way to approximate a long seasonal component. Here a combination of BLOCKSEASON and SEASON statements results in a seasonal component that is a sum of two seasonal patterns: one seasonal pattern is simply a regular season with season length 4 that captures the within-day seasonal pattern, and the other seasonal pattern is a block seasonal pattern that remains constant during the day but varies from day to day within a week. Note the use of the NLOPTIONS statement to change the optimization technique during the parameter estimation to DBLDOG, which in this case performs better than the default technique, TRUREG.

proc ucm data=callCenter;
   id datetime interval=dthour6;
   model calls;
   irregular;
   level;
   season length=4 type=trig;
   blockseason nblocks=7 blocksize=4
      type=trig;
   estimate back=28;
   forecast back=28 lead=28;
   nloptions tech=dbldog;
run;

This model also takes about half the time to fit that the baseline model takes. The last row of the holdout region prediction analysis table for this model is shown in Output 42.3.6, which shows that the block season model does slightly better than the baseline model but not as well as the other two models; its SAE is 508.52, compared to an SAE of 516.22 for the baseline model.

Output 42.3.6: SAE for the Block Season Model

ObsdatetimeActualForecastErrorSAE
55230APR00:186139.33921.661508.522


This example showed a few different ways to model a long seasonal pattern. It showed that parsimonious models for long seasonal patterns can be useful, and in some cases even more effective than the full model. Moreover, for very long seasonal patterns the high memory requirements and long computing times might make full models impractical.

Last updated: May 22, 2025