2

Here is my toy data

y = [1; 1; 2; 6; 7; 3];

and their group information is as follows

grp = ['a'; 'b'; 'b'; 'a'; 'c'; 'c'];

I perform the one-way ANOVA on it.

[~, ~, stats] = anova1(y, grp, 'off');

Then, I do a pairwise comparison with multcompare

[c, m, ~, gnames] = multcompare(stats);

Strangely, the group standard errors are the same!

disp('Mean and standard errors:');
disp([gnames num2cell(m)]);

Mean and standard errors:
    'a'    [3.5]    [1.87082869338697]
    'b'    [1.5]    [1.87082869338697]
    'c'    [  5]    [1.87082869338697]

How can this be possible?


I tried to compute standard errors manually myself. Surprisingly,

>> std(y(grp=='a'))/sqrt(sum(grp=='a'))

ans =

                       2.5

>> std(y(grp=='b'))/sqrt(sum(grp=='b'))

ans =

                       0.5

>> std(y(grp=='c'))/sqrt(sum(grp=='c'))

ans =

     2

1 Answers1

2

This is because the comparisons are based on using a common estimate of $\sigma^2$, computed from the residuals $s^2=\frac{1}{n-k}\sum_{j=1}^k\sum_{i=1}{n_j}(x_{ij}-\bar{x}_{.j})^2$, exactly as is done in ANOVA.

Then, because your sample sizes are all identical, the estimated standard error of each group mean will necessarily be the same.

Glen_b
  • 282,281
  • Thanks a lot Sir! I still cannot wrap my head around it. Could you please elaborate a bit? Like, why is my way of computing the standard error incorrect? Thanks a lot! – Sibbs Gambling Jul 05 '15 at 02:09
  • Since your way was not based on a common estimate of $\sigma^2$, clearly the result will be different from a calculation that is. That doesn't automatically make it incorrect, but it won't correspond to what standard ANOVA does. – Glen_b Jul 05 '15 at 09:12
  • I see. So in the case where I need to show the means (SE) for each group and pairwise comparisons, should I show the SE by my way or the one by the comment estimate? For example, this table. Thanks a lot! – Sibbs Gambling Jul 05 '15 at 13:08
  • 1
    If you're presenting summary statistics for a sample, you do exactly that. It doesn't relate to the calculations you're asking about here. – Glen_b Jul 05 '15 at 15:50
  • well, so I should compute the SE with SD/sqrt(N). Then what does the SE by ANOVA tell us? – Sibbs Gambling Jul 05 '15 at 16:22
  • Comments are not a chat forum; we're no longer clarifying your question nor my answer -- you're simply posing a sequence of new questions with no clear end in sight. This is not a forum for one-on-one tutorials. – Glen_b Jul 05 '15 at 16:26