Re: [R] syntax and package for generalized linear mixed models

From: Jeff Evans <>
Date: Mon, 24 Nov 2008 11:36:34 -0500

Thanks Doug,

I appreciate your response. I'm not a statistician and didn't realize this limitation of the distribution and model I chose. This may be getting beyond the scope of this help list, but I'll try anyway:

If the variance of the response variable (survival) is, in fact, a function of a covariate as it appears to be, is there a different model or distribution I should explore that could account for it without a transformation? I think it is a biologically important feature of the data.

-----Original Message-----
From: [] On Behalf Of Douglas Bates
Sent: Friday, November 21, 2008 11:28 AM To: Jeff Evans
Subject: Re: [R] syntax and package for generalized linear mixed models

On Thu, Nov 20, 2008 at 2:54 PM, Jeff Evans <> wrote:

> I am making the switch to R and uncertain which of the several packages
> mixed models is appropriate for my analysis. I am waiting for Pinheiro and
> Bates' book to arrive via inter-library loan, but it will be a week or
> before it arrives.

> I am trying to fit a generalized linear mixed model of survival data
> (successes/trials) as a function of several categorical fixed and nested
> random effects and a covariate. Additionally, the residual variance in the
> data is a negative function of the covariate, which I would like to model
> well. Working in SAS, I was able to do this on transformed data in PROC
> MIXED, but ran into trouble trying to run it as a logistic regression in
> original scale in GLIMMIX.

> Can glmer in lme4 do this? It seems that "weights" in lme4 refers to
> weighting of observations rather than modeling the variance-covariate, as
> does in nlme. I tried running nlme, but I'm stuck on syntax, particularly
> with regards to how the fixed and random statements should be constructed
> separate from the model statement (not sure how this is supposed to work).
> Generally, I believe my model in lme4 should look like this:

> gm1 = glmer(cbind(#successes,#trials) ~ A*B + covariate + (1|B/C),
> family = binomial, link="logit", data=mydata,
> weights=varExp(form = ~covariate))

I'm sorry to say that this is not a valid model specification for glmer. As you have surmised, lme4 does not allow a general weights specification like this.

Failure to accept a specification like this is not just an oversight or an unimplemented feature. This isn't a valid model specification because this isn't a valid model. If the conditional distribution of the response, given the value of the random effects, is Bernoulli (or Poisson) then it is completely specified by the conditional mean. You can't separately specify the mean and the variance for a Bernoulli or a Poisson distribution as you can for a Gaussian distribution.

As tempting as it may be to want to have several dials and knobs on statistical models to tune their behavior we still need to be careful to specify a mathematical model that is consistent.

> where #trials is the number of subjects at the beginning of the experiment
> in each experimental unit, #successes is the number of survivors, A and B
> are fully crossed fixed categorical factors, C is a categorical random
> factor nested within B (i.e. random site within year), and covariate is a
> continuous numerical variable ranging from 1- +inf.
> Can someone please suggest (a) which package to use for this analysis and
> (b) perhaps share some dummy code using my mock variables above?
> Many thanks,
> Jeff Evans
> PhD Candidate
> Department of Entomology
> EEBB Graduate Program
> Michigan State University
> [[alternative HTML version deleted]]
> ______________________________________________
> mailing list
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code.
> mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Mon 24 Nov 2008 - 16:41:15 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 24 Nov 2008 - 17:30:28 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive