PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_univar_outlier_peirce_2var (g07gb)
Purpose
nag_univar_outlier_peirce_2var (g07gb) returns a flag indicating whether a single data point is an outlier as defined by Peirce's criterion.
Syntax
Description
nag_univar_outlier_peirce_2var (g07gb) tests a potential outlying value using Peirce's criterion. Let
- denote a vector of residuals with mean zero and variance obtained from fitting some model to a series of data ,
- denote the largest absolute residual in , i.e., for all , and let denote the data series with the observation corresponding to having been omitted,
- denote the residual variance on fitting model to ,
- denote the ratio of and with .
Peirce's method flags
as a potential outlier if
, where
and
is obtained from the solution of
where
and
is the cumulative distribution function for the standard Normal distribution.
Unlike
nag_univar_outlier_peirce_1var (g07ga), both
and
must be supplied and therefore no assumptions are made about the nature of the relationship between these two quantities. Only a single potential outlier is tested for at a time.
This function uses an algorithm described in
nag_opt_one_var_func (e04ab) to refine a lower,
, and upper,
, limit for
. This refinement stops when
or
.
References
Gould B A (1855) On Peirce's criterion for the rejection of doubtful observations, with tables for facilitating its application The Astronomical Journal 45
Peirce B (1852) Criterion for the rejection of doubtful observations The Astronomical Journal 45
Parameters
Compulsory Input Parameters
- 1:
– int64int32nag_int scalar
-
, the number of observations.
Constraint:
.
- 2:
– double scalar
-
, the value being tested.
- 3:
– double scalar
-
, the residual variance on fitting model to .
Constraint:
.
- 4:
– double scalar
-
, the residual variance on fitting model to .
Optional Input Parameters
None.
Output Parameters
- 1:
– logical scalar
The result of the function.
- 2:
– double scalar
-
An estimated value of , the cutoff that indicates an outlier.
- 3:
– double scalar
-
, the lower limit for .
- 4:
– double scalar
-
, the upper limit for .
- 5:
– 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:
-
-
Constraint: .
-
-
Constraint: .
-
-
Constraint: .
Constraint: .
-
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
Not applicable.
Further Comments
None.
Example
This example reads in a series of values and variances and checks whether each is a potential outlier.
The dataset used is from Peirce's original paper and consists of fifteen observations on the vertical semidiameter of Venus. Each subsequent line in the dataset, after the first, is the result of dropping the observation with the highest absolute value from the previous data and recalculating the variance.
Open in the MATLAB editor:
g07gb_example
function g07gb_example
fprintf('g07gb example results\n\n');
ns = [int64(15); 14; 13];
es = [-1.4; 1.01; 0.63];
var1s = [0.303; 0.161; 0.103];
var2s = [0.161; 0.103; 0.08];
for i = 1:numel(ns)
[outlier, x, lx, ux, ifail] = ...
g07gb( ...
ns(i), es(i), var1s(i), var2s(i));
fprintf('\nSample size : %10d\n', ns(i));
fprintf('Largest absolute residual (E) : %10.3f\n', es(i));
fprintf('Variance for whole sample : %10.3f\n', var1s(i));
fprintf('Variance excluding E : %10.3f\n', var2s(i));
fprintf('Estimate for cutoff (X) : %10.3f\n', x);
fprintf('Lower limit for cutoff (LX) : %10.3f\n', lx);
fprintf('Upper limit for cutoff (UX) : %10.3f\n', ux);
if outlier
fprintf('E is a potential outlier\n');
else
fprintf('E does not appear to be an outlier\n');
end
end
g07gb example results
Sample size : 15
Largest absolute residual (E) : -1.400
Variance for whole sample : 0.303
Variance excluding E : 0.161
Estimate for cutoff (X) : 0.000
Lower limit for cutoff (LX) : 0.000
Upper limit for cutoff (UX) : 0.000
E is a potential outlier
Sample size : 14
Largest absolute residual (E) : 1.010
Variance for whole sample : 0.161
Variance excluding E : 0.103
Estimate for cutoff (X) : 0.105
Lower limit for cutoff (LX) : 0.100
Upper limit for cutoff (UX) : 0.110
E is a potential outlier
Sample size : 13
Largest absolute residual (E) : 0.630
Variance for whole sample : 0.103
Variance excluding E : 0.080
Estimate for cutoff (X) : 1.059
Lower limit for cutoff (LX) : 1.011
Upper limit for cutoff (UX) : 1.155
E does not appear to be an outlier
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015