Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.


Claudio
Posts:
15
Registered:
11/18/11


Re: ttest2,Anovan question
Posted:
Dec 19, 2012 11:13 AM


"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 oneway 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 pvalue. You might want to look at the kruskalwallis() function as well (a nonparametric version of the ANOVA).
Good luck!



