[R] improvement of Ancova analysis

hadley wickham h.wickham at gmail.com
Sun May 4 15:18:18 CEST 2008


On Sat, May 3, 2008 at 9:00 PM, Tobias Erik Reiners
<Tobias.Reiners at bio.uni-giessen.de> wrote:
> Dear Helpers,
>
>  I just started working with R and I'm a bit overloaded with information.
>
>  My data is from marsupials reindroduced in a area. I have weight(wt), hind
> foot
>  lenghts(pes) as continues variables and origin and gender as categorial.
>  condition is just the residuals i took from the model.
>
>
> > names(dat1)
> >
>  [1] "wt" "pes" "origin"  "gender" "condition"
>
>  my model after model simplification so far:
>  model1<-lm(log(wt)~log(pes)+origin+gender+gender:log(pes))
>  -->six intercepts and two slopes
>
>  the problem is i have some things I can't include in my analysis:
>  1.Very different sample sizes for each of the treatments
>
> > tapply(log(wt),origin,length)
> >
>  captive    site    wild
>     119     149      19
>  2.Substantial differences in the range of values taken by the covariate
> (leg length) between treatments
>
> > tapply(pes,origin,var)
> >
>   captive     site     wild
>  82.43601 71.44442 60.42544
>
> > tapply(pes,origin,mean)
> >
>   captive     site     wild
>  147.3261 144.8698 148.2895
>
>  4.Outliers
>  5.Poorly behaved residuals
>
>  thanks for the answer I am open minded to any different kind of analysis.

How about starting with some graphics?  e.g. with ggplot2 the
following would give you some clues as to whether your models are
appropriate or not:

qplot(pes, wt, data=dat1, colour=gender, facets = . ~ origin,
log="xy") + geom_smooth(method=lm)
qplot(pes, wt, data=dat1, facets = gender ~ origin, log="xy") +
geom_smooth(method=lm)

If you wanted to the see the effect of a robust fit, as suggested by
Brian Ripley, replace lm with rlm.

Hadley

-- 
http://had.co.nz/



More information about the R-help mailing list