Clear Filters
Clear Filters

Tukey's HSD Test q value

59 views (last 30 days)
Shri Chand
Shri Chand on 19 Mar 2024
Answered: Angelo Yeo on 20 Mar 2024
I am trying to use Tukey's HSD test (Tukey's range test) from the multcompare function of the Statistics and Machine Learning Toolbox on MATLAB for the following purpose.
What I want to do: I have 3 groups of data (with different lengths) called G1, G2, and G3. I want to test whether means of each of these groups are equal. Most importantly (which is why I use Tukey's HSD test), I want to determine which of the pairwise differences in mean is statistically the most "real" difference. In other words, I want to determine which group out of the three has the most different mean than the others, and a critical value to help explain how different this one is. This is why I think what I should do is compare each of the three p value I get from Tukey's Test (three p values since there are three pairs to compare) to the "q-value" you get from Tukey's test. However, I do not know how to get this q value from the multcompare function in MATLAB?
My data are in column vectors, so I create one column vector for all of the data called D and one "label" vector as below called C.
% Create data vector D
D = [G1; G2; G3];
% Create labels vector C
labels1 = cell(length(G1), 1);
labels1(:) = {'G1'};
labels2 = cell(length(G2), 1);
labels2(:) = {'G2'};
labels3 = cell(length(G3), 1);
labels3(:) = {'G3'};
C = cat(1, labels1, labels2, labels3);
Now, I run anova1 to get the statistics.
[~, ~, stats] = anova1(D, C, "off");
Now, I run Tukey's HSD test using multcompare.
[results,means,~,gnames] = multcompare(stats,"CriticalValueType","hsd");
And finally, I will just format the results into a nice table (according to some sample code I found in example usage on the multcompare/anova1 pages).
tbl = array2table([results,means],"VariableNames", ...
["Group A","Group B","Lower Limit","A-B","Upper Limit","P-value","Mean","Standard Error"]);
tbl.("Group A")=gnames(tbl.("Group A"));
tbl.("Group B")=gnames(tbl.("Group B"))
So, this will give me a table with columns (in order): "Group A", "Group B", "Lower Limit", "A-B", "Upper Limit", "P-value", "Mean", and "Standard Error". There are three rows to this table (representing each combination of pairwise comparisons). I understand that the p-values in this table describe whether we can reject the null hypothesis that group means are the same with statistical significance, but now I need a q-value to compare them to. Does anyone know how to get this q value?

Answers (1)

Angelo Yeo
Angelo Yeo on 20 Mar 2024
1) For others' information, it looks like that a part of your script is from the doc below.
2) In many cases of multiple comparisons, "q-value" indicates corrected p-values. This corrected p-values can be found in the "P-value" column in the multiple comparison result table that you created. So, in my opinion, it might good to know whether the "q-value" that you want to know is actually the same thing that you found on Wikipedia. However, in my experiences, q-value indicates corrected p-values.




Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!