Jean-Baptiste Ferdy
2008-Mar-19 16:02 UTC
[R] analyzing binomial data with spatially correlated errors
Dear R users, I want to explain binomial data by a serie of fixed effects. My problem is that my binomial data are spatially correlated. Naively, I thought I could found something similar to gls to analyze such data. After some reading, I decided that lmer is probably to tool I need. The model I want to fit would look like lmer ( cbind(n.success,n.failure) ~ (x1 + x2 + ... + xn)^2 , family=binomial, correlation=corExp(1,form=~longitude+latitude)) This doesn't work because lmer says it needs a random effect in the model. And, apart from the spatial random effect that I want to capture by computing the correlation matrix, I have no other random effect. There must be something I do not understand here... I can't get why gls can do this on gaussian data but lmer can't on binomial ones. Any help or thought on this would be welcome ! -- Jean-Baptiste Ferdy Institut des Sciences de l'?volution de Montpellier CNRS UMR 5554 Universit? Montpellier 2 34 095 Montpellier cedex 05 tel. +33 (0)4 67 14 42 27 fax ?+33 (0)4 67 14 36 22
Ben Bolker
2008-Mar-19 20:02 UTC
[R] analyzing binomial data with spatially correlated errors
Jean-Baptiste Ferdy <Jean-Baptiste.Ferdy <at> univ-montp2.fr> writes:> > Dear R users, > > I want to explain binomial data by a serie of fixed effects. My problem is > that my binomial data are spatially correlated. Naively, I thought I could > found something similar to gls to analyze such data. After some reading, I > decided that lmer is probably to tool I need. The model I want to fit would > look like > > lmer ( cbind(n.success,n.failure) ~ (x1 + x2 + ... + xn)^2 , family=binomial, > correlation=corExp(1,form=~longitude+latitude)) > > This doesn't work because lmer says it needs a random effect in the model. > And, apart from the spatial random effect that I want to capture by computing > the correlation matrix, I have no other random effect. > > There must be something I do not understand here... I can't get why gls can do > this on gaussian data but lmer can't on binomial ones. >This is a hard problem. The proximal issue is that lmer does not yet include a correlation term (I'm a little surprised you didn't get an error to that effect), and won't for some time since it is still in heavy development for more basic features. If your data were normal you could use gls from the nlme package, but nlme doesn't do generalized LMMs (only LMMs and NLMMs). You could *almost* use glmmPQL from the MASS package, which allows you to fit any lme model structure within a GLM 'wrapper', but as far as I know it wraps only lme ( which requires at least one random effect) and not gls. You could try gee or geoRglm -- neither trivially easy, I think ... Ben Bolker