From: Meg on
Hi,

Im new to MatLab (first day!!!) and am trying to use the Multcompare command. This is probably a really basic question but I cant figure it out and its bugging me!!

My data set is basically a 38X12 matrix of numbers with no headings etc.
The rows are 38 countries and the cols are months.
I couldnt figure out how to name the variables as their countries so I did:
Ireland =data(1,;)
England =data(2,;)
etc.
This worked fine.

I basically want to compare every country in my dataset to each other.The multcompare command seemed ideal but I cant work it.

Syntax=
[c,m,h] = multcompare(stats)

How do I compute a 'stats' structure with my data?I got "Undefined function or variable 'stats'." when I tried the command above.
When I tried
[c,m,h]=multcompare(Ireland,England), I got
"??? Error using ==> multcompare at 138
STATS must be a structure."

I can see from the example given:
[p,t,st] = anova1(MPG,Origin,'off');
[c,m,h,nms] = multcompare(st,'display','off');
[nms num2cell(m)]
ans =
'USA' [21.1328] [0.8814]
'Japan' [31.8000] [1.8206]
'Germany' [28.4444] [2.3504]
'France' [23.6667] [4.0711]
'Sweden' [22.5000] [4.9860]
'Italy' [28.0000] [7.0513]

that you can do it using anova1 etc but that data seems to be in a different format.

I want results like they got, for all the combinations of my countires.

Can anyone help me???

Thanks in advance,

Meg
From: Tom Lane on
> I basically want to compare every country in my dataset to each other.The
> multcompare command seemed ideal but I cant work it.
> Syntax=
> [c,m,h] = multcompare(stats)
>
> How do I compute a 'stats' structure with my data?I

Meg, if you type "help multcompare" you'll find out that this structure is
created by anova1, anovan, or various other functions. What you have sounds
like one-way anova, since you're trying to compare data in rows. Try this

for j=1:38, c{j} = sprintf('c%d',j); end
c{1} = 'Ireland'; c{2} = 'England';
x = randn(38,12);
[p,tbl,st] = anova1(x',c);
multcompare(st);

Here I created country names Ireland, England, and c3-c38. I created fake
data of the size you have. I used anova1 to test for differences in rows
(notice that I transposed because anova1 works on columns). Then I used
multcompare with the anova1 results.

-- Tom