[R-sig-ME] Problem in simulate() with GLMMs when a link function is specified ?

Pierre Morel pier.morel at gmail.com
Thu May 31 17:07:48 CEST 2012


Dear all,

This is my first message to the list, I hope I won't start on the wrong foot !

I installed the last version of lme4 (0.999902345-0) and I think there is a problem in simulate() when trying to simulate a GLMM in which a link function was specified.
For example, this works (directly from the manual):

gm1 <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd), data = cbpp, family = binomial)
gg <- simulate(gm1,10)

However, when you specify the link function for the binomial family (even if you keep the default one, logit), there is an error:

gm1 <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd), data = cbpp, family = binomial(link="logit"))
gg <- simulate(gm1,10)

Error in simulate.merMod(gm1, 10) : 'family' not recognized

Not a problem if you want to use the default link, but I have psychophysics data for which I would like to use the mafc.logit(2) from the psyphy library.

When I look at the source code, even if I am not good enough in R programming to fix it, it seems that it should work with any link function, since the end result seems only used to get the inverse link function: 

	      etasim <- etasim.fix+etasim.reff
	      family <- object at call$family
	      if(is.symbol(family)) family <- as.character(family)
	      if(is.character(family))
		  family <- get(family, mode = "function", envir = parent.frame(2))
	      if(is.function(family)) family <- family()
	      if(is.null(family$family)) stop("'family' not recognized")
	      musim <- family$linkinv(etasim)

Any idea for a quick fix ?

Regards,

Pierre Morel

-- 
Dr. Pierre Morel
German Primate Center (DPZ)
Sensorimotor Research Group


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