Avoiding for loop with anova1
이전 댓글 표시
I have 2 large 3D matrices, and I've noticed that passing a DIM argument for the ttest2 function decreases the computational time on my computer substantially as opposed to looping through each index in the first 2 dimensions (near 60-fold for the data I'm working with):
[~,~,~,stats]=ttest2(A,B,[],[],[],3);
vs.
stats=cell(rmax,cmax);
for r=1:rmax
for c=1:cmax
[~,~,~,stats{r,c}]=ttest2(A(r,c,:),B(r,c,:));
end
end
Now I would like to do the same thing, but adding another matrix C and using anova1 instead of ttest2. The documentation for anova1 suggests that it won't accept a similar DIM argument, but I'm wondering if there's a similar way to cut down on time and avoid looping through each element.
Thanks!
Zach
댓글 수: 4
Star Strider
2015년 4월 5일
I don’t know your data or your experimental design, so what you’re doing could be appropriate, especially if you’ve discussed it with your statisticians and they suggest the approach you’re doing.
If that’s not the situation, although I didn’t want to comment earlier, I’m uncomfortable with your running lots of paired t-tests without some sort of correction for multiple comparisons.
See if the multcompare function might be more appropriate. It does the same thing, but incorporates corrections for multiple comparisons,
The anova1 analysis is a good step, but that should have been your first approach, and multiple comparisons the second.
Be sure to talk this over with a statistician before going further if you have not already.
Zach
2015년 4월 5일
Star Strider
2015년 4월 5일
I still have no idea what you’re doing, but if you’re doing clustering, you might want to look through the Statistics Toolbox for cluster algorithms such as clusterdata. There are several others, and several related functions, such as those listed at the end of that webpage.
Zach
2015년 4월 6일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Analysis of Variance and Covariance에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!