This function finds the Tukey's q studentized range critical value. This modified macro is based on the Fortran77 algorithm AS 190.2 Appl. Statist. (1983). It needs the sample degrees of freedom (must be the same for each sample), the k number of samples and the p-cumulative probability value (default=0.95). It gives a very good approximation for 0.8 < p < 0.995).
The statistics toolbox does have a private function that implements AS 190 and 190.2 under toolbox/stats/private/stdrinv.m from R2011a. It is called from the multcompare tool when doing the default Tukey HSD comparison.
The note accompanying the code is
% Based on Fortran program from statlib, http://lib.stat.cmu.edu
% Algorithm AS 190 Appl. Statist. (1983) Vol.32, No. 2
% Incorporates corrections from Appl. Statist. (1985) Vol.34 (1)
qTukey() not very accurate.
qTukey implements an algorithm (AS 190.2, called qtrng0() in the Fortran) which was only intended to be a first approximation of Tukey's q. qtrng0 was intended to serve as a startup estimate for the more accurate routine, AS 190.1, called qtrng() in the Fortran. qtrng() uses AS 190, called prtrng() in the Fortran. ptrng() computes a p value for a given q statistic. qtrng() computes q for a desired probability p by recursively calling prtrng() and updating its estimate for q, until the desired accuracy is achieved (p within 0.001 in the Fortran code). If someone converts the Fortran routines prtrng() and qrtrng to m files, then we will have a good algorithm for estimating Tukey's q. Fortran code at http://lib.stat.cmu.edu/apstat/190.
03 Apr 2006
Not accurate. For example, qtukey(20,11,0.99) is 6.1422, while in the tables it is 6.190.