I want to use the Q-test to determine outlier in my dataset. However, I cannot find a function to do this is in Mathematica. Does anyone know if there is a function which does this in Mathematica?
Thanks.
I want to use the Q-test to determine outlier in my dataset. However, I cannot find a function to do this is in Mathematica. Does anyone know if there is a function which does this in Mathematica?
Thanks.
If it's Dixon's Q-test that you are referring to, it's not too hard to compute the statistic; it's the CDFs and quantiles that are a bit troublesome to do. As can be seen here, the formulae for the CDF are rather complicated, which is why Rorabacher just chooses to use spline interpolation on pretabulated values (which I presume were a bit difficult to generate). I am however told that the use of Dixon's test and other such procedures is passé, however.
Anyway, as I said the statistic itself is not too hard to compute:
qstat[data_?VectorQ, mode : Min | Max] := With[{sd = Sort[data]}, (#2 - #1) & @@ Take[sd, 4 Boole[mode === Min] - 2]]/(Max[data] - Min[data])
Choose mode
as Min
or Max
, depending on whether you want to test the lowest value or the highest one as an outlier. Remember that once you've decided to remove one, it is poor form to reapply the test on the edited data.