PDF version (NAG web site
, 64-bit version, 64-bit version)
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
Description
For the general linear regression model
where |
is a vector of length of the dependent variable, |
|
is an by matrix of the independent variables, |
|
is a vector of length of unknown arguments, |
and |
is a vector of length of unknown random errors such that . |
The residuals are given by
and the fitted values,
, can be written as
for an
by
matrix
. The
th diagonal elements of
,
, give a measure of the influence of the
th values of the independent variables on the fitted regression model. The values of
and the
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 th residual is standardized by its variance when the estimate of , , is calculated from all the data; this is known as internal Studentization.
|
(ii) |
The th residual is standardized by its variance when the estimate of , is calculated from the data excluding the th observation; this is known as external Studentization.
|
The two measures of influence are:
(i) |
Cook's
|
(ii) |
Atkinson's
|
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:
– int64int32nag_int scalar
-
, the number of observations included in the regression.
Constraint:
.
- 2:
– int64int32nag_int scalar
-
, the number of linear arguments estimated in the regression model.
Constraint:
.
- 3:
– double array
-
The residuals, .
- 4:
– double array
-
The diagonal elements of
,
, corresponding to the residuals in
res.
Constraint:
, for .
- 5:
– double scalar
-
The estimate of based on all observations, , i.e., the residual mean square.
Constraint:
.
Optional Input Parameters
- 1:
– 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:
.
Output Parameters
- 1:
– double array
-
The standardized residuals and influence statistics.
For the observation with residual,
, given in
.
- Is the internally standardized residual, .
- Is the externally standardized residual, .
- Is Cook's statistic, .
- Is Atkinson's statistic, .
- 2:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Errors or warnings detected by the function:
-
-
On entry, | , |
or | , |
or | , |
or | , |
or | , |
or | . |
-
-
On entry, | or , for some . |
-
-
On entry, | the value of a residual is too large for the given value of rms. |
-
An unexpected error has been triggered by this routine. Please
contact
NAG.
-
Your licence key may have expired or may not have been installed correctly.
-
Dynamic memory allocation failed.
Accuracy
Accuracy is sufficient for all practical purposes.
Further Comments
None.
Example
A set of
residuals and
values from a
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
observations.
Open in the MATLAB editor:
g02fa_example
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;
[sres, ifail] = g02fa( ...
n, ip, res, h, rms);
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)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015