Skip to content
Prev 15515 / 20628 Next

understanding I() in lmer formula

On 17-06-14 08:59 AM, Don Cohen wrote:
Something is getting mangled internally.  One of the reasons you're
not getting much useful advice here is that this is new to us -- I've
never seen  anything like this happen before.  I keep making guesses
based on the differences between your example and the stuff people
normally try to do (I() inside random effects term, long random-effects
term), but so far my guesses haven't panned out.  This is the reason we
keep asking for a **reproducible** example; if I could run this example
myself I could almost certainly figure out what's going on, but remote
debugging is really hard.
It is perfectly sensible: it just means "multiply these two terms
together, using the normal arithmetic meaning of *, rather than
composing their interaction"). However, if this term is indeed causing a
problem, it can be worked around by defining a new variable rather than
constructing it on the fly (this is what I suggested in my previous error).
OK, I've been able to reproduce this (code below), will dig in and let
you know what I find.

----

form <- log.corti~z.n.fert.females*z.n.males+

is.alpha2*(z.infanticide.susceptibility+z.min.co.res+z.co.res+z.log.tenure)+
    z.xtime+z.age.at.sample+sin.season+cos.season+
    (1 #+z.n.fert.females
        +z.n.males
        +is.alpha2.subordinate
        +z.infanticide.susceptibility
        +z.min.co.res
        +z.log.tenure
        +z.co.res
        ## +z.xtime
        +z.age.at.sample
        +sin.season
        +cos.season+
        I(z.n.fert.females*z.n.males)+
        I(is.alpha2.subordinate*z.min.co.res)+
        ##  I(z.co.res*is.alpha2.subordinate)
        I(is.alpha2.subordinate*z.co.res)
        ##  +int.is.a.log.ten
        ||monkeyid)

xvars <- setdiff(all.vars(form),"monkeyid")
dd <- data.frame(matrix(rnorm(1000*length(xvars)),ncol=length(xvars)))
names(dd) <- xvars
dd$monkeyid <- factor(rep(1:20,50))
library(lme4)
parse <- lFormula(form, data=dd)