X13 Procedure

Example 45.6 User-Defined Regressors

(View the complete code for this example.)

This example demonstrates the use of the USERVAR= option in the REGRESSION statement to include user-defined regressors in the regARIMA model. The user-defined regressors must be defined as nonmissing values for the span of the series being modeled plus any backcast or forecast values. Suppose you have the data set SALESDATA with 132 monthly observations beginning in January 1949.

title 'Data Set to be Seasonally Adjusted';
data salesdata;
   set sashelp.air(obs=132);
run;

Because the regARIMA model forecasts one year ahead, you must define the regressor for 144 observations that start in January 1949. You can construct a simple length-of-month regressor by using the following DATA step:

title 'User-defined Regressor for Data to be Seasonally Adjusted';
data regressors(keep=date LengthOfMonth);
   set sashelp.air;
   LengthOfMonth = INTNX('MONTH',date,1) - date;
run;

In this example, the two data sets are merged to use them as input to PROC X13. You can also use the AUXDATA= data set to input user-defined regressors. For more information, see Example 45.11. The BY statement is used to align the regressors with the time series by the time ID variable DATE.

title 'Data Set Containing Series and Regressors';
data datain;
   merge regressors salesdata;
   by date;
run;
proc print data=datain(firstobs=121);
run;

The last 24 observations of the input data set are displayed in Output 45.6.1. The regressor variable is defined for one year (12 observations) beyond the span of the time series to be seasonally adjusted.

Output 45.6.1: PROC X13 Input Data Set with User-Defined Regressor

Data Set Containing Series and Regressors

ObsDATELengthOfMonthAIR
121JAN5931360
122FEB5928342
123MAR5931406
124APR5930396
125MAY5931420
126JUN5930472
127JUL5931548
128AUG5931559
129SEP5930463
130OCT5931407
131NOV5930362
132DEC5931405
133JAN6031.
134FEB6029.
135MAR6031.
136APR6030.
137MAY6031.
138JUN6030.
139JUL6031.
140AUG6031.
141SEP6030.
142OCT6031.
143NOV6030.
144DEC6031.


The DATAIN data set is now ready to be used as input to PROC X13. The DATE= variable and the user-defined regressors are automatically excluded from the variables to be seasonally adjusted.

title 'regARIMA Model with User-defined Regressor';
proc x13 data=datain date=DATE interval=MONTH plots=none;
   transform function=log;
   regression uservar=LengthOfMonth / usertype=lom;
   automdl;
   x11;
   output out=out a1 d11;
run;

The parameter estimates for the regARIMA model are shown in Output 45.6.2

Output 45.6.2: PROC X13 Output for User-Defined Regression Parameter

regARIMA Model with User-defined Regressor

The X13 Procedure

Regression Model Parameter Estimates
For Variable AIR
TypeParameterNoEstEstimateStandard
Error
t ValuePr > |t|
User DefinedLengthOfMonthEst0.046830.018342.550.0119

Exact ARMA Maximum Likelihood Estimation
For Variable AIR
ParameterLagEstimateStandard
Error
t ValuePr > |t|
Nonseasonal MA10.336780.085063.960.0001
Seasonal MA120.540780.077267.00<.0001


Another way to include user-defined regressors in the regARIMA model is to specify the SPAN= option in the PROC X13 statement. The following user-defined regressor is similar to the one defined previously. However, this length-of-month regressor is mean adjusted. Using a zero-mean regressor prevents the regressor from altering the level of the series. In this instance, the series to be seasonally adjusted, AIR, and the regression variable, LengthOfMonth, have nonmissing observations at all time periods in the data set DATAIN.

title 'User-defined Regressor for Data to be Seasonally Adjusted, Mean Adjusted';
data datain(keep=date AIR LengthOfMonth);
   set sashelp.air;
   LengthOfMonth = INTNX('MONTH',date,1) - date - 30.4375;
run;

Because the default forecast period is one year ahead, the span of the series must be limited to one year before the end of the regression variable definition to forecast using the regression variable LengthOfMonth,

title 'regARIMA Model with Zero-Mean User-defined Regressor';
proc x13 data=datain date=DATE interval=MONTH span=(,DEC1959) plots=none;
   transform function=log;
   regression uservar=LengthOfMonth / usertype=lom;
   automdl;
   x11;
   output out=outzm a1 d11;
run;

The parameter estimates for the regARIMA model that are estimated using a zero-mean regressor are shown in Output 45.6.3

Output 45.6.3: PROC X13 Output for Zero-Mean User-Defined Regression Parameter

regARIMA Model with Zero-Mean User-defined Regressor

The X13 Procedure

