[R] two-way anova help

S Ellison S.Ellison at LGCGroup.com
Tue Sep 27 11:23:45 CEST 2011


 
Austin,

As you describe it, 'tank' is indeed nested within 'cross' - no tank contains the offspring from more than one cross. 

How you treat that depends on whether the tank effect is fixed or random. I would _guess_ it's essentially a nuisance effect; if it were the principal effect of interest, you'd not have needed to do multiple parent crosses to find out about it. If it's random and appreciable, it affects inference about the parentage, roughly because the random tank effect increases the uncertainty of the cross means. The lm model for tank nested in the cross groups would probably look something like

response~male*female+male:female:tank

although if tanks were numbered 1-45 you'd get away without the male:female: prefix, at least in lm - the important thing is that lm is told that each male:female cross has _different_ tanks. That should give you an anova table with the tank effect appearing as the last row but one. 
The classical treatment of that with tank as a random effect would be to recalculate F and p for the parent effects and interaction by calculating F from the ratio of their mean squares to the tank mean square if the tank mean square is significant.. If not you would have the usual soul-searching about whether to compare with the residual MS or to re-fit the model without the tank effect. (the results ought to be pretty similar either way unless the tank effect is close to significance - in which case I'd check against it anyway and then think about the answer).

If tank is a fixed effect, you can use the table as is.

A somewhat simpler way to treat the tank-as-random case in R (simoper for you and I, that is - the maths involved is not simpler but fortunately Douglas Bates did it all for us) would be to treat it as a mixed effects model, using lme from the nlme package.  Assuming tank is numbered 1-45 or otherwise identified as something like tankID<-factor(male:femal:tank) to make sure lme knows the tanks are different for each cross, that would look like

library(nlme)
mod <- lme(response~male*female, random=~1|tank, ...)

anova(mod) would then give you a test for the parent effects and interactions, taking into account the estimated between-tank variance whether it's large or not.
and
summary(mod) will tell you the between-tank component of variance.

Finally, if you think the tank effect is probably real and certainly if it's large, taking the tank means and doing two-way anova on the resulting 45 mans should be pretty much the same as the more complicated stuff above.


Caveat: I'm a chemist. Taking a chemist's advice about statistics is about as sensible as taking a statistician's advice about chemistry - the mileage can vary.

S Ellison



> -----Original Message-----
> From: r-help-bounces at r-project.org 
> [mailto:r-help-bounces at r-project.org] On Behalf Of Austin Paul
> Sent: 27 September 2011 06:28
> To: Indrajit Sengupta
> Cc: r-help at r-project.org
> Subject: Re: [R] two-way anova help
> 
> Hi,
> 
> Yes.  As I explained, the three male and three female types 
> were crossed in all combinations (9 ways).  For each of the 9 
> types, I have *5 replicate
> tanks* (45 total tanks).  And from each of the 45 tanks I 
> have 50 observations for size.  So the 5 replicates are 
> somehow nested within the two-way interaction?  If there was 
> just 1 tank for each of the 9 crosses, yes, it would be very 
> easy to code the two-way anova.  It may still be very easy, 
> but I'm not quite sure how to account for the replicate tanks.
> 
> Hope this makes more sense.
> 
> Austin
> 
> 
> 
> On Mon, Sep 26, 2011 at 10:21 PM, Indrajit Sengupta 
> <indra_calisto at yahoo.com
> > wrote:
> 
> > Can you explain what do you mean by "5 replicate tanks"?
> >
> > Doing a two way anova is very simple in R. You would need to fit a 
> > linear model (lm function).
> >
> > Eg.:
> >
> > > model <- lm(y ~ male + female + male:female, data =)
> >
> >
> > Regards,
> > Indrajit
> >
> >
> > ------------------------------
> > *From:* Austin Paul <austinpa at usc.edu>
> > *To:* r-help at r-project.org
> > *Sent:* Tuesday, September 27, 2011 6:13 AM
> > *Subject:* [R] two-way anova help
> >
> > Hello,
> >
> > I am having some trouble coding a two-way anova due to replicated 
> > treatments.
> >
> > I have a factorial design with three male parents and three 
> female parents.
> > They were mated in all combinations and their babies were grown out 
> > and measured for size.  50 babies were measured for each of the 9 
> > crosses.  If I stopped here, I would have no troubles.  But I also 
> > have 5 replicate tanks for each of the 9 crosses.  My 
> question is how 
> > to I code in the 5 replicate tanks per treatment?
> >
> > Thanks,
> > Austin
> >
> >     [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-help at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
> >
> >
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> *******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}



More information about the R-help mailing list