Is it possible to change the order of groups in the GUI created by the MULTCOMPARE function in the Statistics Toolbox?

5 views (last 30 days)
I am using the Statistics Toolbox function MULTCOMPARE function with the "stats" structure created by ANOVAN. I want to change the order of the groups on the Y-axis of the MULTCOMPARE GUI. For example:
y = [52.7 57.5 45.9 44.5 53.0 57.0 45.9 44.0]';
g1 = [1 2 3 2 1 2 1 2];
g2 = {'hi';'hi';'lo';'lo';'hi';'hi';'lo';'lo'};
g3 = {'may'; 'may'; 'may'; 'may'; 'june'; 'june'; 'june'; 'june'};
[p,table,stats] = anovan(y, {g1 g2 g3});
multcompare(stats);
I would like the labels and corresponding data for "X1=1" and "X1=3" to be interchanged. I would like MULTCOMPARE to accept an input that allows for control of the ordering of the Y-axis.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
The ability to place the Y-axis data of the MULTCOMPARE GUI in an arbitrary user specified order via an input argument is not available in the Statistics Toolbox.
To work around this issue, it is possible to reverse the ordering of the Y-axis data by setting the "YDir" property of the MULTCOMPARE axes to "reverse"
y = [52.7 57.5 45.9 44.5 53.0 57.0 45.9 44.0]';
g1 = [1 2 3 2 1 2 1 2];
g2 = {'hi';'hi';'lo';'lo';'hi';'hi';'lo';'lo'};
g3 = {'may'; 'may'; 'may'; 'may'; 'june'; 'june'; 'june'; 'june'};
[p,table,stats] = anovan(y, {g1 g2 g3});
multcompare(stats);
set(gca,'YDir','Reverse');
For input data from ANOVA1, ANOVA2, and ANOVAN, it may also be possible to achieve a desired ordering on the Y-axis of MULTCOMPARE by properly manipulating the order of the "stats" structure returned by a particular test. For example:
[p,t,st] = anova1(MPG,Origin,'off');
st_new = st;
st_new.gnames(1) = st_new.gnames(6);
st_new.n(1) = st_new.n(6);
st_new.means(1) = st_new.means(6);
st_new.gnames(6) = st.gnames(1);
st_new.n(6) = st.n(1);
st_new.means(6) = st.means(1);
[c,m,h,nms] = multcompare(st_new)
In this example, the Y-axis labels and data for USA and Italy have been interchanged by manipulating the stats structure returned by ANOVA1.

More Answers (0)

Products


Release

R14SP2

Community Treasure Hunt

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

Start Hunting!