[R-sig-ME] cloglog and lmer

Ben Bolker bolker at ufl.edu
Fri Mar 19 19:03:41 CET 2010


   Hmmm.  Can you remind me what didn't work?
  Examples below give at least vaguely plausible answers ...

  cheers
    Ben Bolker

set.seed(1001)

N <- 20
n <- 100
x <- runif(N*n)
f <- factor(rep(LETTERS[1:N],each=n))
dat <- data.frame(x,f)

beta <- c(1,3)
alpha <- rnorm(N,sd=0.5)

mm <- cbind(model.matrix(~x,data=dat),
            model.matrix(~f-1,data=dat))

eta <- mm %*% c(beta,alpha)
y <- rbinom(N*n,prob=1-exp(-exp(eta)),size=1)
dat <- data.frame(dat,y)

library(lme4)
(g1 <- glmer(y~x+(1|f),data=dat,
      family=binomial(link="cloglog")))

fixef(g1)  ## matches (1,3) reasonably well
VarCorr(g1) ## matches sd=0.5 reasonably well

## now try crossed random effects
set.seed(1001)  ## reset
N1 <- 10
N2 <- 10
n <-  20
ntot <- n*N1*N2
dat <- expand.grid(f1=LETTERS[1:N1],f2=letters[1:N2],rep=1:n)
dat <- data.frame(dat,x=runif(ntot))
alpha1 <- rnorm(N1,sd=0.5)
alpha2 <- rnorm(N2,sd=1)

mm <- cbind(model.matrix(~x,data=dat),
            model.matrix(~f1-1,data=dat),
            model.matrix(~f2-1,data=dat))

eta <- mm %*% c(beta,alpha1,alpha2)
y <- rbinom(ntot,prob=1-exp(-exp(eta)),size=1)

(g2 <- glmer(y~x+(1|f1)+(1|f2),data=dat,
      family=binomial(link="cloglog")))

## warning about false convergence
fixef(g2) ## still OK.
VarCorr(g2)  ## reasonable but ??



Sasha Goodman wrote:
> Bump. So what was your solution to the cloglog issue? Has it been fixed
> in lme4?
> 
> Other people keep asking me about this issue.
> 
> On Tue, Nov 3, 2009 at 4:48 PM, Sasha Goodman <sashag at stanford.edu
> <mailto:sashag at stanford.edu>> wrote:
> 
>     So, I want to use the cloglog link. Is your solution working now?
>     Does it worked with crossed random effects?
> 
> 
>     On Thu, Oct 1, 2009 at 1:46 PM, Sasha Goodman <sashag at stanford.edu
>     <mailto:sashag at stanford.edu>> wrote:
> 
>         Very interested! Never came up with a solution. Even retried
>         with a recent version of lme4 recently.
> 
> 
>         On Thu, Oct 1, 2009 at 2:29 PM, Ben Bolker <bolker at ufl.edu
>         <mailto:bolker at ufl.edu>> wrote:
> 
> 
>              I came across your post to the r-sig-mixed list from May.
>              Did you ever resolve your problem?  I may have a solution
>             (of sorts)
>             if you're still interested.
> 
>              Ben Bolker
> 
>             --
>             Ben Bolker
>             Associate professor, Biology Dep't, Univ. of Florida
>             bolker at ufl.edu <mailto:bolker at ufl.edu> /
>             www.zoology.ufl.edu/bolker <http://www.zoology.ufl.edu/bolker>
>             GPG key: www.zoology.ufl.edu/bolker/benbolker-publickey.asc
>             <http://www.zoology.ufl.edu/bolker/benbolker-publickey.asc>
> 
> 
> 
> 
>         -- 
>         Sasha Goodman
>         Doctoral Candidate, Organizational Behavior
> 
> 
> 
> 
>     -- 
>     Sasha Goodman
>     Doctoral Candidate, Organizational Behavior
> 
> 
> 
> 
> -- 
> Sasha Goodman
> Doctoral Candidate, Organizational Behavior


-- 
Ben Bolker
Associate professor, Biology Dep't, Univ. of Florida
bolker at ufl.edu / people.biology.ufl.edu/bolker
GPG key: people.biology.ufl.edu/bolker/benbolker-publickey.asc




More information about the R-sig-mixed-models mailing list