The X13 Procedure

Example 46.5 Automatic Outlier Detection

(View the complete code for this example.)

This example demonstrates the use of the OUTLIER statement to automatically detect and remove outliers from a time series to be seasonally adjusted. The data set is the same as in the section Basic Seasonal Adjustment and the previous examples. Adding the OUTLIER statement to Example 46.3 requests that outliers be detected by using the default critical value as described in the section OUTLIER Statement. The tables associated with outlier detection for this example are shown in Output 46.5.1. The first table shows the critical values; the second table shows that a single potential outlier was identified; the third table shows the estimates for the ARMA parameters. Since no outliers are included in the regression model, the "Regression Model Parameter Estimates" table is not displayed. Because only a potential outlier was identified, and not an actual outlier, in this case the A1 series and the B1 series are identical.

title 'Automatic Outlier Identification';
proc x13 data=sales date=date;
   var sales;
   transform function=log;
   arima model=( (0,1,1)(0,1,1) );
   outlier;
   estimate;
   x11;
   output out=nooutlier a1 b1 d10;
run ;

Output 46.5.1: PROC X13 Output When Potential Outliers Are Identified

Automatic Outlier Identification

The X13 Procedure

Critical Values to use in Outlier
Detection
For Variable sales
BeginSEP1978
EndAUG1990
Observations144
MethodAdd One
AO Critical Value3.889838
LS Critical Value3.889838


Note:The following time series values might later be identified as outliers when data are added or revised. They were not identified as outliers in this run either because their test t-statistics were slightly below the critical value or because they were eliminated during the backward deletion step of the identification procedure, when a non-robust t-statistic is used.

Potential Outliers
For Variable sales
Type of OutlierDatet Value for AOt Value for LS
AONOV1989-3.48-1.51

Exact ARMA Maximum Likelihood Estimation
For Variable sales
ParameterLagEstimateStandard
Error
t ValuePr > |t|
Nonseasonal MA10.401810.078875.09<.0001
Seasonal MA120.556950.076267.30<.0001


In the next example, reducing the critical value to 3.3 causes the outlier identification routine to more aggressively identify outliers as shown in Output 46.5.2. The first table shows the critical values. The second table shows that three additive outliers and a level-shift have been included in the regression model. The third table shows how the inclusion of outliers in the model affects the ARMA parameters.

proc x13 data=sales date=date;
   var sales;
   transform function=log;
   arima model=((0,1,1) (0,1,1));
   outlier cv=3.3;
   estimate;
   x11;
   output out=outlier a1 a8  a8ao a8ls b1 d10;
run;
proc print data=outlier(obs=45);
run;

Output 46.5.2: PROC X13 Output When Outliers Are Identified

Automatic Outlier Identification

The X13 Procedure

Critical Values to use in Outlier
Detection
For Variable sales
BeginSEP1978
EndAUG1990
Observations144
MethodAdd One
AO Critical Value3.3
LS Critical Value3.3

Regression Model Parameter Estimates
For Variable sales
TypeParameterNoEstEstimateStandard
Error
t ValuePr > |t|
Automatically IdentifiedAO JAN1981Est0.095900.021684.42<.0001
 LS FEB1983Est-0.096730.02488-3.890.0002
 AO OCT1983Est-0.080320.02146-3.740.0003
 AO NOV1989Est-0.103230.02480-4.16<.0001

Exact ARMA Maximum Likelihood Estimation
For Variable sales
ParameterLagEstimateStandard
Error
t ValuePr > |t|
Nonseasonal MA10.332050.082394.03<.0001
Seasonal MA120.496470.076766.47<.0001


The first 45 observations of the A1, A8, A8AO, A8LS, B1, and D10 series are displayed in Output 46.5.3. You can confirm the following relationships from the data:

The seasonal factors are stored in the variable sales_D10.

Output 46.5.3: PROC X13 Output Series Related to Outlier Detection

Automatic Outlier Identification

