[R] syntax and package for generalized linear mixed models

Douglas Bates bates at stat.wisc.edu
Fri Nov 21 17:28:19 CET 2008


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

> I am making the switch to R and uncertain which of the several packages for
> 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 more
> 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 as
> 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 the
> 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 it
> 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]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list