Tools › Statistics › Descriptive and Outliers › Data Summary and Outliers


Data Summary and Outliers

Descriptive statistics, normality tests and outlier tests for the columns of a pasted table: n, missing cells, mean, standard deviation, standard error and the 95 % t interval, median, quartiles (type 7 and the Tukey hinges), IQR, range, CV, MAD, 10 % trimmed mean, skewness and excess kurtosis with their standard errors; normality by Shapiro–Wilk, Anderson–Darling and the D'Agostino–Pearson K² omnibus; outliers by Tukey's fences, Grubbs' test (iterated), Dixon's ratio with Rorabacher's table and Rosner's generalized ESD test for several outliers; Pearson and Spearman correlations when two or more columns are chosen; a histogram with the normal curve, a box plot and a normal Q–Q plot. The default data are the NIST/SEMATECH e-Handbook heat flow meter calibration set (195 values, case study 1.4.2.8), whose printed mean, standard deviation, confidence interval, autocorrelation and Grubbs statistic the page reproduces, beside an illustrative small column with one planted outlier.

  • Report-ready summary table of every chosen column: location, spread, quartiles by two definitions, shape measures with standard errors

  • Normality by Shapiro–Wilk (AS R94), Anderson–Darling with the estimated-parameter correction and the D'Agostino–Pearson K² test

  • Outliers named by value and row: Tukey's fences at 1.5 and 3 IQR, iterated Grubbs, Dixon's ratio (n ≤ 30) and the generalized ESD test

  • Pearson r with t p-values and Spearman ρ on the rows two columns share; histogram, box plot and Q–Q plot of a chosen column

Data Summary and Outliers


Unit System: /

Data (first line = column names; cells separated by commas, tabs, semicolons or spaces; a blank or NA cell is missing)



Options




×

Data Summary and Outliers

Descriptive Statistics, Normality Tests and Outlier Tests

What the tool does

A pasted table (one row per line, cells separated by commas, tabs, semicolons or spaces, the first line read as the header when it holds any non-numeric cell) is summarized column by column. Missing cells (blank, NA, NaN, a dot or a dash) are counted and skipped. For every chosen column the tool reports the location, spread and shape measures of the summary table, three tests of normality, four outlier procedures, and, when two or more columns are chosen, their pairwise correlations on the rows both share. One column, chosen by number, gets the worked equations with the substituted numbers and the three figures. The default data are the NIST/SEMATECH e-Handbook heat flow meter calibration set (case study 1.4.2.8, 195 values), whose printed summary statistics, confidence intervals, lag-1 autocorrelation and Grubbs statistic the page reproduces, beside an illustrative 12-value column with one planted outlier that shows every outlier test firing.

Location and spread

The mean and the standard deviation s (denominator n − 1) describe a roughly symmetric sample; the standard error s/√n is the standard deviation of the mean itself, and the 95 % confidence interval of the mean is mean ± t0.975, n−1 s/√n with Student's t. The interval of s uses the chi-square distribution of (n − 1)s²/σ². The median, the quartiles and the interquartile range IQR = Q3 − Q1 describe the sample without being pulled by its extremes. Quartiles have several definitions, and two are shown: the type 7 rule of Hyndman and Fan (1996), linear interpolation of the order statistics at position (n − 1)p + 1, which R, NumPy, Excel and most spreadsheets use by default; and Tukey's hinges (1977), the medians of the lower and upper halves of the ordered sample, the sample median counted in both halves when n is odd (the depth of a hinge is (⌊(n + 1)/2⌋ + 1)/2, a fractional depth averaging the two values about it). The two agree for many n and differ a little for others; the box plot and the fences follow Tukey. The coefficient of variation is s/|mean|. The median absolute deviation MAD = median|xi − median| is a robust scale; multiplied by 1.4826 = 1/Φ−1(0.75) it estimates σ for a normal sample. The 10 % trimmed mean drops the ⌊0.1n⌋ smallest and largest values and averages the rest, a compromise between the mean and the median.

Shape: skewness and kurtosis

