Matlab-Multcompare-HELP!!!!

edited July 2010 in Science & Tech
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

Comments

  • drasnordrasnor Starship Operator Hawthorne, CA Icrontian
    edited July 2010
    If it makes you feel any better, this isn't a basic question. Lots of professors teach MATLAB assuming you already know how to write and debug software but in my first MATLAB course that was true for less than half the class.

    In MATLAB, a structure is a type of data object that serves as a container for other data objects. In your 38x12 matrix you have homogeneous data which as I recall defaults to double precision floating point numbers. So in your first attempt you tried to use multcompare on a 38x12 double array and in the second an argument list of 1x12 double arrays. As you discovered, neither of these objects are the same as a 'stat' object. So what you need is a tool that can make one.

    At this point, I should mention that if your professor didn't explicitly tell you to use multcompare or perform an analysis of variation then you're probably making this harder on yourself than intended. This isn't really something I would consider a first day MATLAB problem for newbies.

    The example suggests anova1 but that is a tool for a specific type of statistical analysis (one-way analysis of variation.) You can also use anova2 (two-way analysis of variation,) anovan (n-way analysis of variation,) or the aoctool user interface. All of these choices require you to know exactly what kind of analysis you want to perform. I'm not much of a statistician so I can't really help in regard to tool selection. From my read of the documentation though, if only the values in the rows are significant (i.e. you can re-order elements along each country's row without distorting your desired answer) then I would suggest anova1. If column position is significant (each column corresponds to a specific month,) anova2 may be the right choice. The documentation for anova1 shows how to group sample sets by label (in your case country) but for anova2 you're stuck with by row and column and you'll need to add in the comments after the analysis to note which rows correspond to what countries and so on.
  • edited July 2010
    drasnor wrote:
    If it makes you feel any better, this isn't a basic question. Lots of professors teach MATLAB assuming you already know how to write and debug software but in my first MATLAB course that was true for less than half the class.

    In MATLAB, a structure is a type of data object that serves as a container for other data objects. In your 38x12 matrix you have homogeneous data which as I recall defaults to double precision floating point numbers. So in your first attempt you tried to use multcompare on a 38x12 double array and in the second an argument list of 1x12 double arrays. As you discovered, neither of these objects are the same as a 'stat' object. So what you need is a tool that can make one.

    At this point, I should mention that if your professor didn't explicitly tell you to use multcompare or perform an analysis of variation then you're probably making this harder on yourself than intended. This isn't really something I would consider a first day MATLAB problem for newbies.

    The example suggests anova1 but that is a tool for a specific type of statistical analysis (one-way analysis of variation.) You can also use anova2 (two-way analysis of variation,) anovan (n-way analysis of variation,) or the aoctool user interface. All of these choices require you to know exactly what kind of analysis you want to perform. I'm not much of a statistician so I can't really help in regard to tool selection. From my read of the documentation though, if only the values in the rows are significant (i.e. you can re-order elements along each country's row without distorting your desired answer) then I would suggest anova1. If column position is significant (each column corresponds to a specific month,) anova2 may be the right choice. The documentation for anova1 shows how to group sample sets by label (in your case country) but for anova2 you're stuck with by row and column and you'll need to add in the comments after the analysis to note which rows correspond to what countries and so on.

    Thanks so much-that is all really helpful
Sign In or Register to comment.