[ADMB Users] R2admb with random effects

Charlotte Boyd boydchar at uw.edu
Thu Sep 8 15:24:56 PDT 2011

Hi Mollie

Yes – you’re right. Many thanks for pointing that out. If only it was always
that simple!



*From:* Mollie Brooks [mailto:mbrooks at ufl.edu]
*Sent:* Thursday, September 08, 2011 2:56 PM
*To:* Charlotte Boyd
*Cc:* users at admb-project.org
*Subject:* Re: [ADMB Users] R2admb with random effects

Hi Charlotte,

I suspect that the pdf is not as up to date as the help file. I checked the
help file ?do_admb and saw that there's a parameter called re, but not one
called re_vectors.


a named list of the identities and dimensions of any random effects vectors
or matrices used in the TPL file


Try replacing "re_vectors" with "re" in your call to do_admb.



On 8 Sep 2011, at 5:26 PM, Charlotte Boyd wrote:


I would like to use R2admb with a random effects model. When I try the toy
example in the vignette, I get the following error message:

Error in do_admb("test", data = tmpdat, re = TRUE, params = list(beta =
rep(0,  :

  unused argument(s) (re_vectors = list(u_herd = ncol(Zherd)))

I’m using R version 2.13.1 (2011-07-08), and have tried this on other
computers and got the same error message. I’ve copied all the code from
R2admb.pdf (Bolker, 2011), but for completeness, the code I’m using and the
‘bare-bones’ .tpl file are below. It’s probably something simple I’m missing
– I’d appreciate any suggestions on what that is.

With many thanks


*Charlotte Boyd*

*School of Aquatic and Fishery Sciences*

*University of Washington*

*1122 NE Boat St Rm 116*

*Seattle WA 98105*



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

X <- model.matrix(~period,data=cbpp)

Zherd <- model.matrix(~herd-1,data=cbpp)

tmpdat <- list(X=X,Zherd=Zherd, incidence=cbpp$incidence,size=cbpp$size,

d1 <-


# .tpl file


  vector herdvec(1,nobs)

  vector eta(1,nobs)

  vector mu(1,nobs)


  herdvec = sigma_herd*(Zherd*u_herd);

  eta = X*beta; // form linear predictor

  eta += herdvec; // augment with random effects

  mu = pow(1.0+exp(-eta),-1.0); // logistic transform

  // binomial log-likelihood (unnormalized)

  f -= sum(elem_prod(incidence,log(mu))+


  f+=0.5*norm2(u_herd); // log-prior (standard normal)

Users mailing list
Users at admb-project.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.admb-project.org/pipermail/users/attachments/20110908/f26aa184/attachment.html>

More information about the Users mailing list