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_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

[result, x, lx, ux, ifail] = g07gb(n, e, var1, var2)
[result, x, lx, ux, ifail] = nag_univar_outlier_peirce_2var(n, e, var1, var2)

Description

nag_univar_outlier_peirce_2var (g07gb) tests a potential outlying value using Peirce's criterion. Let
Peirce's method flags e~ as a potential outlier if ||x|e~|x, where x = σ2zx=σ2z and zz is obtained from the solution of
R = λ1n ( (n1)n1 )/(nn)
R = λ 1-n (n-1) n-1 nn
(1)
where
R = 2 exp((( z2 1 )/2)(1Φ(z)))
R = 2 exp( ( z2 - 1 2 ) ( 1- Φ(z) ) )
(2)
and ΦΦ is the cumulative distribution function for the standard Normal distribution.
Unlike nag_univar_outlier_peirce_1var (g07ga), both σ2σ2 and σ̃2σ~2 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, ll, and upper, uu, limit for xx. This refinement stops when || < l|e~|<l or || > u|e~|>u.

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:     n – int64int32nag_int scalar
nn, the number of observations.
Constraint: n3n3.
2:     e – double scalar
e~, the value being tested.
3:     var1 – double scalar
σ2σ2, the residual variance on fitting model MM to yy.
Constraint: var1 > 0.0var1>0.0.
4:     var2 – double scalar
σ̃2σ~2, the residual variance on fitting model MM to y~.
Constraints:

Optional Input Parameters

None.

Input Parameters Omitted from the MATLAB Interface

None.

Output Parameters

1:     result – logical scalar
The result of the function.
2:     x – double scalar
An estimated value of xx, the cutoff that indicates an outlier.
3:     lx – double scalar
ll, the lower limit for xx.
4:     ux – double scalar
uu, the upper limit for xx.
5:     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
Constraint: n3n3.
  ifail = 3ifail=3
Constraint: var1 > 0.0var1>0.0.
  ifail = 4ifail=4
Constraint: var2 < var1var2<var1.
Constraint: var2 > 0.0var2>0.0.

Accuracy

Not applicable.

Further Comments

None.

Example

function nag_univar_outlier_peirce_2var_example
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:3
  % Check whether es(i) is a potential outlier
  [outlier, x, lx, ux, ifail] = nag_univar_outlier_peirce_2var(ns(i), es(i), var1s(i), var2s(i));

  % Display results
  if ifail == 0
    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
end
 

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

function g07gb_example
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:3
  % Check whether es(i) is a potential outlier
  [outlier, x, lx, ux, ifail] = g07gb(ns(i), es(i), var1s(i), var2s(i));

  % Display results
  if ifail == 0
    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
end
 

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)
Chapter Contents
Chapter Introduction
NAG Toolbox

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