[R-sig-ME] alternative interaction representations

Sebastian P. Luque spluque at gmail.com
Sat Aug 21 19:07:56 CEST 2010


Hi,

## With the CO2 data, suppose we want to build a LME model of 'uptake' with
## 'conc' (continuous) and want to know whether there is a change in slope
## at conc=300, with random slopes for plants

CO2new <- subset(CO2, Type == "Quebec" & Treatment == "nonchilled")
CO2new <- within(CO2new, {
    ## The more intuitive way to set up the interaction is to first define
    ## a factor breaking up the 'conc' predictor
    stage1 <- cut(conc, breaks=c(floor(min(conc)), 300,
                          ceiling(max(conc))),
                  labels=c("pre", "post"), include.lowest=TRUE)
    ## Alternative, direct representation of interaction
    stage2 <- ifelse(conc > 300, conc - 300, 0)
    ## We center conc at 300 for interpreting intercept here
    conc <- conc - 300
})
str(CO2new)
xyplot(uptake ~ conc, data=CO2new, groups=Plant, type="b")

## Consider a model with fixed effects for intercept, conc, and varying
## slopes.  Using the more intuitive representation:

(fm1 <- lmer(uptake ~ conc + conc:stage1 + (conc:stage1 | Plant), data=CO2new))

## And using the direct representation of the interaction

(fm2 <- lmer(uptake ~ conc + stage2 + (conc + stage2 | Plant), data=CO2new))

## In this simple case, it doesn't seem to matter which representation is
## used.  For other models where an interaction with another factor, say
## Type, is needed in the model to indicate 3-way interactions with conc
## then the latter seems to allow for a simpler model (which may impact
## lmer performance) because the interaction would then be modelled as a
## 2-way interaction.
##
## Is this a fair comparison of using direct representations of
## interactions compared to the more natural factor-based representations?
## Overall, is it preferable to use one rather than the other?

Cheers,

-- 
Seb




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