With the central moments mk = Σ(xi − x̄)k/n, the Fisher–Pearson skewness is g1 = m3/m23/2 and the excess kurtosis g2 = m4/m2² − 3, both zero for a normal distribution (NIST 1.3.5.11). Joanes and Gill (1998) compare the sample versions; the adjusted forms G1 = g1 √(n(n − 1))/(n − 2) and G2 = ((n − 1)/((n − 2)(n − 3))) ((n + 1) g2 + 6) are what Excel, SAS, SPSS and Minitab print and are less biased in small samples. Under normality the standard errors are approximately √(6/n) for the skewness and √(24/n) for the kurtosis; the exact small-sample values are SES = √(6n(n − 1)/((n − 2)(n + 1)(n + 3))) and SEK = 2 SES √((n² − 1)/((n − 3)(n + 5))). A ratio G/SE beyond about ±2 marks a departure worth noting; the formal tests below put a p-value on it. Positive skewness is a longer right tail; positive excess kurtosis means tails heavier than normal (leptokurtic), typically with a sharper peak, and negative excess kurtosis lighter tails (platykurtic), as in a uniform sample.

Normality tests

All three tests take the mean and variance as unknown and estimated from the sample (the "case 3" of the goodness-of-fit literature), which changes the null distribution of the statistics; the critical values and p-values used here are the ones for that case.

  • Shapiro–Wilk W = (Σ ai x(i))² / Σ(xi − x̄)², the squared correlation between the ordered sample and the expected normal order statistics, with the coefficients ai and the normalizing transform of Royston's (1995) Algorithm AS R94 (3 ≤ n ≤ 5000; the same code as R's shapiro.test and SciPy). W is at most 1; small W rejects normality. It is the most powerful general-purpose test for small and moderate samples.
  • Anderson–Darling A² = −n − (1/n) Σ (2i − 1)[ln F(x(i)) + ln(1 − F(x(n+1−i)))] with F the normal cdf at the sample mean and s weights the tails of the empirical distribution more than the Kolmogorov–Smirnov statistic (NIST 1.3.5.14). For estimated parameters D'Agostino and Stephens (1986, Table 4.7) give the modified statistic A* = A²(1 + 0.75/n + 2.25/n²) with the 5 % critical value 0.752 and, in Table 4.9, a p-value formula in A*; both are reported. Stephens' earlier (1974) modification A²(1 + 4/n − 25/n²) with the critical value 0.787 is what Dataplot and the NIST case studies print as the "adjusted test statistic", so it is shown too: the two forms reach the same decision.
  • D'Agostino–Pearson K² (D'Agostino, Belanger and D'Agostino 1990) tests the skewness and the kurtosis together. The skewness g1 is transformed by D'Agostino's (1970) formula into Z1 (n ≥ 8) and the kurtosis b2 = g2 + 3 by the Anscombe–Glynn (1983) formula into Z2, each approximately standard normal under normality; K² = Z1² + Z2² is approximately χ² with 2 degrees of freedom, so p = exp(−K²/2) and the 5 % critical value is 5.991. The two Z values say how normality fails (asymmetry or tail weight); the kurtosis transform is rough below about n = 20. These are the formulas of SciPy's skewtest, kurtosistest and normaltest.

The normal probability plot correlation coefficient PPCC (Filliben 1975; NIST 1.3.3.21) is the correlation of the ordered sample with the normal quantiles of the uniform order-statistic medians; it is the straightness of the Q–Q plot as one number, 1 for a perfectly normal sample. The lag-1 autocorrelation r1 = Σ(xi − x̄)(xi+1 − x̄)/Σ(xi − x̄)² of the column in its pasted order is reported because every standard error above assumes independent values; |r1| beyond about 2/√n says consecutive values are related and the uncertainty of the mean is larger than s/√n (the heat flow meter data show r1 = 0.28, which NIST notes as a mild violation).

Outlier procedures

