Suppose you have 6 groups (A, B, C, D, E, F) and you measured the weight of 5 individuals from each group. Therefore you have 30 weight observations in total.
You wish to test if the mean of the response variable is different for each of the groups. [ i.e. the null hypothesis is that all 6 groups means are the same. ] Lets simulate some data first: grp <- gl(6, k=5, labels=LETTERS[1:6]) grp [1] A A A A A B B B B B C C C C C D D D D D E E E E E F F F F F Levels: A B C D E F set.seed(1) # for reproducibility only w <- runif(30, min=40, max=75) # weights w <- round(w, digits=1) Let us first calculate the group means: tapply(w, grp, mean) A B C D E F 56.24 62.36 55.54 63.54 55.34 53.94 The group means are close, except for possibly group B and D. You can do a formal testing by regressing the response (weight) to its predictors (group). You will need to use the lm() function in R. fit <- lm( w ~ grp ) You can get a summary of the fit by summary(fit) ... Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 56.240 4.725 11.903 1.48e-11 *** grpB 6.120 6.682 0.916 0.369 grpC -0.700 6.682 -0.105 0.917 grpD 7.300 6.682 1.093 0.285 grpE -0.900 6.682 -0.135 0.894 grpF -2.300 6.682 -0.344 0.734 ... This simply says that the intercept is strongly NOT zero. Based on the p-values, one can roughly summarise that none of the groups appear to be different. Another useful tool is the ANOVA test which tests if the between group variations are larger than average within group variation. anova(fit) Analysis of Variance Table Response: w Df Sum Sq Mean Sq F value Pr(>F) grp 5 411.15 82.23 0.7367 0.6033 Residuals 24 2678.79 111.62 This says that there is no significant variation between the groups. Hope this helps. Regards, Adai On Fri, 2006-03-10 at 11:24 -0500, Jason Horn wrote: > I'd like to do a simple one-way ANOVA comparing the means of 6 > groups. But it seems like the only way to do an ANOVA in R is to > specify some sort of model, where there is an outcome or dependent > variable that is a function of independent variables (linear model). > But I don't have a linear model, I just want to do a simple ANOVA > (and f-test) to compare the means. How do I do this? My stats > skills are basic, so please bear with me. > > Thanks for any ideas... > > ______________________________________________ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html > ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html