nag_tsa_auto_corr_part (g13acc) (PDF version)
g13 Chapter Contents
g13 Chapter Introduction
NAG Library Manual

NAG Library Function Document

nag_tsa_auto_corr_part (g13acc)

 Contents

    1  Purpose
    7  Accuracy

1  Purpose

nag_tsa_auto_corr_part (g13acc) calculates partial autocorrelation coefficients given a set of autocorrelation coefficients. It also calculates the predictor error variance ratios for increasing order of finite lag autoregressive predictor, and the autoregressive parameters associated with the predictor of maximum order.

2  Specification

#include <nag.h>
#include <nagg13.h>
void  nag_tsa_auto_corr_part (const double r[], Integer nk, Integer nl, double p[], double v[], double ar[], Integer *nvl, NagError *fail)

3  Description

The data consist of values of autocorrelation coefficients r1,r2,,rK, relating to lags 1,2,,K. These will generally (but not necessarily) be sample values such as may be obtained from a time series xt using nag_tsa_auto_corr (g13abc).
The partial autocorrelation coefficient at lag l may be identified with the parameter pl,l in the autoregression
xt = cl + pl,1 xt-1 + pl,2 xt-2 ++ pl,l xt-l + el,t  
where el,t is the predictor error.
The first subscript l of pl,l and el,t emphasizes the fact that the parameters will in general alter as further terms are introduced into the equation (i.e., as l is increased).
The parameters are determined from the autocorrelation coefficients by the Yule–Walker equations
ri = pl,1 ri-1 + pl,2 ri-2 ++ pl,l ri-l ,   i=1,2,,l  
taking rj=rj when j<0, and r0=1.
The predictor error variance ratio vl=varel,t/varxt is defined by
vl = 1- pl,1 r1 - pl,2 r2 -- pl,l rl .  
The above sets of equations are solved by a recursive method (the Durbin–Levinson algorithm). The recursive cycle applied for l=1,2,,L-1, where L is the number of partial autocorrelation coefficients required, is initialized by setting p1,1=r1 and v1=1-r12.
Then
p l + 1 , l + 1 = r l + 1 - p l , 1 r l - p l , 2 r l - 1 - - p l , l r 1 / v l p l + 1 , j = p l , j - p l + 1 , l + 1 p l , l + 1 - j ,   j=1,2,,l v l + 1 = v l 1 - p l + 1 , l + 1 1 + p l + 1 , l + 1 .  
If the condition pl,l1 occurs, say when l=l0, it indicates that the supplied autocorrelation coefficients do not form a positive definite sequence (see Hannan (1960)), and the recursion is not continued. The autoregressive parameters are overwritten at each recursive step, so that upon completion the only available values are pLj, for j=1,2,,L, or pl0-1,j if the recursion has been prematurely halted.

4  References

Box G E P and Jenkins G M (1976) Time Series Analysis: Forecasting and Control (Revised Edition) Holden–Day
Durbin J (1960) The fitting of time series models Rev. Inst. Internat. Stat. 28 233
Hannan E J (1960) Time Series Analysis Methuen

5  Arguments

1:     r[nk] const doubleInput
On entry: the autocorrelation coefficient relating to lag k, for k=1,2,,K.
2:     nk IntegerInput
On entry: K, the number of lags. The lags range from 1 to K and do not include zero.
Constraint: nk>0.
3:     nl IntegerInput
On entry: L, the number of partial autocorrelation coefficients required.
Constraint: 0<nlnk.
4:     p[nl] doubleOutput
On exit: p[l-1] contains the partial autocorrelation coefficient at lag l, pl,l, for l=1,2,,nvl.
5:     v[nl] doubleOutput
On exit: v[l-1] contains the predictor error variance ratio vl, for l=1,2,,nvl.
6:     ar[nl] doubleOutput
On exit: the autoregressive parameters of maximum order, i.e., pLj if fail.code= NE_NOERROR, or pl0-1,j if fail.code= NE_CORR_NOT_POS_DEF, for j=1,2,,nvl.
7:     nvl Integer *Output
On exit: the number of valid values in each of p, v and ar. Thus in the case of premature termination at iteration l0 (see Section 3), nvl is returned as l0-1.
8:     fail NagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

6  Error Indicators and Warnings

NE_CORR_NOT_POS_DEF
The autocorrelation coefficients do not form a positive definite sequence.
NE_INT
On entry, nk=value.
Constraint: nk>0.
On entry, nl=value.
Constraint: nl>0.
NE_INT_2
On entry, nk=value and nl=value.
Constraint: nknl.

7  Accuracy

The computations are believed to be stable.

8  Parallelism and Performance

Not applicable.

9  Further Comments

The time taken by nag_tsa_auto_corr_part (g13acc) is proportional to nvl 2.

10  Example

This example uses an input series of 10 sample autocorrelation coefficients derived from the original series of sunspot numbers generated by the nag_tsa_auto_corr (g13abc) example program. The results show five values of each of the three output arrays: partial autocorrelation coefficients, predictor error variance ratios and autoregressive parameters. All of these were valid.

10.1  Program Text

Program Text (g13acce.c)

10.2  Program Data

Program Data (g13acce.d)

10.3  Program Results

Program Results (g13acce.r)

This plot shows the partial autocorrelations for all possible lag values. Reference lines are given at ±z0.975/n.
GnuplotProduced by GNUPLOT 4.6 patchlevel 3 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1 0 10 20 30 40 50 PACF Lag Example Program Partial Autocorrelation Coefficients gnuplot_plot_1 gnuplot_plot_2 gnuplot_plot_3

nag_tsa_auto_corr_part (g13acc) (PDF version)
g13 Chapter Contents
g13 Chapter Introduction
NAG Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2015