Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: ttest2,Anovan question
Replies: 1   Last Post: Dec 19, 2012 11:13 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Claudio

Posts: 11
Registered: 11/18/11
Re: ttest2,Anovan question
Posted: Dec 19, 2012 11:13 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Walk" wrote in message <kar9nn$jgg$1@newscl01ah.mathworks.com>...
> I have 3 vectors
> a=[1 2 3 4 5];
> b=[2 4 6 8 10 12 14 16];
> c=[1 2 4 8 16 32];
>
> All I want to do is determine whether or not there is evidence to conclude whether these samples come from the same distribution. With only two vectors, this would be done with ttest2(a,b). How do I expand this into checking between 3 or more vectors? From what I've read, anovan is supposed to do this, but when I read the documentation and look at the example, it appears to be meant for something entirely different, or is explained in a way that I can't follow. Unfortunately, all of the other example's I've managed to find simply regurgitate this one example, which is of no use to me. Am I missing something obvious, or do I have to go through ttest2 and compare a to b, then a to c, then b to c?



Hello Walk,

You can use the anova1(X) function. From the Matlab help: "In a one-way analysis of variance, you compare the means of several groups to test the hypothesis that they are all the same, against the general alternative that they are not all the same".

You should arrange your vectors in a matrix, but remember to put NaNs to fill in shorter vectors. Using your example vectors :
X=[...
1 2 3 4 5 NaN NaN NaN; ...
2 4 6 8 10 12 14 16 ;...
1 2 4 8 16 32 NaN NaN]';

p = anova1(X);

Look at the Matlab help for interpreting the p-value. You might want to look at the kruskalwallis() function as well (a non-parametric version of the ANOVA).

Good luck!


Date Subject Author
12/18/12
Read ttest2,Anovan question
Walk
12/19/12
Read Re: ttest2,Anovan question
Claudio

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.