[R] Please Post Planned Contrasts Example in lme {nlme}
Tobias Verbeke
tobias.verbeke at openanalytics.eu
Fri Mar 19 02:57:34 CET 2010
Hi Martin,
Martin Turcotte wrote:
> Hi I am running some linear and non-linear mixed effect models and would like to do some planned contrasts (a priori contrasts)
>
> I have looked in the help and in many forums and it seems possible to do so but don't understand how to write the function and I couldn't find an example in Pinheiro and Bates.
>
> lme {nlme} has a contrasts argument but I can't understand how to code it.
>
> Here is a simple example of my working lme model:
> dependent variable: APHIDS: log (number of aphids)
> Fixed effects: DAY (time) and TREATMENT ( 6 different aphid treatments)
> Random effects: POPULATION (each population is counted through time)
>
> lme.fit<-lme(log(APHIDS)~ DAY*TREATMENT, random = ~ DAY| POPULATION,data= aphid.data)
>
> My hypothesis testing focuses on comparing Treatments ~ 1 and 4 , and eventually 2 vs 5, and 3 vs 6.
>
> Q1: How can I do planned contrasts on these pairs for the main effect of TREATMENT?
>
> Q2: Can I also do this for the interaction term (DAY*TREATMENT)?
>
> Q3: Would this code work for a non-linear mixed effect model nlme( )
I would have a look at the multcomp package which allows for
defining contrasts in a very convenient way and can deal a.o.
with lme (from nlme) and mer (from lme4) objects.
http://cran.r-project.org/web/packages/multcomp/index.html
The package comes with several vignettes with example uses
(also an lmer one IIRC).
Best,
Tobias
More information about the R-help
mailing list