Basic Concepts
Definition 1: Suppose that we take a sample of size n from each of k populations with the same normal distribution N(μ,σ2) and suppose that x̄min is the smallest of these sample means and x̄max is the largest of these sample means, and suppose s2 is the pooled sample variance from these samples. Then the following random variable has a Studentized range distribution.
This distribution is related to the t distribution and is very useful especially in follow-up testing for ANOVA such as Tukey’s HSD (see Unplanned Comparisons).
Tables of critical values for this distribution can be found in Studentized Range q Table.
Worksheet Functions
Real Statistics Functions: The following functions are supplied by the Real Statistics Resource Pack
QDIST(q, k, df) = value at q of the studentized range distribution with k independent variables and df degrees of freedom
QINV(p, k, df, tails) = inverse of the studentized q distribution, i.e. the critical value for the studentized q range; tails = the number of tails and takes on the value 1 or 2 (default); QINV(p, k, df) has the value q such that QDIST(q, k, df) = p.
QPROB(q, k, df, tails, iter, interp) = estimated p-value for the studentized range q distribution at q for the distribution with k groups, degrees of freedom df; iter is the number of iterations used to calculate the p-value from the table of critical values (default 40).
QCRIT(k, df, α, tails, interp) = the critical value for the studentized q range based on the entries in the tables found in Studentized Range q Table, making a linear interpolation for entries between entries in the table; α is a number between 0 and 1 (default .05).
Here, tails = 1 or 2 (default) and interp = TRUE (default) for recommended interpolation and FALSE (linear interpolation)
Note that theoretically QINV(p, k, df) = QCRIT(k, df, p), but whereas QCRIT does a table lookup, QINV makes a calculation of the critical value. Generally, for values shown in the tables, QCRIT is more accurate, while for values outside the table QINV is usually preferred. The relationship between QDIST(q, k, df) and QPROB(q, k, df) is similar.
Finally, note that if df is omitted in QDIST, QCRIT and QPROB, it defaults to infinity. This is equivalent to 500 for QCRIT and QPROB and 2400 for QDIST.
Reference
Ferreira, D. F., Demetrio, C. G. B., Manly, B. F. J, Machado, A. de A. (2007) Quantile from the maximum studentized range distribution
https://www.researchgate.net/publication/325670415_QXLA_Adding_Upper_Quantiles_for_the_Studentized_Range_to_Excel_for_Multiple_Comparison_Procedures
Lane, D. M. (2023) Studentized range distribution
https://onlinestatbook.com/2/calculators/studentized_range_dist.html
Is there someplace to find out the mathematical formula of the QINV function so that we can calculate it ourselves without depending on Tukey’s critical value table and if we don’t use Excel?
It requires more than a simple formula. An algorithm for calculating QINV is given in the reference at the bottom of the following webpage:
https://www.real-statistics.com/students-t-distribution/studentized-range-distribution/
Charles
Hi. Thank you for putting this comprehensive add-in together. Very useful for us non-SPSS users!
I ran some Games Howell tests for ANOVA post-hoc analysis and I noticed that some p-values in the Q test table are negative. Here is an example: QDIST(19.80,4,937.18) = -3.69×10^-13
Are these negative p values meaningful or interpretable under the definition of the Q distribution?
Hello Chris,
This is a very small number and for all practical purposes this number can be considered to be zero.
Charles
Charles,
Thanks for your sharing. I am wondering whether I can find Q critical value with alpha<0.001? For example, alpha=10^-6?
Thanks!
Hui-Min
Hui-Min,
You can use the Real Statistics function QINV to do this. I don’t really know how accurate the result will be for such extreme values of alpha.
Charles
Would you mind sharing the equation behind the Qdist() function? I can not find much documentation on this distribution. I though I had found an expression, but when I perform numerical integration, my results do not match table values exactly. They are off by about 10%.
When k=2, I know it is 2*(t.dist(q/sqrt(2),df) – 1). and when df approaches infinity, it’s:
k * ∫ norm.s.dist(z,false)[norm.s.dist(z+w,true) – norm.s.dist(z,true)]ᵏ⁻¹ dz
Would you mind sharing the equation behind the Qdist() function? I can not find much documentation on this distribution. I though I had founf an expression, but when I perform numerical integration, my results do not match table values exactly. They are off by about 10%.
Kevin,
It is not an equation, but a fairly complicated program.
Charles
Is it more complicated than a numerical integration? Would you mind explaining the method? Besides providing table values, literature is very spotty on how the values arise.
When k=2, I know it is 2*(t.dist(q/sqrt(2),df) – 1). and when df approaches infinity, it’s:
k * ∫ norm.s.dist(z/sqrt(2),false)[norm.s.dist((z+w)/sqrt(2),true) – norm.s.dist(z/sqrt(2),true)]ᵏ⁻¹ dz. I can integrate the second equation in Excel and get perfect matches between literature and spreadsheet. Replacing norm.s.dist with t.dist is close, but not perfect (unless df approaches infinity of course).
Typo:
Q = 2*(t.dist(q/sqrt(2),df, true) – .5)
Kevin,
I can’t recall the details, but I do recall having to do a lot of work to create the distribution program.
Charles
Hi Charles Thanks a lot for your contribution, and do you know more reference about this calculated? How do you find this value a step, as you did in other examples? Where to find?
Fabio,
I don’t understand your question. Are you asking me how to calculate the p-value or critical value of the studentized range distribution?
Charles
hello! how can i duplicate the studentized range distribution? and where can i get the different functions you listed? thankyou for your response 😉
Hello Myra,
These functions are included in the Real Statistics Resource Pack. You can download this for free by going to the webpage
Real Statistics Download.
Charles
is the formula given above can solve the critical value that exists on Tukey distribution table? Thankyou for your response.
The values should be approximately the same.
Charles
QINV as downloaded this week has a last parameter B. I see no documentation about what that is.
Rod,
If b = TRUE then sometimes instead of using the calculation based on QDIST, the function uses the critical value found in the table, i.e. the value returned by QCRIT. This is because in the extreme situations the calculations using QDIST are not very accurate. The table lookup is used instead when (1) df = 1 And (p <= 0.025 Or p = 0.05 Or p = 0.1) or when (2) df = 2 and .001 <= p <= .01 or when df = 3 and p = .001. I have not explained this since I don't expect anyone to set b to FALSE (the default is TRUE). I plan to revisit this issue sometime in the future and try to make the calculation for QDIST and QINV more accurate to that the table lookup approach is not necessary. Since I have now improved the approach used for interpolation, I may instead simply use the table values for QINV and QDIST when df = 1 or (df = 2 and p <= .01) or (df = 3 and p <= .001), or something similar. For now, I would simply ignore the b argument.
Hello – great Add-In. Thank you. I’m trying to duplicate the Studentized range table, for alpha = 0.05, using your QINV function. All values seem pretty accurate to other tables that I’ve seen, except for the first few values in the first row (v=1). For example, here are the first few values I’m obtaining for that row:
k=2: 17.969 k=3: 26.227 k=4: 31.998 (they start to match other tables that I’ve seen around k=12 (and beyond).
Do you know why this might be happening? But again, thanks!
Daryl,
I don’t know why the algorithm I used gives such poor values for df = 1. In fact for small values of alpha less than or equal to .01 the algorithm gives poor values for df = 2 as well. I added an option to simply use the table values in certain cases, but it sounds like I should consider expanding the cases where I use the table values.
Charles