[R-sig-ME] [R] understanding I() in lmer formula
Don Cohen
don-r-help at isis.cs3-inc.com
Wed Jun 14 02:17:30 CEST 2017
Andrew Robinson writes:
> can you provide a minimal executable example?
I was hoping it was going to be something simple.
It looks to me like this is related to parsing and has nothing
to do with the data.
I start by trying to simplify my formula and find that even deleting
seemingly irrelevant parts leads to the same kinds of errors.
> > but what is that "~" doing in the error message??
I wish I knew!
Here's an example that's not exactly small, but at least smaller
than I started with. The first one seems to work and then I move
the # to the other line that I'd expect to have the same meaning.
> fullx=lmer(log.corti~
z.n.fert.females*z.n.males+
is.alpha2*(z.infanticide.susceptibility_new+z.min.co.res+z.co.res+z.log.tenure)+
z.age.at.sample+sin.season+cos.season+
(1+z.n.fert.females+z.n.males+is.alpha2.subordinate+z.infanticide.susceptibility_new+
z.min.co.res+z.log.tenure+z.co.res+
z.age.at.sample+sin.season+cos.season+
I(z.n.fert.females*z.n.males)+
I(is.alpha2.subordinate*z.co.res)+
I(z.min.co.res*is.alpha2.subordinate)+
# I(is.alpha2.subordinate*z.min.co.res)+
int.is.a.log.ten||monkeyid),
data=fe.re.xx$data, REML=F, control=contr)
+ + + + + + + + + + + + > fullx=lmer(log.corti~
z.n.fert.females*z.n.males+
is.alpha2*(z.infanticide.susceptibility_new+z.min.co.res+z.co.res+z.log.tenure)+
z.age.at.sample+sin.season+cos.season+
(1+z.n.fert.females+z.n.males+is.alpha2.subordinate+z.infanticide.susceptibility_new+
z.min.co.res+z.log.tenure+z.co.res+
z.age.at.sample+sin.season+cos.season+
I(z.n.fert.females*z.n.males)+
I(is.alpha2.subordinate*z.co.res)+
# I(z.min.co.res*is.alpha2.subordinate)+
I(is.alpha2.subordinate*z.min.co.res)+
int.is.a.log.ten||monkeyid),
data=fe.re.xx$data, REML=F, control=contr)
+ + + + + + + + + + + + Error in is.alpha2.subordinate * ~z.min.co.res :
non-numeric argument to binary operator
>
And if I start with the one that works and delete something
seemingly irrelevant, like z.infanticide.susceptibility_new+
> fullx=lmer(log.corti~
z.n.fert.females*z.n.males+
is.alpha2*(z.infanticide.susceptibility_new+z.min.co.res+z.co.res+z.log.tenure)+
z.age.at.sample+sin.season+cos.season+
(1+z.n.fert.females+z.n.males+is.alpha2.subordinate+ # z.infanticide.susceptibility_new+
z.min.co.res+z.log.tenure+z.co.res+
z.age.at.sample+sin.season+cos.season+
I(z.n.fert.females*z.n.males)+
I(is.alpha2.subordinate*z.co.res)+
I(z.min.co.res*is.alpha2.subordinate)+
# I(is.alpha2.subordinate*z.min.co.res)+
int.is.a.log.ten||monkeyid),
data=fe.re.xx$data, REML=F, control=contr)
+ + + + + + + + + + + + Error in is.alpha2.subordinate * ~z.co.res :
non-numeric argument to binary operator
I know this is not the minimal executable example requested, but I'm
hoping someone will have an idea before I try to simplify it further
and provide all you need to run it.
More information about the R-sig-mixed-models
mailing list