Legacy Documentation

Time Series (2011)

This is documentation for an obsolete product.
Current products and services

Previous section-----Next section

1.6.2 Diagnostic Checking

After fitting a model to a given set of data the goodness of fit of the model is usually examined to see if it is indeed an appropriate model. If the model is not satisfactory, modifications are made to the model and the whole process of model selection, parameter estimation, and diagnostic checking must be repeated until a satisfactory model is found.

Residual Testing

There are various ways of checking if a model is satisfactory. The commonly used approach to diagnostic checking is to examine the residuals. There are several alternative definitions of the residuals and here we define the residuals to be the noise calculated from the estimated model. Let {} and {} be estimated ARMA parameters and and the corresponding AR and MA polynomials, the residual is defined by
Or explicitly,
where xt=0 for t≤0. From (6.5) we see that if the fitted model is the "true" model, the residuals {} should behave like a white noise process with zero mean and constant variance. So the behavior of the residuals is used to test the adequacy of the fitted model.
The first step in residual testing is to calculate the residuals given the fitted model and observed data. The function
Residual[data, model]
gives the residuals for t=1, 2, ... , n given the fitted model and observed data. Internally the function iterates (6.6) with the starting values xt=0 for t≤0 and for t≤0.
In[58]:=
Since the residuals are also ordered in time, we can treat them as a time series. As in the analysis of the time series itself, the first diagnostic test in examining residuals is to plot them as a function of time to see if it appears to be a stationary random sequence.
In[59]:=
Out[59]=
The graph gives no indication of deviation from stationary random noise. Often we also calculate the sample correlation function of the residuals and see if it behaves the way it should.
In[60]:=
In[61]:=
Out[61]=
Although the sample correlation of the residuals has smaller asymptotic variance than 1/n for small lags (see Brockwell and Davis (1987), pp. 297-300), we nevertheless use as a rough guide to see if the correlations are significantly different from zero. In our example, , and we see no reason to believe that the residuals are not white noise.
Instead of looking at the correlation function of the residuals at each k, we can also look at the first h correlation values together and test if the first h correlations are zero (H0). The portmanteau test is based on the statistic
which has an asymptotic 2 distribution with h-p-q degrees of freedom. If , the adequacy of the model is rejected at level . The function
PortmanteauStatistic[residual, h]
gives the value of Qh for given residuals and h. Here we calculate the portmanteau statistic using the residuals we obtained above for h=35.
In[62]:=
Out[62]=
This number is compared with , which can be obtained as follows.
In[63]:=
Out[63]=
Since this number exceeds the portmanteau statistic, we accept the fitted model model1 as adequate.
For an m-variate time series the portmanteau statistic Qh is (see Granger and Newbold (1986), p. 250 and Reinsel (1993), p. 134)
where is the covariance matrix of residuals. The statistic has an asymptotic 2 distribution with m2(h-p-q) degrees of freedom. The same function PortmanteauStatistic can be used to compute (6.7).
There are various other tests for checking the randomness of the residuals. These tests are often easily implemented with Mathematica and the reader is urged to try them. Here we show how the turning points test and difference-sign test can be implemented. (See Kendall and Ord (1990), pp. 18-23.)

Turning Points Test

Let {x1, x2, ... , xn} be a time series. xi is a turning point if xi-1<xi and xi+1<xi or xi-1>xi and xi+1>xi. In other words, a turning point is a local extremum (a peak or a trough). Let T denote the number of turning points. If the series is a realization of an identically and independently distributed (IID) random process, then T has an asymptotic normal distribution with mean T=2(n-2)/3 and variance .
In[64]:=
Count counts the number of occurrences of the adjacent elements with opposite signs, that is, the number of turning points.
In[65]:=
Out[65]=
In[66]:=
Out[66]=
The result is well within two standard deviations.

The Difference-Sign Test

In this test, the number of times xi>xi-1, or xi-xi-1 is positive is counted. If the series is random we expect this number to be (n-1)/2. If the number of times xi>xi-1 is far from (n-1)/2, a trend is likely present in the series.
Using Count we can easily get the number of times xi-xi-1 is positive.
In[67]:=
Out[67]=
The deviation of this count from the mean (n-1)/2 can then be compared with the standard deviation =((n+1)/12)1/2. In this case the deviation is within two .