NAG CL Interface
g13acc (uni_​autocorr_​part)

Settings help

CL Name Style:


1 Purpose

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 arguments associated with the predictor of maximum order.

2 Specification

#include <nag.h>
void  g13acc (const double r[], Integer nk, Integer nl, double p[], double v[], double ar[], Integer *nvl, NagError *fail)
The function may be called by the names: g13acc, nag_tsa_uni_autocorr_part or nag_tsa_auto_corr_part.

3 Description

The data consist of values of autocorrelation coefficients r 1 , r 2 , , r K , relating to lags 1 , 2 , , K . These will generally (but not necessarily) be sample values such as may be obtained from a time series x t using g13abc.
The partial autocorrelation coefficient at lag l may be identified with the argument p l,l in the autoregression
x t = c l + p l,1 x t-1 + p l,2 x t-2 + + p l,l x t-l + e l,t  
where e l,t is the predictor error.
The first subscript l of p l,l and e l,t emphasizes the fact that the arguments will in general alter as further terms are introduced into the equation (i.e., as l is increased).
The arguments are determined from the autocorrelation coefficients by the Yule–Walker equations
r i = p l,1 r i-1 + p l,2 r i-2 + + p l,l r i-l ,   i = 1 , 2 , , l  
taking r j = r |j| when j<0 , and r 0 = 1 .
The predictor error variance ratio v l = var( e l,t ) / var( x t ) is defined by
v l = 1 - p l,1 r 1 - p l,2 r 2 - - p l,l r l .  
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 p 1,1 = r 1 and v 1 = 1 - r 1 2 .
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 | p l,l | 1 occurs, say when l = l 0 , 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 arguments are overwritten at each recursive step, so that upon completion the only available values are p Lj , for j=1,2,,L, or p l 0 - 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 double Input
On entry: r[k-1] contains the autocorrelation coefficient relating to lag k , for k=1,2,,K.
2: nk Integer Input
On entry: the number of lags, K . The lags range from 1 to K and do not include zero.
Constraint: nk>0 .
3: nl Integer Input
On entry: the number of partial autocorrelation coefficients required, L .
Constraint: 0 < nl nk .
4: p[nl] double Output
On exit: p[l-1] contains the partial autocorrelation coefficient at lag l , p l,l , for l=1,2,,nvl.
5: v[nl] double Output
On exit: v[l-1] contains the predictor error variance ratio v l , for l=1,2,,nvl.
6: ar[nl] double Output
On exit: the autoregressive arguments of maximum order, i.e., p Lj if fail.code=NE_NOERROR , or p l 0 - 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 l 0 (see Section 3), nvl is returned as l 0 - 1 .
8: fail NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

6 Error Indicators and Warnings

NE_2_INT_ARG_LT
On entry, nk=value while nl=value . These arguments must satisfy nknl .
NE_CORR_NOT_POS_DEF
Recursion has been prematurely terminated; the supplied autocorrelation coefficients do not form a positive definite sequence. Parameter nvl returns the number of valid values computed.
NE_INT_ARG_LE
On entry, nk=value.
Constraint: nk>0.
On entry, nl=value.
Constraint: nl>0.
NE_INVALID_AUTOCO_COEF
On entry, the autocorrelation coefficient of lag 1 has an absolute value greater than or equal to 1.0; no recursions could be performed.

7 Accuracy

The computations are believed to be stable.

8 Parallelism and Performance

g13acc is not threaded in any implementation.

9 Further Comments

The time taken by g13acc is proportional to nvl 2 .

10 Example

In the example below the input series is the set of 10 sample autocorrelation coefficients derived from the original series of sunspot numbers by g13abc example program. The results show 5 values of each of the three output arrays – partial autocorrelation coefficients, predictor error variance ratios and autoregressive arguments. 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)