What is the formula for calculating p-value of Tukey HSD http://onlinestatbook.com/calculators/tukeycdf.html
1 Answer
The following site contains the Matlab code for calculating the p-value for the Tukey HSD (based upon an unidentified FORTRAN program): http://www.mathworks.com/matlabcentral/fileexchange/37450-cumulative-distribution-function-of-the-studentized-range--for-tukey-s-hsd-test-
The calculation relies upon the observed value of Tukey's test, degrees of freedom (total number of elements minus number of groups, and the number of samples.
The following site, asking about a stata implementation provides the basics of a formula which can be used with any application which calculates the Studentized Range Distribution: http://www.stata.com/statalist/archive/2012-02/msg00469.html From the website:
p = 1 - tukeyprob(k, df, q)
where p
is the p-value, tukeyprob
is equivalent to ptukey
in R
, k
is the number of means to compare, df
are the degrees of freedom, and q
is the HSD test statistic.
In r, the equation would be p = 1 - ptukey(q, k, df)
.
Edit:
Based upon a comment, the equation these algorithms are attempting to solve is:
$$f\left ( q;k,v \right )=\frac{\sqrt{2\pi}k\left ( k-1 \right )v^{v/2}}{\Gamma\left ( \frac{v}{2} \right )2^{v/2-1}}\int_{0}^{\infty }x^v\varphi \left ( \sqrt{v}x \right )\left [ \int_{-\infty}^{\infty}\varphi\left ( u \right )\varphi\left ( u-qx \right ) \left ( \Phi\left ( u \right )- \Phi\left (u-qx \right ) \right )^{k-2}du\right ]dx$$
-
$\begingroup$ These are useful references--but that's all they are. They can hardly be construed as formulas. The Fortran code (which actually is AS 190) is computing an integral: the formula would be the integral rather than this code. Unfortunately, the code says little about what integral it's computing. I believe Tukey's HSD is based on a Studentized range, so likely the relevant distribution is that described at en.wikipedia.org/wiki/Studentized_range_distribution. $\endgroup$– whuber ♦Commented Apr 7, 2017 at 16:54
ptukey
andqtukey
. -1 for not looking it up. $\endgroup$