An outlier is an observation that deviates markedly from the rest. Finding one is a reason to investigate, not to delete: a recording or transcription error is corrected or removed, a genuine extreme is kept (it may be the most informative value in the set) or handled with the robust measures above. All the formal tests assume the bulk of the data is normal, so a rejection of normality and an outlier can be the same fact seen twice; NIST 1.3.5.17 recommends looking at the normal probability plot first. Four procedures are run:

  • Tukey's fences (1977): with the hinges HL, HU and the H-spread (the hinges' IQR), the inner fences are HL − 1.5 IQR and HU + 1.5 IQR and the outer fences HL − 3 IQR and HU + 3 IQR. Values between the inner and outer fences are "outside", beyond the outer fences "far out". The rule is descriptive, needs no distribution and no significance level, and is what a box plot shows; for a normal sample about 0.7 % of values fall outside the inner fences by chance, so in a large sample a few outside values are expected.
  • Grubbs' test (1969; NIST 1.3.5.17.1) tests one value, the most extreme, with G = max|xi − x̄|/s. The two-sided critical value is Gcrit = ((n − 1)/√n) √(t²/(n − 2 + t²)) with t the upper α/(2n) quantile of Student's t with n − 2 degrees of freedom (α/n for a one-sided test of a named end), and the p-value inverts that relation. The tool repeats the test on the remaining values while it rejects. That sequential use is common but can fail by masking: two outliers inflate s so much that neither is found at the first step, and the procedure stops with none, as it does on Rosner's 54-value example. The generalized ESD test exists for that case.
  • Dixon's ratio (1951) uses gaps between ordered values instead of the mean and s, so it is not inflated by the suspect value itself, and is meant for small samples (n ≤ 30). Rorabacher (1991) recommends r10 = (x(2) − x(1))/(x(n) − x(1)) for n = 3–7, r11 = (x(2) − x(1))/(x(n−1) − x(1)) for 8–10, r21 = (x(3) − x(1))/(x(n−1) − x(1)) for 11–13 and r22 = (x(3) − x(1))/(x(n−2) − x(1)) for 14–30, each mirrored for the high end; the higher ratios protect the test against a second outlier at either end. The suspect is the end with the larger ratio, compared with Rorabacher's two-tailed critical values at 90, 95 or 99 % (the level chosen on the form). For n ≤ 10 the simpler Q = gap/range of Dean and Dixon (1951), the "Q test" of analytical chemistry, is also shown with its own critical value. Dixon's test finds at most one outlier.
  • Generalized ESD test (extreme studentized deviate, Rosner 1983; NIST 1.3.5.17.3) for up to kmax outliers: at step i the most extreme remaining value gives Ri = max|x − x̄|/s computed on the values left, and is removed; the critical value is λi = (n − i) tp, n−i−1/√((n − i − 1 + t²)(n − i + 1)) with p = 1 − α/(2(n − i + 1)). The number of outliers is the largest i for which Ri > λi, not the first: that is what defeats masking. The test needs only an upper bound on the number of outliers, holds its overall level α approximately for n ≥ 25 and is the recommended procedure when more than one outlier is possible. kmax is capped at n − 3.

The outlier table lists every value any procedure flags, with its row in the pasted table and the procedures that flagged it, so each can be traced to its record.

Correlation

For every pair of chosen columns, on the rows where both have a number, Pearson's r = Σ(x − x̄)(y − ȳ)/√(Σ(x − x̄)² Σ(y − ȳ)²) measures linear association. Under the hypothesis of no correlation in a bivariate normal population t = r √((n − 2)/(1 − r²)) follows Student's distribution with n − 2 degrees of freedom, which gives the two-sided p-value. Spearman's ρ is Pearson's r of the ranks, ties given their average rank, and measures any monotone association; the same t approximation gives its p (as SciPy does). The two together are diagnostic: Pearson high and Spearman low means a few extreme rows drive the linear fit; Spearman high and Pearson lower means a monotone but curved relation. Anscombe's (1973) four data sets, all with r = 0.816 and the same regression line but entirely different scatter plots, are the standard warning that a coefficient is not a substitute for looking at the data.

Figures

The histogram (Figure 1) shows the values as a probability density with the normal curve of the sample mean and s, in max(6, min(25, ⌈√n⌉)) equal bins. The box plot (Figure 2) is Tukey's: the box spans the hinges, the line is the median, the whiskers end at the adjacent values (the most extreme data inside the inner fences), the dashed lines are the inner fences, and the points beyond are the outside and far-out values. The normal Q–Q plot (Figure 3) plots the ordered values against the normal quantiles of the Blom plotting positions (i − 3/8)/(n + 1/4) with the line x̄ + s·z: a straight line is normal, a bow is skew, an S is heavy or light tails, and points departing at an end are the outliers.

Reading the results

Start with the figures and the shape measures, then the normality table, then the outliers. If the normality tests reject and the outlier table names one or two values, remove them (after checking the records) and read the tests again: a normal body with a bad value is a different finding from a skewed population. If the lag-1 autocorrelation is large, the data are a time series and the confidence interval of the mean is too narrow; a run-sequence or control chart is the right next tool. The summary table is laid out for a report, statistics down and columns across; the quartile definition should be named when the numbers are quoted, since spreadsheets and texts differ.

Limits

Numbers only (dates and text columns are counted as missing); one table at a time; Shapiro–Wilk needs 3 ≤ n ≤ 5000, Anderson–Darling n ≥ 5, the skewness transform n ≥ 8 and the kurtosis transform is approximate below n ≈ 20; Dixon's table ends at n = 30; the Grubbs, Dixon and ESD tests assume an underlying normal distribution, so on a skewed column they flag the long tail; Tukey's fences on a skewed column flag the long tail too. Not included: grouped or weighted data, the Tietjen–Moore test (which needs the exact number of outliers), robust estimators beyond MAD and the trimmed mean, multivariate outliers, transformations (Box–Cox) and confidence intervals of the median and quartiles.




References

NIST/SEMATECH (2012). e-Handbook of Statistical Methods. National Institute of Standards and Technology, Gaithersburg, MD.

Tukey, J. W. (1977). Exploratory Data Analysis. Addison-Wesley, Reading, MA.

Hyndman, R. J., and Fan, Y. (1996). "Sample Quantiles in Statistical Packages." The American Statistician, Vol. 50, No. 4, pp. 361–365.

Joanes, D. N., and Gill, C. A. (1998). "Comparing Measures of Sample Skewness and Kurtosis." Journal of the Royal Statistical Society, Series D (The Statistician), Vol. 47, No. 1, pp. 183–189.

Shapiro, S. S., and Wilk, M. B. (1965). "An Analysis of Variance Test for Normality (Complete Samples)." Biometrika, Vol. 52, No. 3/4, pp. 591–611.

Royston, P. (1995). "Remark AS R94: A Remark on Algorithm AS 181: The W-test for Normality." Journal of the Royal Statistical Society, Series C (Applied Statistics), Vol. 44, No. 4, pp. 547–551.

Stephens, M. A. (1974). "EDF Statistics for Goodness of Fit and Some Comparisons." Journal of the American Statistical Association, Vol. 69, No. 347, pp. 730–737.

D'Agostino, R. B., and Stephens, M. A. (eds.) (1986). Goodness-of-Fit Techniques. Marcel Dekker, New York.

D'Agostino, R. B. (1970). "Transformation to Normality of the Null Distribution of g1." Biometrika, Vol. 57, No. 3, pp. 679–681.

Anscombe, F. J., and Glynn, W. J. (1983). "Distribution of the Kurtosis Statistic b2 for Normal Samples." Biometrika, Vol. 70, No. 1, pp. 227–234.

D'Agostino, R. B., Belanger, A., and D'Agostino, R. B., Jr. (1990). "A Suggestion for Using Powerful and Informative Tests of Normality." The American Statistician, Vol. 44, No. 4, pp. 316–321.

Filliben, J. J. (1975). "The Probability Plot Correlation Coefficient Test for Normality." Technometrics, Vol. 17, No. 1, pp. 111–117.

Grubbs, F. E. (1969). "Procedures for Detecting Outlying Observations in Samples." Technometrics, Vol. 11, No. 1, pp. 1–21.

Grubbs, F. E., and Beck, G. (1972). "Extension of Sample Sizes and Percentage Points for Significance Tests of Outlying Observations." Technometrics, Vol. 14, No. 4, pp. 847–854.

Rosner, B. (1983). "Percentage Points for a Generalized ESD Many-Outlier Procedure." Technometrics, Vol. 25, No. 2, pp. 165–172.

Dixon, W. J. (1951). "Ratios Involving Extreme Values." The Annals of Mathematical Statistics, Vol. 22, No. 1, pp. 68–78.

Dean, R. B., and Dixon, W. J. (1951). "Simplified Statistics for Small Numbers of Observations." Analytical Chemistry, Vol. 23, No. 4, pp. 636–638.

Rorabacher, D. B. (1991). "Statistical Treatment for Rejection of Deviant Values: Critical Values of Dixon's Q Parameter and Related Subrange Ratios at the 95 % Confidence Level." Analytical Chemistry, Vol. 63, No. 2, pp. 139–146.

Tietjen, G. L., and Moore, R. H. (1972). "Some Grubbs-Type Statistics for the Detection of Several Outliers." Technometrics, Vol. 14, No. 3, pp. 583–597.

Anscombe, F. J. (1973). "Graphs in Statistical Analysis." The American Statistician, Vol. 27, No. 1, pp. 17–21.

Komsta, L. (2022). outliers: Tests for Outliers, R package version 0.15. Comprehensive R Archive Network.


DISCLAIMER: The methods and calculation on aNOWysis.com are provided as means to educate the reader. There is no warranty, expessed or implied, as to the relevance or accuracy of the methods or calculations. All calculations should be checked by a qualified analyst for appropriateness and accuracy. We will not be held liable for any damages, injuries or deaths caused by using methods or calculations from this site.