Documentation Center

  • Trial Software
  • Product Updates

Infer Residuals for Diagnostic Checking

This example shows how to infer residuals from a fitted ARIMA model. Diagnostic checks are performed on the residuals to assess model fit.

The time series is the log quarterly Australian Consumer Price Index (CPI) measured from 1972 to 1991.

Step 1: Load the data.

Load the Australian CPI data. Take first differences, then plot the series.

load Data_JAustralian
Y = Dataset.PAU;
N = length(Y);
dY = diff(Y);

figure
plot(2:N,dY)
xlim([0,N])
title('Differenced Australian CPI')

The differenced series looks relatively stationary.

Step 2. Plot the sample ACF and PACF.

Plot the sample autocorrelation function (ACF) and partial autocorrelation function (PACF) to look for autocorrelation in the differenced series.

figure
subplot(2,1,1)
autocorr(dY)
subplot(2,1,2)
parcorr(dY)

The sample ACF decays more slowly than the sample PACF. The latter cuts off after lag 2. This, along with the first-degree differencing, suggests an ARIMA(2,1,0) model.

Step 3. Estimate an ARIMA(2,1,0) model.

Specify, and then estimate, an ARIMA(2,1,0) model. Infer the residuals for diagnostic checking.

model = arima(2,1,0);
fit = estimate(model,Y);
[res,~,LogL] = infer(fit,Y);
 
    ARIMA(2,1,0) Model:
    --------------------
    Conditional Probability Distribution: Gaussian

                                  Standard          t     
     Parameter       Value          Error       Statistic 
    -----------   -----------   ------------   -----------
     Constant      0.0100723    0.00328015        3.07069
        AR{1}       0.212059     0.0954278        2.22219
        AR{2}       0.337282      0.103781        3.24994
     Variance    9.23017e-05   1.11119e-05        8.30659

Notice that the model is fit to the original series, and not the differenced series. The model object to be fit, model, has property D equal to 1. This accounts for the one degree of differencing.

This specification assumes a Gaussian innovation distribution. infer returns the value of the loglikelihood objective function (Logl) along with the residuals (res).

Step 4. Perform residual diagnostic checks.

Standardize the inferred residuals, and check for normality and any unexplained autocorrelation.

stdr = res/sqrt(fit.Variance);

figure
subplot(2,2,1)
plot(stdr)
title('Standardized Residuals')
subplot(2,2,2)
hist(stdr)
title('Standardized Residuals')
subplot(2,2,3)
autocorr(stdr)
subplot(2,2,4)
parcorr(stdr)

The residuals appear uncorrelated and approximately normally distributed. There is some indication that there is an excess of large residuals.

Step 5. Modify the innovation distribution.

To explore possible excess kurtosis in the innovation process, fit an ARIMA(2,1,0) model with a Student's t distribution to the original series. Return the value of the loglikelihood objective function so you can use the Bayesian information criterion (BIC) to compare the fit of the two models.

model.Distribution = 't';
[fitT,~,LogLT] = estimate(model,Y);
[~,bic] = aicbic([LogLT,LogL],[5,4],N)
 
    ARIMA(2,1,0) Model:
    --------------------
    Conditional Probability Distribution: t

                                  Standard          t     
     Parameter       Value          Error       Statistic 
    -----------   -----------   ------------   -----------
     Constant     0.00997461    0.00161523        6.17535
        AR{1}       0.326885     0.0755029        4.32943
        AR{2}       0.187194     0.0746899        2.50628
     Variance    0.000247221   0.000746319       0.331253
          DoF        2.25935      0.955607        2.36431

bic =

 -492.5317 -479.4691

The model with the t innovation distribution has one extra parameter (the degrees of freedom of the t distribution).

According to the BIC, the ARIMA(2,1,0) model with a Student's t innovation distribution is the better choice because it has a smaller (more negative) BIC value.

See Also

| | |

Related Examples

More About

Was this topic helpful?