I am trying to run a Poisson model in R. I checked a number of web sites to do this and I believe the code below should work. However, I am getting an error message that indicates that there is an unused argument. I don't understand what the issue is.
library(lme4)
m1<-lmer(sum ~ Lunch + intervention_y_n + (1 | prcid),
data=data_long_1, family = "poisson"(link = "log"))
Error in lmer(sum ~ Lunch + intervention_y_n + (1 | prcid), data = data_long_1, : unused argument (family = poisson(link = "log"))
You need glmer()
for generalized linear mixed models (e.g. a Poisson model). lmer()
is for linear mixed models only (Gaussian response with an identity link), so it doesn't have a family
argument.
This code worked until fairly recently (4 months ago). If you check the NEWS file for lme4 you'll see that version 1.1-22, which was released in April 2020, disabled the automatic forwarding of lmer(..., family=...)
to glmer
. However, this usage had been deprecated (i.e., gave a warning message telling you not to use it) starting in 2013 ...