hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_correg_linregm_stat_resinf (g02fa)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_correg_linregm_stat_resinf (g02fa) calculates two types of standardized residuals and two measures of influence for a linear regression.

Syntax

[sres, ifail] = g02fa(n, ip, res, h, rms, 'nres', nres)
[sres, ifail] = nag_correg_linregm_stat_resinf(n, ip, res, h, rms, 'nres', nres)

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 arguments,
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 nag_correg_linregm_fit (g02da).
nag_correg_linregm_stat_resinf (g02fa) 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 .  

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

Parameters

Compulsory Input Parameters

1:     n int64int32nag_int scalar
n, the number of observations included in the regression.
Constraint: n>ip+1.
2:     ip int64int32nag_int scalar
p, the number of linear arguments estimated in the regression model.
Constraint: ip1.
3:     resnres – double array
The residuals, ri.
4:     hnres – double array
The diagonal elements of H, hi, corresponding to the residuals in res.
Constraint: 0.0<hi<1.0, for i=1,2,,nres.
5:     rms – double scalar
The estimate of σ2 based on all n observations, s2, i.e., the residual mean square.
Constraint: rms>0.0.

Optional Input Parameters

1:     nres int64int32nag_int scalar
Default: the dimension of the arrays res, h. (An error is raised if these dimensions are not equal.)
The number of residuals.
Constraint: 1nresn.

Output Parameters

1:     sresldsres4 – double array
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.
2:     ifail int64int32nag_int scalar
ifail=0 unless the function detects an error (see Error Indicators and Warnings).

Error Indicators and Warnings

Errors or warnings detected by the function:
   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.
   ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
   ifail=-399
Your licence key may have expired or may not have been installed correctly.
   ifail=-999
Dynamic memory allocation failed.

Accuracy

Accuracy is sufficient for all practical purposes.

Further Comments

None.

Example

A set of 24 residuals and hi values from a 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.
function g02fa_example


fprintf('g02fa example results\n\n');

res = [ 0.2660  -0.1387  -0.2971   0.5926  -0.4013   0.1396 ...
       -1.3173   1.1226   0.0321  -0.7111   0.3439  -0.4379 ...
        0.0633  -0.0936   0.9968   0.0209  -0.4056   0.1396 ...
        0.0327   0.2970  -0.2277   0.5180   0.5301  -1.0650 ];

h   = [ 0.5519   0.9746   0.6256   0.3144   0.4106   0.6268 ...
        0.5479   0.2325   0.4115   0.3577   0.3342   0.1673 ...
        0.3874   0.1705   0.3466   0.3743   0.7527   0.9069 ...
        0.2610   0.6256   0.2485   0.3072   0.5848   0.4794 ];

n  = int64(numel(res));
ip = int64(11);
rms  = 0.5798;

% Calculate standardised residuals
[sres, ifail] = g02fa( ...
                       n, ip, res, h, rms);

% Display results
fprintf('        Internally    Internally\n');
fprintf('Obs.   standardized  standardized   Cook''s D   Atkinson''s T\n');
fprintf('         residuals     residuals\n\n');
for j = 1:ip-1
  fprintf('%2d%13.3f%13.3f%13.3f%13.3f\n',j,sres(j,1:4))
end


g02fa example results

        Internally    Internally
Obs.   standardized  standardized   Cook's D   Atkinson's T
         residuals     residuals

 1        0.522        0.507        0.030        0.611
 2       -1.143       -1.158        4.557       -7.797
 3       -0.638       -0.622        0.062       -0.875
 4        0.940        0.935        0.037        0.689
 5       -0.686       -0.672        0.030       -0.610
 6        0.300        0.289        0.014        0.408
 7       -2.573       -3.529        0.729       -4.223
 8        1.683        1.828        0.078        1.094
 9        0.055        0.053        0.000        0.048
10       -1.165       -1.183        0.069       -0.960

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

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