[R] Help with three-way anova

michael watson (IAH-C) michael.watson at bbsrc.ac.uk
Wed Apr 6 11:30:53 CEST 2005


OK, now I am lost.

I went from using aov(), which I fully understand, to lm() which I
probably don't.  I didn't specify a contrasts matrix in my call to
lm()....

Basically I want to find out if Infected/Uninfected affects the level of
IL.4, and if Vaccinated/Unvaccinated affects the level of IL.4,
obviously trying to separate the effects of Infection from the effects
of Vaccination.

The documentation for specifying contrasts to lm() is a little
convoluted, sending me to the help file for model.matrix.default, and
the help there doesn't really give me much to go on when trying to
figure out what contrasts matrix I need to use...

Many thanks for your help

Mick

-----Original Message-----
From: Federico Calboli [mailto:f.calboli at imperial.ac.uk] 
Sent: 06 April 2005 10:15
To: michael watson (IAH-C)
Cc: r-help
Subject: RE: [R] Help with three-way anova


On Wed, 2005-04-06 at 09:11 +0100, michael watson (IAH-C) wrote:
> OK, so I tried using lm() instead of aov() and they give similar
> results:
> 
> My.aov <-  aov(IL.4 ~ Infected + Vaccinated + Lesions, data)
> My.lm  <-   lm(IL.4 ~ Infected + Vaccinated + Lesions, data)

Incidentally, if you want interaction terms you need 

lm(IL.4 ~ Infected * Vaccinated * Lesions, data)

for all the possible interactions in the model (BUT you need enough
degrees of freedom from the start to be able to do this).
> 
> If I do summary(My.lm) and summary(My.aov), I get similar results, but

> not identical. If I do anova(My.aov) and anova(My.lm) I get identical 
> results.  I guess that's to be expected though.
> 
> Regarding the results of summary(My.lm), basically Intercept, Infected

> and Vaccinated are all significant at p<=0.05.  I presume the 
> signifcance of the Intercept is that it is significantly different to 
> zero?  How do I interpret that?

I guess it's all due to the contrast matrix you used. Check with
contrasts() the term(s) in the datafile you use as independent
variables, and change the contrast matrix as you see fit.

HTH,

F
-- 
Federico C. F. Calboli
Department of Epidemiology and Public Health
Imperial College, St Mary's Campus
Norfolk Place, London W2 1PG

Tel  +44 (0)20 7594 1602     Fax (+44) 020 7594 3193

f.calboli [.a.t] imperial.ac.uk
f.calboli [.a.t] gmail.com




More information about the R-help mailing list