g07ga identifies outlying values using Peirce's criterion.
Syntax
C# |
---|
public static void g07ga( int n, int p, double[] y, double mean, double var, int[] iout, out int niout, int ldiff, double[] diff, double[] llamb, out int ifail ) |
Visual Basic |
---|
Public Shared Sub g07ga ( _ n As Integer, _ p As Integer, _ y As Double(), _ mean As Double, _ var As Double, _ iout As Integer(), _ <OutAttribute> ByRef niout As Integer, _ ldiff As Integer, _ diff As Double(), _ llamb As Double(), _ <OutAttribute> ByRef ifail As Integer _ ) |
Visual C++ |
---|
public: static void g07ga( int n, int p, array<double>^ y, double mean, double var, array<int>^ iout, [OutAttribute] int% niout, int ldiff, array<double>^ diff, array<double>^ llamb, [OutAttribute] int% ifail ) |
F# |
---|
static member g07ga : n : int * p : int * y : float[] * mean : float * var : float * iout : int[] * niout : int byref * ldiff : int * diff : float[] * llamb : float[] * ifail : int byref -> unit |
Parameters
- n
- Type: System..::..Int32On entry: , the number of observations.Constraint: .
- p
- Type: System..::..Int32On entry: , the number of parameters in the model used in obtaining the . If is an observed set of values, as opposed to the residuals from fitting a model with parameters, then should be set to , i.e., as if a model just containing the mean had been used.Constraint: .
- y
- Type: array<System..::..Double>[]()[][]An array of size [n]On entry: , the data being tested.
- mean
- Type: System..::..Double
- var
- Type: System..::..Double
- iout
- Type: array<System..::..Int32>[]()[][]An array of size [n]On exit: the indices of the values in y sorted in descending order of the absolute difference from the mean, therefore , for .
- niout
- Type: System..::..Int32%
- ldiff
- Type: System..::..Int32
- diff
- Type: array<System..::..Double>[]()[][]An array of size [ldiff]On exit: holds for observation , for .
- llamb
- Type: array<System..::..Double>[]()[][]An array of size [ldiff]On exit: holds for observation , for .
- ifail
- Type: System..::..Int32%On exit: unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).
Description
g07ga flags outlying values in data using Peirce's criterion. Let
- denote a vector of observations (for example the residuals) obtained from a model with parameters,
- denote the number of potential outlying values,
- and denote the mean and variance of respectively,
- denote a vector of length constructed by dropping the values from with the largest value of ,
- denote the (unknown) variance of ,
- 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.
(1) |
(2) |
As is unknown an assumption is made that the relationship between and , hence , depends only on the sum of squares of the rejected observations and the ratio estimated as
which gives
(3) |
A value for the cutoff is calculated iteratively. An initial value of is used and a value of is estimated using equation (1). Equation (3) is then used to obtain an estimate of and then equation (2) is used to get a new estimate for . This process is then repeated until the relative change in between consecutive iterations is , where is machine precision.
By construction, the cutoff for testing for potential outliers is less than the cutoff for testing for potential outliers. Therefore Peirce's criterion is used in sequence with the existence of a single potential outlier being investigated first. If one is found, the existence of two potential outliers is investigated etc.
If one of a duplicate series of observations is flagged as an outlier, then all of them are flagged as outliers.
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
Error Indicators and Warnings
Errors or warnings detected by the method:
- On entry, .
- On entry, or .
Accuracy
Not applicable.
Parallelism and Performance
None.
Further Comments
One problem with Peirce's algorithm as implemented in g07ga is the assumed relationship between , the variance using the full dataset, and , the variance with the potential outliers removed. In some cases, for example if the data were the residuals from a linear regression, this assumption may not hold as the regression line may change significantly when outlying values have been dropped resulting in a radically different set of residuals. In such cases g07gb should be used instead.
Example
This example reads in a series of data and flags any potential outliers.
The dataset used is from Peirce's original paper and consists of fifteen observations on the vertical semidiameter of Venus.
Example program (C#): g07gae.cs