How do I compare between 10 groups on a Ttest2?

2 ビュー (過去 30 日間)
Yossi Sourugeon
Yossi Sourugeon 2016 年 4 月 12 日
編集済み: jgg 2016 年 4 月 12 日
Hello, I have 10 vectors. For each vector, I have to do a Ttest2 with the nine other vectors(nine comparisons for each vector). Any ideas how i can do this? Thanks!

回答 (1 件)

jgg
jgg 2016 年 4 月 12 日
編集済み: jgg 2016 年 4 月 12 日
Let's suppose you have them labeled v1, v2, ..., v10 and they're the same size n. (If they're not the same size, use a cell array instead.)
Put your vectors in an array:
v = [v1,v2,v3,v4,v5,v6,v7,v8,v9,v10];
Then loop over them:
v = randn(1000,10); %to debug; use the real v here
h = zeros(10,10);
p = zeros(10,10);
for i = 1:10
for j = (i+1):10
[h(i,j),p(i,j)] = ttest2(v(:,i),v(:,j));
end
end
Your values and decisions for tests i,j are in the respective element of h and p.
Notice, you don't actually need to do 9 comparisons from each vector; if you've already compared v1 and v2 you don't need to compare v2 to v1 as well.

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by