[R-sig-ME] [R] understanding I() in lmer formula
David Winsemius
dwinsemius at comcast.net
Wed Jun 14 08:47:36 CEST 2017
> On Jun 13, 2017, at 9:13 PM, Don Cohen <don-r-help at isis.cs3-inc.com> wrote:
>
>> 1. Strip down the formula so that only the term that causes the
>> error is present.
>
> It's not clear what you mean by the term that causes the error.
> Here's a different sort of minimal example:
>
> full=lmer(log.corti~z.xtime+(1 +is.alpha2.subordinate+z.infanticide.susceptibility+z.min.co.res
> +z.age.at.sample+sin.season+cos.season+ I(z.n.fert.females*z.n.males)||monkeyid),
> data=fe.re.xx$data, REML=F, control=contr)
> + + Error in z.n.fert.females * ~z.n.males :
> non-numeric argument to binary operator
> It's minimal in that leaving out any one of the other terms in the || other
> than the I term does not give an error, e.g.,
> leave out is.alpha2.subordinate:
> full=lmer(log.corti~z.xtime+(1 +z.infanticide.susceptibility+z.min.co.res
> +z.age.at.sample+sin.season+cos.season+ I(z.n.fert.females*z.n.males)||monkeyid),
> data=fe.re.xx$data, REML=F, control=contr)
> + + >
> leave out z.infanticide.susceptibility
> full=lmer(log.corti~z.xtime+(1 +is.alpha2.subordinate+z.min.co.res
> +z.age.at.sample+sin.season+cos.season+ I(z.n.fert.females*z.n.males)||monkeyid),
> data=fe.re.xx$data, REML=F, control=contr)
> + + >
> etc.
>
>> str(fe.re.xx$data)
> yes, loads of stuff, but z.n.fert.females and z.n.males are both
> numeric, as are is.alpha2.subordinate and z.min.co.res in the
> previous examples. If this were the problem it wouldn't work when
> I remove those other terms.
>
>> 3. use ls() ...
> none of the terms in the formula appear there
> Again, it seems if this were the problem it wouldn't be solved by
> removing other terms.
>
>> 4. Start a new, **clean** R session
> I did that, even started on a different machine, did a load to get
> the data and library(lme4)
>
> At this point I'd like to know how to interpret the error message:
> Error in z.n.fert.females * ~z.n.males
> non-numeric argument to binary operator
> and what's that ~ all about?
The expression `~z.n.males` is a unary formula, i.e. a language object, so it's not a data object much less a numeric data object. The `*` operator does not have a method for such an object as the second argument.
It appears that trying to use I() on an expression with a multiplication operator was not something that was anticipated as having a sensible meaning.
I'm not sure what this was supposed to be doing but perhaps you wanted the interaction()-function rather than the as.is function?
--
David Winsemius
Alameda, CA, USA
More information about the R-sig-mixed-models
mailing list