UCM Procedure

A Seasonal Series with Linear Trend

The airline passenger series, given as Series G in Box and Jenkins (1976), is often used in time series literature as an example of a nonstationary seasonal time series. This series is a monthly series consisting of the number of airline passengers who traveled during the years 1949 to 1960. Its main features are a steady rise in the number of passengers from year to year and the seasonal variation in the numbers during any given year. It also exhibits an increase in variability around the trend. A log transformation is used to stabilize this variability. The following DATA step prepares the log-transformed passenger series analyzed in this example:


data seriesG;
   set sashelp.air;
   logair = log( air );
run;

The following statements produce a time series plot of the series by using the TIMESERIES procedure (see Chapter 38, TIMESERIES Procedure (SAS/ETS User's Guide)). The trend and seasonal features of the series are apparent in the plot in Figure 1.


proc timeseries data=seriesG plot=series;
   id date interval=month;
   var logair;
run;

Figure 1: Series Plot of Log-Transformed Airline Passenger Series

Series Plot of Log-Transformed Airline Passenger Series


In this example this series is modeled using an unobserved component model called the basic structural model (BSM). The BSM models a time series as a sum of three stochastic components: a trend component mu Subscript t, a seasonal component gamma Subscript t, and random error epsilon Subscript t. Formally, a BSM for a response series y Subscript t can be described as

y Subscript t Baseline equals mu Subscript t Baseline plus gamma Subscript t Baseline plus epsilon Subscript t

Each of the stochastic components in the model is modeled separately. The random error epsilon Subscript t, also called the irregular component, is modeled simply as a sequence of independent, identically distributed (iid) zero-mean Gaussian random variables. The trend and the seasonal components can be modeled in a few different ways. The model for trend used here is called a locally linear time trend. This trend model can be written as follows:

StartLayout 1st Row 1st Column mu Subscript t 2nd Column equals 3rd Column mu Subscript t minus 1 Baseline plus beta Subscript t minus 1 Baseline plus eta Subscript t Baseline comma eta Subscript t Baseline tilde normal i normal i normal d upper N left parenthesis 0 comma sigma Subscript eta Superscript 2 Baseline right parenthesis 2nd Row 1st Column beta Subscript t 2nd Column equals 3rd Column beta Subscript t minus 1 Baseline plus xi Subscript t Baseline comma xi Subscript t Baseline tilde normal i normal i normal d upper N left parenthesis 0 comma sigma Subscript xi Superscript 2 Baseline right parenthesis EndLayout

These equations specify a trend where the level mu Subscript t as well as the slope beta Subscript t is allowed to vary over time. This variation in slope and level is governed by the variances of the disturbance terms eta Subscript t and xi Subscript t in their respective equations. Some interesting special cases of this model arise when you manipulate these disturbance variances. For example, if the variance of xi Subscript t is 0, the slope will be constant (equal to beta 0); if the variance of eta Subscript t is also 0, mu Subscript t will be a deterministic trend given by the line mu 0 plus beta 0 t. The seasonal model that this example uses is called a trigonometric seasonal. The stochastic equations that govern a trigonometric seasonal are explained in the section Modeling Seasons. However, it is worth noting here that this seasonal model reduces to the familiar regression with deterministic seasonal dummies if the variance of the disturbance terms in its equations is 0. The following statements specify a BSM that has these three components:


/* Load data into mylib */
data mylib.seriesG;
   set seriesG;
run;

proc ucm data=mylib.seriesG;
   id date interval=month;
   model logair;
   irregular;
   level;
   slope;
   season length=12 type=trig print=smooth;
   estimate;
   forecast lead=24 print=decomp;
run;

The PROC UCM statement signifies the start of the UCM procedure; the input SAS table, mylib.seriesG, which contains the dependent series, is specified there. The ID statement is used to specify a date, datetime, or time identification variable, which is called date in this example, to label the observations. The INTERVAL=MONTH option in the ID statement indicates that the measurements were collected on a monthly basis. The model specification begins with the MODEL statement, where the response series is specified (logair in this case). Then the components in the model are specified using separate statements that enable you to control their individual properties. The irregular component epsilon Subscript t is specified using the IRREGULAR statement, and the trend component mu Subscript t is specified using the LEVEL and SLOPE statements. The seasonal component gamma Subscript t is specified using the SEASON statement. The specifics of the seasonal characteristics, such as the season length, its stochastic evolution properties, and so on, are specified using the options in the SEASON statement. The seasonal component that this example uses has a season length of 12, corresponding to monthly seasonality, and is of the trigonometric type. The various types of seasonal components are explained in the section Modeling Seasons.

The parameters of this model are the variances of the disturbance terms in the evolution equations of mu Subscript t, beta Subscript t, and gamma Subscript t and the variance of the irregular component epsilon Subscript t. These parameters are estimated by maximizing the likelihood of the data. The ESTIMATE statement options can be used to specify the span of data that are used in parameter estimation and to display and save the results of the estimation step and the model diagnostics. You can use the estimated model to obtain the forecasts of the series as well as the components. The options in the individual component statements can be used to display the component forecasts; for example, the PRINT=SMOOTH option in the SEASON statement displays smoothed forecasts of the seasonal component gamma Subscript t. The series forecasts and forecasts of the sum of components can be produced using the FORECAST statement. The PRINT=DECOMP option in the FORECAST statement prints the smoothed trend mu Subscript t and the trend plus seasonal component (mu Subscript t Baseline plus gamma Subscript t).

The parameter estimates for this model are displayed in Figure 2.

Figure 2: BSM for the Logair Series

The UCM Procedure

Final Estimates of the Free Parameters
ComponentParameterEstimateApprox
Std Error
t ValueApprox
Pr > |t|
IrregularError Variance0.000234360.00012.170.0298
LevelError Variance0.000298280.00012.820.0048
SlopeError Variance8.47913E-130.00000.000.9989
SeasonError Variance0.000003560.00002.690.0072


The estimates suggest that except for the slope component, the disturbance variances of all the components are significant—that is, all these components are stochastic. The slope component, however, appears to be deterministic because its error variance is quite insignificant. It might then be useful to check if the slope component can be dropped from the model—that is, if beta 0 equals 0. This can be checked by examining the significance analysis table of the components given in Figure 3.

Figure 3: Component Significance Analysis for the Logair Series

Significance Analysis of Components
(Based on the Final State)
ComponentDFChi-SquarePr > ChiSq
Irregular10.080.7747
Level1117867<.0001
Slope143.78<.0001
Season11507.75<.0001


This table provides the significance of the components in the model at the end of the estimation span. If a component is deterministic, this analysis is equivalent to checking whether the corresponding regression effect is significant. However, if a component is stochastic, then this analysis pertains only to the portion of the series near the end of the estimation span. In this example the slope appears quite significant and should be retained in the model, possibly as a deterministic component. Note that, on the basis of this table, the irregular component’s contribution appears insignificant toward the end of the estimation span; however, since it is a stochastic component, it cannot be dropped from the model on the basis of this analysis alone. The slope component can be made deterministic by holding the value of its error variance fixed at 0. This is done by modifying the SLOPE statement as follows:


slope variance=0 noest;

After a tentative model is fit, its adequacy can be checked by examining different goodness-of-fit measures and other diagnostic tests and plots that are based on the model residuals. Once the model appears satisfactory, it can be used for forecasting. An interesting feature of the UCM procedure is that, apart from the series forecasts, you can request the forecasts of the individual components in the model. The plots of component forecasts can be useful in understanding their contributions to the series. The following statements illustrate some of these features:


proc ucm data=mylib.seriesG;
   id date interval = month;
   model logair;
   irregular;
   level plot=smooth;
   slope variance=0 noest;
   season length=12 type=trig
       plot=smooth;
   estimate;
   forecast lead=24 plot=decomp;
run;

The table given in Figure 4 shows the goodness-of-fit statistics that are computed by using the one-step-ahead prediction errors (see the section Statistics of Fit). These measures indicate a good agreement between the model and the data. Additional diagnostic measures are also printed by default but are not shown here.

Figure 4: Fit Statistics for the Logair Series

The UCM Procedure

Fit Statistics Based on Residuals
Mean Squared Error0.00147
Root Mean Squared Error0.03830
Mean Absolute Percentage Error0.54132
Maximum Percent Error2.19097
R-Square0.99061
Adjusted R-Square0.99046
Random Walk R-Square0.87288
Amemiya's Adjusted R-Square0.99017
Number of non-missing residuals used for computing the fit statistics = 131


The first plot, shown in Figure 5, is produced by the PLOT=SMOOTH option in the LEVEL statement, it shows the smoothed level of the series.

Figure 5: Smoothed Trend in the Logair Series

Smoothed Trend in the Logair Series


The second plot (Figure 6), produced by the PLOT=SMOOTH option in the SEASON statement, shows the smoothed seasonal component by itself.

Figure 6: Smoothed Seasonal in the Logair Series

Smoothed Seasonal in the Logair Series


The plot of the sum of the trend and seasonal component, produced by the PLOT=DECOMP option in the FORECAST statement, is shown in Figure 7. You can see that, at least visually, the model seems to fit the data well. In all these decomposition plots the component estimates are extrapolated for two years in the future based on the LEAD=24 option specified in the FORECAST statement.

Figure 7: Smoothed Trend plus Seasonal in the Logair Series

Smoothed Trend plus Seasonal in the Logair Series


Last updated: July 09, 2026