G02FAF (PDF version)
G02 Chapter Contents
G02 Chapter Introduction
NAG Library Manual

NAG Library Routine Document

G02FAF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

G02FAF calculates two types of standardized residuals and two measures of influence for a linear regression.

2  Specification

SUBROUTINE G02FAF ( N, IP, NRES, RES, H, RMS, SRES, LDSRES, IFAIL)
INTEGER  N, IP, NRES, LDSRES, IFAIL
REAL (KIND=nag_wp)  RES(NRES), H(NRES), RMS, SRES(LDSRES,4)

3  Description

For the general linear regression model
y=Xβ+ε,
where y is a vector of length n of the dependent variable,
X is an n by p matrix of the independent variables,
β is a vector of length p of unknown parameters,
and ε is a vector of length n of unknown random errors such that varε=σ2I.
The residuals are given by
r=y-y^=y-Xβ^
and the fitted values, y^=Xβ^, can be written as Hy for an n by n matrix H. The ith diagonal elements of H, hi, give a measure of the influence of the ith values of the independent variables on the fitted regression model. The values of r and the hi are returned by G02DAF.
G02FAF calculates statistics which help to indicate if an observation is extreme and having an undue influence on the fit of the regression model. Two types of standardized residual are calculated:
(i) The ith residual is standardized by its variance when the estimate of σ2, s2, is calculated from all the data; this is known as internal Studentization.
RIi=ris1-hi .
(ii) The ith residual is standardized by its variance when the estimate of σ2, s-i2 is calculated from the data excluding the ith observation; this is known as external Studentization.
REi=ris-i1-hi =rin-p-1 n-p-RIi2 .
The two measures of influence are:
(i) Cook's D 
Di=1pREi2hi1-hi .
(ii) Atkinson's T 
Ti=REi n-pp hi1-hi .

4  References

Atkinson A C (1981) Two graphical displays for outlying and influential observations in regression Biometrika 68 13–20
Cook R D and Weisberg S (1982) Residuals and Influence in Regression Chapman and Hall

5  Parameters

1:     N – INTEGERInput
On entry: n, the number of observations included in the regression.
Constraint: N>IP+1.
2:     IP – INTEGERInput
On entry: p, the number of linear parameters estimated in the regression model.
Constraint: IP1.
3:     NRES – INTEGERInput
On entry: the number of residuals.
Constraint: 1NRESN.
4:     RES(NRES) – REAL (KIND=nag_wp) arrayInput
On entry: the residuals, ri.
5:     H(NRES) – REAL (KIND=nag_wp) arrayInput
On entry: the diagonal elements of H, hi, corresponding to the residuals in RES.
Constraint: 0.0<Hi<1.0, for i=1,2,,NRES.
6:     RMS – REAL (KIND=nag_wp)Input
On entry: the estimate of σ2 based on all n observations, s2, i.e., the residual mean square.
Constraint: RMS>0.0.
7:     SRES(LDSRES,4) – REAL (KIND=nag_wp) arrayOutput
On exit: the standardized residuals and influence statistics.
For the observation with residual, ri, given in RESi.
SRESi1
Is the internally standardized residual, RIi.
SRESi2
Is the externally standardized residual, REi.
SRESi3
Is Cook's D statistic, Di.
SRESi4
Is Atkinson's T statistic, Ti.
8:     LDSRES – INTEGERInput
On entry: the first dimension of the array SRES as declared in the (sub)program from which G02FAF is called.
Constraint: LDSRESNRES.
9:     IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to 0, -1​ or ​1. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1​ or ​1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is 0. When the value -1​ or ​1 is used it is essential to test the value of IFAIL on exit.
On exit: IFAIL=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6  Error Indicators and Warnings

If on entry IFAIL=0 or -1, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Errors or warnings detected by the routine:
IFAIL=1
On entry,IP<1,
orNIP+1,
orNRES<1,
orNRES>N,
orLDSRES<NRES,
orRMS0.0.
IFAIL=2
On entry,Hi0.0 or 1.0, for some i=1,2,,NRES.
IFAIL=3
On entry,the value of a residual is too large for the given value of RMS.

7  Accuracy

Accuracy is sufficient for all practical purposes.

8  Further Comments

None.

9  Example

A set of 24 residuals and hi values from a 11 parameter model fitted to the cloud seeding data considered in Cook and Weisberg (1982) are input and the standardized residuals etc calculated and printed for the first 10 observations.

9.1  Program Text

Program Text (g02fafe.f90)

9.2  Program Data

Program Data (g02fafe.d)

9.3  Program Results

Program Results (g02fafe.r)


G02FAF (PDF version)
G02 Chapter Contents
G02 Chapter Introduction
NAG Library Manual

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