drizopoulos / GLMMadaptive

GLMMs with adaptive Gaussian quadrature
https://drizopoulos.github.io/GLMMadaptive/
60 stars 14 forks source link

Degenerate case with constant response #20

Closed wviechtb closed 5 years ago

wviechtb commented 5 years ago

I just noticed the following when trying to fit a model where the response is constant:

dat <- data.frame(xi=rep(1,10), mi=rep(9,10), id=1:10)
lme4::glmer(cbind(xi,mi) ~ 1 + (1 | id), data=dat, family=binomial)

Throws error (Error: Response is constant). But:

GLMMadaptive::mixed_model(cbind(xi,mi) ~ 1, random = ~ 1 | id, data=dat, family=binomial)

runs, but gives an estimate larger than 0 for the variance component. Also, the intercept estimate is slightly off (it should be log(1/9)), although that difference only shows up in the 4th decimal place, so I would consider that negligible.

Switching to Nelder-Mead gives the expected result:

GLMMadaptive::mixed_model(cbind(xi,mi) ~ 1, random = ~ 1 | id, data=dat, family=binomial, control=list(optim_method="Nelder-Mead"))

Now the variance component is estimated to be =~ 0.

This is obviously a degenerate case, but reporting it regardless in case you are interested.

drizopoulos commented 5 years ago

Thanks! I'll have a look.