Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Multcompare function does not compare all variable groups from anova2

Asked by Beth on 7 May 2013

Hi,

I am using the function anova2 to complete a two-way ANOVA. Here is the data:

d =

   1.0e+03 *
    0.0053    0.9991
    0.0042    1.6223
    0.0044    1.2638
    0.0016    0.0031
    0.0024    0.0036
    0.0018    0.0036

Here is the code I ran:

[p,h,s]=anova2(d,3)

both columns and rows were significant with significant interaction:

p =

   1.0e-04 *
    0.9668    0.9543    0.9827

I ran multcompare on this analysis

[c, m, h, nms] = multcompare(s,'alpha',0.05,'ctype','bonferroni')

and this was my result:

c =

    1.0000    2.0000 -854.1768 -645.9667 -437.7565

I realize that you can specify either column or row for the multcompare function, but shouldn't the multcompare function compare all quadrants:

i.e.

d =

     1     2
     3     4

Shouldn't the multcompare function compare 1 & 2, 1 & 3, 1 & 4, 2 & 3, 2 & 4 and 3 & 4, because both columns and rows were significantly different. Maybe I am misunderstanding how the multcompare function works.

Any help would be greatly appreciated. Thanks.

Beth

0 Comments

Beth

Products

1 Answer

Answer by Tom Lane on 10 May 2013
Accepted answer

You are right, it looks like multcompare with anova2 can only compare one dimension at a time. But multcompare with anovan can compare both. Try this:

row = [1 1 1 2 2 2 1 1 1 2 2 2]';
col = [1 1 1 1 1 1 2 2 2 2 2 2]';
[p,~,s] = anovan(d(:),{row col},'interaction')
multcompare(s,'dim',1:2)

0 Comments

Tom Lane

Contact us