NAG CL Interface
g02fac (linregm_​stat_​resinf)

Settings help

CL Name Style:

1 Purpose

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

2 Specification

#include <nag.h>
void  g02fac (Integer n, Integer ip, Integer nres, const double res[], const double h[], double rms, double sres[], NagError *fail)
The function may be called by the names: g02fac, nag_correg_linregm_stat_resinf or nag_regsn_std_resid_influence.

3 Description

For the general linear regression model is defined by
y = X β + ε  
where y is a vector of length n of the dependent variable,
X is an n × p matrix of the independent variables,
β is a vector of length p of unknown arguments,
and ε is a vector of length n of unknown random errors such that varε = σ 2 I .
The residuals are given by
r = y - y ^ = y - X β ^ .  
The fitted values, y ^ = X β ^ , can be written as Hy for an n × n matrix H . The i th diagonal element of H , h i , gives a measure of the influence of the i th value of the independent variables on the fitted regression model. The values of r and the h i are returned by g02dac.
g02fac 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:
  1. (a)The i th residual is standardized by its variance when the estimate of σ 2 , s 2 , is calculated from all the data; known as internal studentization.
    RI i = r i s 1 - h i .  
  2. (b)The i th residual is standardized by its variance when the estimate of σ 2 , s -i 2 is calculated from the data excluding the i th observation; known as external studentization.
    RE i = r i s -i 1 - h i = r i n-p - 1 n - p - R I i 2 .  
The two measures of influence are:
  1. (a)Cook's D
    D i = 1 p RE i 2 h i 1 - h i  
  2. (b)Atkinson's T
    T i = | RE i | ( n-p p ) ( h i 1 - h i ) .  

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 Arguments

1: n Integer Input
On entry: number of observations included in the regression, n .
Constraint: n > ip + 1 .
2: ip Integer Input
On entry: the number of linear arguments estimated in the regression model, p .
Constraint: ip1 .
3: nres Integer Input
On entry: the number of residuals.
Constraint: 1 nres n .
4: res[nres] const double Input
On entry: the residuals, r i .
5: h[nres] const double Input
On entry: the diagonal elements of H , h i , corresponding to the residuals in res.
Constraint: 0.0 < h[i] < 1.0 , for i=0,1,,nres - 1.
6: rms double Input
On entry: the estimate of σ 2 based on all n observations, s 2 , i.e., the residual mean square.
Constraint: rms>0.0 .
7: sres[nres×4] double Output
On exit: the standardized residuals and influence statistics.
For the observation with residual given in res[i] :
  • sres[(i)×4] is the internally studentized residual
  • sres[(i)×4+1] is the externally studentized residual
  • sres[(i)×4+2] is Cook's D statistic
  • sres[(i)×4+3] is Atkinson's T statistic.
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

On entry, nres=value while n=value . These arguments must satisfy nresn .
On entry, n=value while ip + 1 = value. These arguments must satisfy n > ip + 1 .
On entry, ip=value.
Constraint: ip1.
On entry, nres=value.
Constraint: nres1.
On entry, h[value] must not be greater than or equal to 1.0: h[value] = value.
On entry, h[value] must not be less than or equal to 0.0: h[value] = value.
On entry, rms must not be less than or equal to 0.0: rms=value .
On entry, the value of a residual is too large for the given value of rms: res[value] = value, rms=value .

7 Accuracy

Accuracy is sufficient for all practical purposes.

8 Parallelism and Performance

Background information to multithreading can be found in the Multithreading documentation.
g02fac is not threaded in any implementation.

9 Further Comments


10 Example

A set of 24 residuals and h i values from an 11 argument 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.

10.1 Program Text

Program Text (g02face.c)

10.2 Program Data

Program Data (g02face.d)

10.3 Program Results

Program Results (g02face.r)