Regression Model Parameter Estimates
For Variable AIR
TypeParameterNoEstEstimateStandard
Error
t ValuePr > |t|
User DefinedLengthOfMonthEst0.046830.018342.550.0119

Exact ARMA Maximum Likelihood Estimation
For Variable AIR
ParameterLagEstimateStandard
Error
t ValuePr > |t|
Nonseasonal MA10.336780.085063.960.0001
Seasonal MA120.540780.077267.00<.0001


Specifying USERTYPE=LOM causes the regression effect to be removed from the seasonally adjusted series. The effect of the mean of the regression variable on the seasonally adjusted series can be seen by examining the plots of the original series and the seasonally adjusted series.

title 'regARIMA Model with Non-Zero-Mean User-Defined Regressor';
proc sgplot data=out;
   series x=date y=air_A1 / name = "A1" markers
                              markerattrs=(color=red symbol='asterisk')
                              lineattrs=(color=red);
   series x=date y=air_D11 / name= "D11" markers
                               markerattrs=(symbol='circle')
                               lineattrs=(color=blue);
   yaxis label='Original and Seasonally Adjusted Time Series';
run;
title 'regARIMA Model with Zero-Mean User-Defined Regressor';
proc sgplot data=outzm;
   series x=date y=air_A1 / name = "A1" markers
                              markerattrs=(color=red symbol='asterisk')
                              lineattrs=(color=red);
   series x=date y=air_D11 / name= "D11" markers
                               markerattrs=(symbol='circle')
                               lineattrs=(color=blue);
   yaxis label='Original and Seasonally Adjusted Time Series';
run;

The graph of the original and seasonally adjusted series in Output 45.6.4 shows that the level of the seasonally adjusted series has been altered due to the user-defined regressor. The graph of the original and seasonally adjusted series in Output 45.6.5 shows that the level of the seasonally adjusted series is the same as the original series since the user-defined regressor has zero-mean.

Output 45.6.4: Plot of Original and Seasonally Adjusted Data

Plot of Original and Seasonally Adjusted Data


Output 45.6.5: Plot of Original and Seasonally Adjusted Data (Zero-Mean Regressor)

Plot of Original and Seasonally Adjusted Data (Zero-Mean Regressor)


When actual values are available for the forecast periods, information about forecast error is available in the output. Output 45.6.6 shows the table "Forecasts and Standard Errors of the Transformed Data on the Original Scale" for a series with missing values in the forecast period. Output 45.6.7 shows the table "Forecasts and Standard Errors of the Transformed Data on the Original Scale" for a series with actual values in the forecast period. Thus, it is more desirable to use SPAN= option to limit the span of a series if the actual values are available for the forecast period.

Output 45.6.6: PROC X13 Forecasts for Series Extended with Missing Values

Forecasts and Standard Errors of the Transformed
Data
On the Original scale
For Variable AIR
DateForecastStandard
Error
95% Confidence Limits
JAN1960419.60014.85053391.509449.705
FEB1960416.48019.05188380.826455.472
MAR1960466.69722.66762424.402513.208
APR1960454.46824.53242408.951505.051
MAY1960473.87627.91366422.353531.684
JUN1960547.60134.74893483.769619.855
JUL1960623.31842.20549546.139711.405
AUG1960631.73145.30824549.231726.623
SEP1960527.22139.81839455.011610.890
OCT1960462.77436.63020396.605539.984
NOV1960407.15533.64286346.608478.277
DEC1960452.70238.91914382.913535.212


Output 45.6.7: PROC X13 Forecasts for Series with Actual Values in Forecast Periods

Forecasts and Standard Errors of the Transformed Data
On the Original scale
For Variable AIR
DateDataForecastForecast ErrorStandard
Error
t Value95% Confidence Limits
JAN1960417.000419.600-2.60014.85053-0.18391.509449.705
FEB1960391.000416.480-25.48019.05188-1.34380.826455.472
MAR1960419.000466.697-47.69722.66762-2.10424.402513.208
APR1960461.000454.4686.53224.532420.27408.951505.051
MAY1960472.000473.876-1.87627.91366-0.07422.353531.684
JUN1960535.000547.601-12.60134.74893-0.36483.769619.855
JUL1960622.000623.318-1.31842.20549-0.03546.139711.405
AUG1960606.000631.731-25.73145.30824-0.57549.231726.623
SEP1960508.000527.221-19.22139.81839-0.48455.011610.890
OCT1960461.000462.774-1.77436.63020-0.05396.605539.984
NOV1960390.000407.155-17.15533.64286-0.51346.608478.277
DEC1960432.000452.702-20.70238.91914-0.53382.913535.212


Last updated: June 19, 2025