### Example 7.6 Detection of Level Changes in the Nile River Data

This example shows how to use the OUTLIER statement to detect changes in the dynamics of the time series being modeled. The time series used here is discussed in de Jong and Penzer (1998). The data consist of readings of the annual flow volume of the Nile River at Aswan from 1871 to 1970. These data have also been studied by Cobb (1978). These studies indicate that river flow levels in the years 1877 and 1913 are strong candidates for additive outliers and that there was a shift in the flow levels starting from the year 1899. This shift in 1899 is attributed partly to the weather changes and partly to the start of construction work for a new dam at Aswan. The following DATA step statements create the input data set.

```data nile;
input level @@;
year = intnx( 'year', '1jan1871'd, _n_-1 );
format year year4.;
datalines;
1120  1160  963  1210  1160  1160  813  1230   1370  1140
995   935   1110 994   1020  960   1180 799    958   1140
1100  1210  1150 1250  1260  1220  1030 1100   774   840

... more lines ...

```

The following program fits an ARIMA model, ARIMA(0,1,1), similar to the structural model suggested in de Jong and Penzer (1998). This model is also suggested by the usual correlation analysis of the series. By default, the OUTLIER statement requests detection of additive outliers and level shifts, assuming that the series follows the estimated model.

```/*-- ARIMA(0, 1, 1) Model --*/
proc arima data=nile;
identify var=level(1);
estimate q=1 noint method=ml;
outlier maxnum= 5 id=year;
run;
```

The outlier detection output is shown in Output 7.6.1.

Output 7.6.1: ARIMA(0, 1, 1) Model

 SERIES A: Chemical Process Concentration Readings

The ARIMA Procedure

Outlier Detection Summary
Maximum number searched 5
Number found 5
Significance used 0.05

Outlier Details
Obs Time ID Type Estimate Chi-Square Approx Prob>ChiSq
29 1899 Shift -315.75346 13.13 0.0003
43 1913 Additive -403.97105 11.83 0.0006
7 1877 Additive -335.49351 7.69 0.0055
94 1964 Additive 305.03568 6.16 0.0131
18 1888 Additive -287.81484 6.00 0.0143

Note that the first three outliers detected are indeed the ones discussed earlier. You can include the shock signatures that correspond to these three outliers in the Nile data set as follows:

```data nile;
set nile;
AO1877 = ( year = '1jan1877'd );
AO1913 = ( year = '1jan1913'd );
LS1899 = ( year >= '1jan1899'd );
run;
```

Now you can refine the earlier model by including these outliers. After examining the parameter estimates and residuals (not shown) of the ARIMA(0,1,1) model with these regressors, the following stationary MA1 model (with regressors) appears to fit the data well:

```/*-- MA1 Model with Outliers --*/
proc arima data=nile;
identify var=level
crosscorr=( AO1877 AO1913 LS1899 );
estimate q=1
input=( AO1877 AO1913 LS1899 )
method=ml;
outlier maxnum=5 alpha=0.01 id=year;
run;
```

The relevant outlier detection process output is shown in Output 7.6.2. No outliers, at significance level 0.01, were detected.

Output 7.6.2: MA1 Model with Outliers

 SERIES A: Chemical Process Concentration Readings

The ARIMA Procedure

Outlier Detection Summary
Maximum number searched 5
Number found 0
Significance used 0.01