multcompare for vartestn?

2 views (last 30 days)
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.

Accepted Answer

Scott MacKenzie
Scott MacKenzie on 29 Jul 2021
Edited: Scott MacKenzie on 29 Jul 2021
@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
Tahariet Sharon
Tahariet Sharon on 31 Jul 2021
Thanks, I will accept your answer, becuase it is currently the one way to do this :)
Thanks for your time again!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by