Ranksum - Wilcoxon rank sum test - Get more statistics using a for loop
6 views (last 30 days)
Show older comments
Clemente Tagliafierro
on 22 Jun 2020
Commented: Yogesh Kumkar
on 31 Jan 2022
Hello everyone!
I am running some statistics and I need to use the Wilcoxon rank sum test.
I have 2 matrices and I need to compare 25 vector pairs.
If I run the test in a for loop, I get only the p-values - I would love to get more statistics but I have not been able to find a way.
That is what I have now:
Matrix1 = n x 25
Matrix2 = m x 25
for i = 1:25
testresults(i) = ranksum(Matrix1.(i),Matrix2(i),'method','exact')
end
If I run the test like this, I will get as a results just the pval, any clue how to get [p,h,stats] in a for loop?
I know how to run this out of the for loop.
Thank you all in advance for your help!
0 Comments
Accepted Answer
Adam Danz
on 22 Jun 2020
Edited: Adam Danz
on 22 Jun 2020
p = nan(1,n);
h = false(1,n);
stats = cell(1,n);
for i = 1:n
[p(i),h(i),stats{i}] = ranksum(x,y,__)
end
7 Comments
Adam Danz
on 31 Jan 2022
The loop gets stuck in the while-loop at the first non-NaN value in CTL2008E1.
I think you want a condition rather than a while-loop.
if ~isnan(CTL2008E1(i,j))
[pRC(i,j),hRC(i,j)] = ranksum(squeeze(Xrel(i,j,:)),squeeze(Yctl(i,j,:)));
[pIC(i,j),hIC(i,j)] = ranksum(squeeze(Zidl(i,j,:)),squeeze(Yctl(i,j,:)));
end
More Answers (0)
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!