Skip to content
Prev 7311 / 20628 Next

In II[, ii] + REmat$codes[[i]] :

[cc'ing back to r-sig-mixed-models]

  A few things:

* the basic problem is that you have NA values in your data: these get
removed automatically in one place in the code and not in the other,
hence the length mismatch.  This is not absolutely trivial to fix
automatically -- the fixed and random effect predictors are handled
separately, and there may be extra variables in the data that should be
disregarded completely -- but in the meantime I have at least put in an
informative warning message in this case (for the next release).  The
simplest solution is to use na.omit() to get rid of these values (which
can't be used in the fit anyway).

 * it's not advisable to fit a random effect to a factor with only three
levels, although in this case it seems not to do anything disastrous
(ADMB does issue one warning, although in this case it seems harmless)

 * for this problem glmer works *much* faster than glmmADMB (glmmADMB
used to work faster, but we made it slower in the process of adapting it
to be more general and flexible) -- about 2 seconds vs. 2 minutes on my
computer.  quasi-likelihood is unreliable (and no longer possible) in
glmer, but you should check http://glmm.wikidot.com/faq for other
alternatives for handling overdispersion [and for more on the previous
point about numbers of levels of random effects] (although it is still
true that glmmADMB allows a wider range of options than glmer)

 * the data set you sent didn't have a 'chi_hh' variable in it, only an
'ave_chi_hh' variable -- I used it instead for the fitting. *However*,
ave_chi_hh is not integer-valued.  Unless you're absolutely sure you
know what you're doing, you shouldn't use a Poisson GLMM to fit
non-integer data.  (I'm adding a test and a warning for this too.)

library(glmmADMB)
## best not to call data 'data', this masks a built-in R function
ddat <- read.csv("dottisani_data.csv")
summary(ddat)
ddat <- na.omit(ddat)

library(lme4)
t1 <- system.time(g1 <- glmer(ave_chi_hh ~ age + educ +(1 |country_y),
data=ddat,
         family="poisson"))

t2 <- system.time(g2 <- glmmadmb(ave_chi_hh ~ age + educ +(1
|country_y), data=ddat,
         family="poisson"))
On 12-01-13 01:08 PM, Giulia Dotti Sani wrote: