Performs Grubbs' test for one outlier, two outliers on one tail, or two outliers on opposite tails, in small sample.
grubbs.test(x, type = 10, opposite = FALSE, two.sided = FALSE)
oppositeparameter). 11 is a test for two outliers on opposite tails, 20 is test for two outliers in one tail.
The function can perform three tests given and discussed by Grubbs (1950).
First test (10) is used to detect if the sample dataset contains one outlier, statistically different than the other values. Test is based by calculating score of this outlier G (outlier minus mean and divided by sd) and comparing it to appropriate critical values. Alternative method is calculating ratio of variances of two datasets - full dataset and dataset without outlier. The obtained value called U is bound with G by simple formula.
Second test (11) is used to check if lowest and highest value are two outliers on opposite tails of sample. It is based on calculation of ratio of range to standard deviation of the sample.
Third test (20) calculates ratio of variance of full sample and sample without two extreme observations. It is used to detect if dataset contains two outliers on the same tail.
The p-values are calculated using
Grubbs, F.E. (1950). Sample Criteria for testing outlying observations. Ann. Math. Stat. 21, 1, 27-58.
set.seed(1234) x = rnorm(10) grubbs.test(x) grubbs.test(x,type=20) grubbs.test(x,type=11)