G07GBF (PDF version)
G07 Chapter Contents
G07 Chapter Introduction
NAG Library Manual

NAG Library Routine Document

G07GBF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

 Contents

    1  Purpose
    7  Accuracy

1  Purpose

G07GBF returns a flag indicating whether a single data point is an outlier as defined by Peirce's criterion.

2  Specification

FUNCTION G07GBF ( N, E, VAR1, VAR2, X, LX, UX, IFAIL)
LOGICAL G07GBF
INTEGER  N, IFAIL
REAL (KIND=nag_wp)  E, VAR1, VAR2, X, LX, UX

3  Description

G07GBF tests a potential outlying value using Peirce's criterion. Let
Peirce's method flags e~ as a potential outlier if e~x, where x=σ2z and z is obtained from the solution of
R = λ 1-n n-1 n-1 nn (1)
where
R = 2 exp z2 - 1 2 1- Φz (2)
and Φ is the cumulative distribution function for the standard Normal distribution.
Unlike G07GAF, both σ2 and σ~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 routine uses an algorithm described in E04ABF/E04ABA to refine a lower, l, and upper, u, limit for x. This refinement stops when e~<l or e~>u.

4  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

5  Parameters

1:     N – INTEGERInput
On entry: n, the number of observations.
Constraint: N3.
2:     E – REAL (KIND=nag_wp)Input
On entry: e~, the value being tested.
3:     VAR1 – REAL (KIND=nag_wp)Input
On entry: σ2, the residual variance on fitting model M to y.
Constraint: VAR1>0.0.
4:     VAR2 – REAL (KIND=nag_wp)Input
On entry: σ~2, the residual variance on fitting model M to y~.
Constraints:
  • VAR2>0.0;
  • VAR2<VAR1.
5:     X – REAL (KIND=nag_wp)Output
On exit: an estimated value of x, the cutoff that indicates an outlier.
6:     LX – REAL (KIND=nag_wp)Output
On exit: l, the lower limit for x.
7:     UX – REAL (KIND=nag_wp)Output
On exit: u, the upper limit for x.
8:     IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to 0, -1​ or ​1. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1​ or ​1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is 0. When the value -1​ or ​1 is used it is essential to test the value of IFAIL on exit.
On exit: IFAIL=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6  Error Indicators and Warnings

If on entry IFAIL=0 or -1, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Errors or warnings detected by the routine:
IFAIL=1
On entry, N=value.
Constraint: N3.
IFAIL=3
On entry, VAR1=value.
Constraint: VAR1>0.0.
IFAIL=4
On entry, VAR1=value, VAR2=value.
Constraint: VAR2<VAR1.
On entry, VAR2=value.
Constraint: VAR2>0.0.
IFAIL=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.8 in the Essential Introduction for further information.
IFAIL=-399
Your licence key may have expired or may not have been installed correctly.
See Section 3.7 in the Essential Introduction for further information.
IFAIL=-999
Dynamic memory allocation failed.
See Section 3.6 in the Essential Introduction for further information.

7  Accuracy

Not applicable.

8  Parallelism and Performance

Not applicable.

9  Further Comments

None.

10  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.

10.1  Program Text

Program Text (g07gbfe.f90)

10.2  Program Data

Program Data (g07gbfe.d)

10.3  Program Results

Program Results (g07gbfe.r)


G07GBF (PDF version)
G07 Chapter Contents
G07 Chapter Introduction
NAG Library Manual

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