Skip to content

Commit ac5afaf

Browse files
author
acp29
committed
Update maxq.m
1 parent dc6062d commit ac5afaf

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

inst/helper/maxq.m

+7-8
Original file line numberDiff line numberDiff line change
@@ -48,25 +48,24 @@
4848

4949
% Calculate the q-ratio test statistic
5050
if isempty(ref)
51-
% Calculate Tukey's q-ratio for maximum difference between
52-
% bootfun for all sample pairwise comparisons
51+
% Calculate Tukey's q-ratio for maximum difference between bootfun
52+
% for all sample pairwise comparisons
5353
%
5454
% Note that Tukey's q-ratio here does not have the sqrt(2) factor.
5555
%
5656
% Bibliography:
5757
% [1] https://en.wikipedia.org/wiki/Tukey%27s_range_test
5858
% [2] https://cdn.graphpad.com/faq/1688/file/MulitpleComparisonAlgorithmsPrism8.pdf
5959
% [3] www.graphpad.com/guides/prism/latest/statistics/stat_the_methods_of_tukey_and_dunne.htm
60-
%
61-
[theta,i] = sort(theta,1);
62-
range = abs(theta(k) - theta(1));
63-
q = range / sqrt(Var * (w(i(k)) + w(i(1))));
60+
idx = logical(triu(ones(k,k),1));
61+
i = (1:k)' * ones(1,k);
62+
j = ones(k,1) * (1:k);
63+
q = max(abs(theta(i(idx)) - theta(j(idx))) ./ sqrt(Var * (w(i(idx)) + w(j(idx)))));;
6464
else
6565
% Calculate Dunnett's q-ratio for maximum difference between
6666
% bootfun for test vs. control samples
6767
% Dunnett's q-ratio is similar to Student's t-statistic
68-
[range, i] = max(abs((theta - ones(k,1) * theta(ref))));
69-
q = range / sqrt(Var * (w(ref) + w(i)));
68+
q = max(abs((theta - theta(ref))) ./ sqrt(Var * (w + w(ref))));
7069
end
7170

7271
end

0 commit comments

Comments
 (0)