<< ST_grubbs Outlier-Tests ST_nalimov >>

samplestat >> samplestat > Outlier-Tests > ST_grubbs_iterat

ST_grubbs_iterat

Iterative Grubbs outlier test without adapting critical value (Not recommended)

Syntax

[outlierfree, outlier] = ST_grubbs_iterat(v, p)
[outlierfree, outlier] = ST_grubbs_iterat(v, p, side)
[outlierfree] = ST_grubbs_iterat(v, p)
[outlierfree] = ST_grubbs_iterat(v, p, side)

Parameters

v :

vector of numerical values

p :

statistical confidence level (%) as a string or the level of significance (α) as a decimal value, "95%", "99%", "99.9%" or 0.05, 0.01, 0.001 resp (see examples).

side:

one-or two-sided "both" (default), "left", "right"

outlierfree :

input vector with the detected outlier removed; unchanged if the test does not identify an outlier

outlier :

detected outliers as a scalar vector; [] if no outlier is detected

Description

Performs an ITERATIVE Grubbs outlier test. The classic Grubbs test detects just one outlier at a time. This function applies the test iteratively on the same data record until no further outlier is found.

IMPORTANT: When ST_grubbs_iterat() repeatedly used its interative algorithm on the same data it does not adapting the critical value. After each iterative run, the statistical confidence decreases. This means that even if a confidence level of 99% was specified, the result does not correspond to that level of statistical confidence. It is lower and increases the probability of removing valid observations.

For statistically reliable outlier removal, the classic Grubbs test (ST_grubbs) is recommended. However, it can only detect one outlier in a data record. If more than one outlier is expected, Roesner-ESD (ST_esd) is the statistically clean alternative.

A warning is displayed on very output of ST_grubbs_iterat()

It is implemented for comparison purposes because it is often used this way in lab practice. Use it with care.

Confidence levels 95%, 99% or 99.9% (α: 0.05, 0.01 or 0.001) are available.

The test can be applied one- or two-sided. If “side” is set to “left,” the outliers are determined one-sided from the minimum side; if “side” is set to “right,” from the maximum side. If "side" is set to "both" or omitted the test is performed two-sided and determine outliers from the minimum and the maximum side.

The test statistic

\begin{eqnarray}
G_{two-sided} &=& \frac{\underset{i..n}{max} \left| x_i - \overline{x} \right|}{s} \\
G_{left-sided(min)} &=& \frac{\overline{x} - x_{min}}{s} \\
G_{right-sided(max)} &=& \frac{x_{max} - \overline{x}}{s} \\
\end{eqnarray}

Critical value:

\begin{eqnarray}
G_{crit} &=& \frac{n-1}{\sqrt{n}} \sqrt{\frac{t^2}{n-2+t^2}} \\ \\
t       &=& t_{\frac{1-\alpha}{2n}, n-2} \quad : \quad \text{ Student t quantile for two-sided test} \\
t       &=& t_{\frac{1-\alpha}{n}, n-2} \quad : \quad \text{ Student t quantile for on-sided test} \\
\text{and} \\
x_i     &:& \text{test value} \\
n       &:& \text{number of values} \\
s       &:& \text{sample standard deviation} \\
\bar{x} &:& \text{arithmetic mean} \\
x_{max} &:& \text{max. value} \\
x_{min} &:& \text{min value} \\
\alpha  &:& \text{statistical confidence level}
\end{eqnarray}

Decision rule

The selected observation is classified as an outlier when G > Gcrit. Equality does not lead to rejection.

Examples

data = [
0.4827129   0.3431706  -0.4127328    0.3843994 ..
-0.7107495  -0.2547306   0.0290803    0.1386087 ..
-0.7698385   1.0743628   1.0945652    0.4365680 ..
-0.5913411  -0.7426987   1.609719     0.8079680 ..
-2.1700554  -4.7361261   0.0069708    14.626386 ..
-2.5036545  -2.9046385 ..
];

// two-sided & confidence-level 95%
of = ST_grubbs_iterat(data, "95%")              // Output: outlier-free values, only
[of, o] = ST_grubbs_iterat(data, "95%", "both") // Output: outlier and outlier-free values
[of, o] = ST_grubbs_iterat(data, 0.05)

// left-sided & confidence-level 99%, outlier and outlier-free values output
[of, o] = ST_grubbs_iterat(data, "99%", "left")

// right-sided & confidence-level 99.9%, outlier and outlier-free values output
[of, o] = ST_grubbs_iterat(data, 0.001, "right")

See also

Authors


Report an issue
<< ST_grubbs Outlier-Tests ST_nalimov >>