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)

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β + ε,
y=Xβ+ε,
where yy is a vector of length nn of the dependent variable,
XX is an nn by pp matrix of the independent variables,
ββ is a vector of length pp of unknown parameters,
and εε is a vector of length nn of unknown random errors such that varε = σ2Ivarε=σ2I.
The residuals are given by
r = y = yXβ̂
r=y-y^=y-Xβ^
and the fitted values, = Xβ̂y^=Xβ^, can be written as HyHy for an nn by nn matrix HH. The iith diagonal elements of HH, hihi, give a measure of the influence of the iith values of the independent variables on the fitted regression model. The values of rr and the hihi 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 iith residual is standardized by its variance when the estimate of σ2σ2, s2s2, is calculated from all the data; this is known as internal Studentization.
RIi = (ri)/(s×sqrt(1hi)).
RIi=ris1-hi .
(ii) The iith residual is standardized by its variance when the estimate of σ2σ2, si2s-i2 is calculated from the data excluding the iith observation; this is known as external Studentization.
REi = (ri)/(sisqrt(1hi)) = risqrt((np1)/(npRIi2)).
REi=ris-i1-hi =rin-p-1 n-p-RIi2 .
The two measures of influence are:
(i) Cook's DD 
Di = 1/pREi2(hi)/(1hi).
Di=1pREi2hi1-hi .
(ii) Atkinson's TT 
Ti = |REi|sqrt( ((np)/p) ((hi)/(1hi)) ).
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
nn, the number of observations included in the regression.
Constraint: n > ip + 1n>ip+1.
2:     ip – int64int32nag_int scalar
pp, the number of linear parameters estimated in the regression model.
Constraint: ip1ip1.
3:     res(nres) – double array
nres, the dimension of the array, must satisfy the constraint 1nresn1nresn.
The residuals, riri.
4:     h(nres) – double array
nres, the dimension of the array, must satisfy the constraint 1nresn1nresn.
The diagonal elements of HH, hihi, corresponding to the residuals in res.
Constraint: 0.0 < h(i) < 1.00.0<hi<1.0, for i = 1,2,,nresi=1,2,,nres.
5:     rms – double scalar
The estimate of σ2σ2 based on all nn observations, s2s2, i.e., the residual mean square.
Constraint: rms > 0.0rms>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: 1nresn1nresn.

Input Parameters Omitted from the MATLAB Interface

ldsres

Output Parameters

1:     sres(ldsres,44) – double array
ldsresnresldsresnres.
The standardized residuals and influence statistics.
For the observation with residual, riri, given in res(i)resi.
sres(i,1)sresi1
Is the internally standardized residual, RIiRIi.
sres(i,2)sresi2
Is the externally standardized residual, REiREi.
sres(i,3)sresi3
Is Cook's DD statistic, DiDi.
sres(i,4)sresi4
Is Atkinson's TT statistic, TiTi.
2:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:
  ifail = 1ifail=1
On entry,ip < 1ip<1,
ornip + 1nip+1,
ornres < 1nres<1,
ornres > nnres>n,
orldsres < nresldsres<nres,
orrms0.0rms0.0.
  ifail = 2ifail=2
On entry,h(i)0.0hi0.0 or 1.01.0, for some i = 1,2,,nresi=1,2,,nres.
  ifail = 3ifail=3
On entry,the value of a residual is too large for the given value of rms.

Accuracy

Accuracy is sufficient for all practical purposes.

Further Comments

None.

Example

function nag_correg_linregm_stat_resinf_example
n = int64(24);
ip = int64(11);
res = [0.266;
     -0.1387;
     -0.2971;
     0.5926;
     -0.4013;
     0.1396;
     -1.3173;
     1.1226;
     0.0321;
     -0.7111];
h = [0.5519;
     0.9746;
     0.6256;
     0.3144;
     0.4106;
     0.6268;
     0.5479;
     0.2325;
     0.4115;
     0.3577];
rms = 0.5798;
[sres, ifail] = nag_correg_linregm_stat_resinf(n, ip, res, h, rms)
 

sres =

    0.5219    0.5067    0.0305    0.6113
   -1.1429   -1.1578    4.5566   -7.7966
   -0.6377   -0.6225    0.0618   -0.8747
    0.9399    0.9354    0.0368    0.6886
   -0.6865   -0.6718    0.0298   -0.6096
    0.3001    0.2893    0.0138    0.4076
   -2.5729   -3.5286    0.7293   -4.2230
    1.6829    1.8282    0.0780    1.0939
    0.0550    0.0528    0.0002    0.0480
   -1.1653   -1.1830    0.0687   -0.9598


ifail =

                    0


function g02fa_example
n = int64(24);
ip = int64(11);
res = [0.266;
     -0.1387;
     -0.2971;
     0.5926;
     -0.4013;
     0.1396;
     -1.3173;
     1.1226;
     0.0321;
     -0.7111];
h = [0.5519;
     0.9746;
     0.6256;
     0.3144;
     0.4106;
     0.6268;
     0.5479;
     0.2325;
     0.4115;
     0.3577];
rms = 0.5798;
[sres, ifail] = g02fa(n, ip, res, h, rms)
 

sres =

    0.5219    0.5067    0.0305    0.6113
   -1.1429   -1.1578    4.5566   -7.7966
   -0.6377   -0.6225    0.0618   -0.8747
    0.9399    0.9354    0.0368    0.6886
   -0.6865   -0.6718    0.0298   -0.6096
    0.3001    0.2893    0.0138    0.4076
   -2.5729   -3.5286    0.7293   -4.2230
    1.6829    1.8282    0.0780    1.0939
    0.0550    0.0528    0.0002    0.0480
   -1.1653   -1.1830    0.0687   -0.9598


ifail =

                    0



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–2013