MATLAB Answers

multcompare for vartestn?

조회 수: 1(최근 30일)
Tahariet Sharon
Tahariet Sharon 2020년 5월 6일
댓글: Tahariet Sharon 2021년 7월 31일
Hi,
Is there a way to know which of the groups being compared vartestn is the one that differs from the rest? The function multcompare does not admit the stats output from the vartestn function. Thanks.

채택된 답변

Scott MacKenzie
Scott MacKenzie 2021년 7월 29일
편집: Scott MacKenzie 2021년 7월 29일
@Tahariet Sharon It is true that multcompare cannot work with input from vartestn. A frustration with multcompare is that it cannot work as a standalone test; that is, it cannot receive as input a matrix of column data and perform a pairwise comparisons test on that data. That's unfortunate, in my view. However, multcompare can receive as input a stats object created from anova1.
Below is a script that performs a pairwise comparisons test on a matrix of column data. The script loads some test data, creates a stats object from that data, then passes that object in to multcompare. Mission accomplished!
The 16x4 test data are in testdata.txt, which is attached. The file contains 16 marks on 4 tests. The last column of output produced by multcompare is the p-value for the hypothesis test that the corresponding mean difference is not equal to 0 for the pairs tested in that row. As seen below, the marks were significantly different (p < .05) between tests 1 and 3 and tests 2 and 3.
multcompare uses the Tukey-Kramer test by default, but other tests (e.g., Bonferroni) can be specified via the 'CType' option.
% load test data: 16 marks on 4 tests
y = readmatrix('testdata.txt'); % 16x4
% do the anova -- just to get a stats object
[~, ~, stats] = anova1(y, {'t1' 't2' 't3' 't4'}, 'off');
% pass stats object into multcompare (p-value in last column of output)
multcompare(stats, 'display', 'off')
ans = 6×6
1.0000 2.0000 -3.9088 -0.8750 2.1588 0.8711 1.0000 3.0000 -7.5338 -4.5000 -1.4662 0.0013 1.0000 4.0000 -4.8463 -1.8125 1.2213 0.3983 2.0000 3.0000 -6.6588 -3.6250 -0.5912 0.0130 2.0000 4.0000 -3.9713 -0.9375 2.0963 0.8464 3.0000 4.0000 -0.3463 2.6875 5.7213 0.1002
  댓글 수: 3
Tahariet Sharon
Tahariet Sharon 2021년 7월 31일
Thanks, I will accept your answer, becuase it is currently the one way to do this :)
Thanks for your time again!

댓글을 달려면 로그인하십시오.

추가 답변(0개)

Community Treasure Hunt

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

Start Hunting!

Translated by