ObsDATEsales_A1sales_A8sales_A8AOsales_A8LSsales_B1sales_D10
1SEP781121.101561.000001.10156101.6740.90496
2OCT781181.101561.000001.10156107.1210.94487
3NOV781321.101561.000001.10156119.8301.04711
4DEC781291.101561.000001.10156117.1071.00119
5JAN791211.101561.000001.10156109.8440.94833
6FEB791351.101561.000001.10156122.5531.06817
7MAR791481.101561.000001.10156134.3551.18679
8APR791481.101561.000001.10156134.3551.17607
9MAY791361.101561.000001.10156123.4611.07565
10JUN791191.101561.000001.10156108.0290.91844
11JUL791041.101561.000001.1015694.4120.81206
12AUG791181.101561.000001.10156107.1210.91602
13SEP791151.101561.000001.10156104.3970.90865
14OCT791261.101561.000001.10156114.3830.94131
15NOV791411.101561.000001.10156128.0001.04496
16DEC791351.101561.000001.10156122.5530.99766
17JAN801251.101561.000001.10156113.4750.94942
18FEB801491.101561.000001.10156135.2631.07172
19MAR801701.101561.000001.10156154.3271.18663
20APR801701.101561.000001.10156154.3271.18105
21MAY801581.101561.000001.10156143.4331.07383
22JUN801331.101561.000001.10156120.7380.91930
23JUL801141.101561.000001.10156103.4900.81385
24AUG801401.101561.000001.10156127.0930.91466
25SEP801451.101561.000001.10156131.6320.91302
26OCT801501.101561.000001.10156136.1710.93086
27NOV801781.101561.000001.10156161.5891.03965
28DEC801631.101561.000001.10156147.9720.99440
29JAN811721.212431.100651.10156141.8640.95136
30FEB811781.101561.000001.10156161.5891.07981
31MAR811991.101561.000001.10156180.6531.18661
32APR811991.101561.000001.10156180.6531.19097
33MAY811841.101561.000001.10156167.0361.06905
34JUN811621.101561.000001.10156147.0640.92446
35JUL811461.101561.000001.10156132.5390.81517
36AUG811661.101561.000001.10156150.6950.91148
37SEP811711.101561.000001.10156155.2340.91352
38OCT811801.101561.000001.10156163.4050.91632
39NOV811931.101561.000001.10156175.2061.03194
40DEC811811.101561.000001.10156164.3120.98879
41JAN821831.101561.000001.10156166.1280.95699
42FEB822181.101561.000001.10156197.9011.09125
43MAR822301.101561.000001.10156208.7951.19059
44APR822421.101561.000001.10156219.6881.20448
45MAY822091.101561.000001.10156189.7311.06355


From the two previous examples, you can examine how outlier detection affects the seasonally adjusted series. Output 46.5.4 shows a plot of A1 versus B1 in the series where outliers are detected. B1 has been adjusted for the additive outliers and the level-shift.

proc sgplot data=outlier;
   series x=date y=sales_A1 / name='A1' markers
                              markerattrs=(color=red symbol='circle')
                              lineattrs=(color=red);
   series x=date y=sales_B1 / name='B1' markers
                              markerattrs=(color=black symbol='asterisk')
                              lineattrs=(color=black);
   yaxis label='Original and Outlier Adjusted Time Series';
run;

Output 46.5.4: Original Series and Outlier Adjusted Series

Original Series and Outlier Adjusted Series


Output 46.5.5 compares the seasonal factors (Table D10) of the series unadjusted for outliers to the series adjusted for outliers. The seasonal factors are based on the B1 series.

data both;
   merge nooutlier(rename=(sales_D10=unadj_D10)) outlier;
run;

title 'Results of Outlier Identification on Final Seasonal Factors';
proc sgplot data=both;
   series x=date y=unadj_D10 / name='unadjusted' markers
                               markerattrs=(color=red symbol='circle')
                               lineattrs=(color=red)
                               legendlabel='Unadjusted for Outliers';
   series x=date y=sales_D10 / name='adjusted' markers
                               markerattrs=(color=blue symbol='asterisk')
                               lineattrs=(color=blue)
                               legendlabel='Adjusted for Outliers';
   yaxis label='Final Seasonal Factors';
run;

Output 46.5.5: Seasonal Factors Based on Original and Outlier Adjusted Series

Seasonal Factors Based on Original and Outlier Adjusted Series


Last updated: August 11, 2020