Skip to content

Anova

3 messages · daniel jupiter, Gavin Simpson, Douglas Bates

#
On Sat, 2008-03-15 at 12:48 -0500, daniel jupiter wrote:
if obj is the result of anova, aov, oneway.test, then

str(obj) ## for anova
str(summary(obj)) ## for aov
str(obj) ## for oneway.test

to find the names of the elements of obj that contain the p-values of
the various tests/models. In the first two you are looking for the
component "Pr(>F)" and the latter is obvious ("p.value")

For summary(aov) objects, the result is a list so this gets the p-value
you need:

obj[[1]]$`Pr(>F)` or obj[[1]][,5]]

for anova then this:

obj$`Pr(>F)` or obj[,5]

note the quoting of the component name using backticks.

For oneway.test

obj$p.value
?TukeyHSD for the results of aov
See ?lme in package nlme
I'm not sure what the problem is here - you don't say. All of what I say
above is documented in the relevant help pages for the various functions
and using str() is a basic tenet of using R and looking at returned
objects.

Ok, you might have needed help with getting the p-values for some of
those tests/models, but 2) and 3) are answered on ?aov

For what you describe, stick with aov for balanced designs if you want
to do TukeyHSD as there is a method for aov objects (otherwise) you'll
need to refit the model.

For unbalanced designs, check out lme and for that you may need to
get/borrow the book by Pinhiero and Bates, reference details of which
are given in item [7] on:

http://www.r-project.org/doc/bib/R-books.html
HTH

G
1 day later
#
On Sun, Mar 16, 2008 at 6:39 AM, Gavin Simpson <gavin.simpson at ucl.ac.uk> wrote:
Thanks for the plug, Gavin, but lme and my book with Jose are for
linear *mixed-effects* models.  I think the question here is about
unbalanced fixed-effects models and those can be fit quite simply by
lm, aov and friends.

Users, quite reasonably, expect that model fitting in R is done using
the formulas that they saw in an introductory textbook.  In fact, that
is almost never the case.  Functions like lm and aov use computational
methods that do not depend on balance in the data.