[R-sig-ME] alternative interaction representations

Sebastian P. Luque spluque at gmail.com
Sun Aug 22 21:39:05 CEST 2010


On Sun, 22 Aug 2010 08:47:47 +0200,
Reinhold Kliegl <reinhold.kliegl-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org> wrote:

> # This representation fits two linear slopes, one below and one after
> conc = 300, splicing them at 0:
> CO2new$conc1 <- ifelse(CO2new$conc < 300, CO2new$conc - 300, 0)
> CO2new$conc2 <- ifelse(CO2new$conc > 300, CO2new$conc - 300, 0)

> # Basic LMM
> print(LMM <- lmer(uptake ~ conc1 + conc2 + (1 | Plant), data=CO2new), cor=FALSE)
> #  ... the linear uptake is significant below 300, no longer
> significant after 300
> # ... the intercept estimates the upake at conc=300

> # To test whether there is significant between-plant variance in
> slopes below and above conc:
> # Varying-slopes LMM
> print(LMM.conc.1 <-   lmer(uptake ~ conc1 + conc2 + (1 | Plant) +
> (0+conc1 | Plant), data=CO2new), cor=FALSE)
> print(LMM.conc.2 <-   lmer(uptake ~ conc1 + conc2 + (1 | Plant) +
> (0+conc2 | Plant), data=CO2new), cor=FALSE)
> #print(LMM.conc.1.2 <- lmer(uptake ~ conc1 + conc2 + (1 | Plant) +
> (0+conc1 | Plant) + (0+conc2 | Plant), data=CO2new), cor=FALSE)
> #print(LMM.conc.12 <-  lmer(uptake ~ conc1 + conc2 + (1 + conc1 +
> conc2 | Plant), data=CO2new), cor=FALSE)

> anova(LMM, LMM.conc.1)
> anova(LMM, LMM.conc.2)
> #  Apparently there is not enough information in the data to test the
> between-slope variance.

Thanks Reinhold, it seems as if these piecewise linear splines with one
or two knots are easier to fit and interpret than using a factor.

Cheers,

-- 
Seb




More information about the R-sig-mixed-models mailing list