[ADMB Users] R2admb with random effects

Mollie Brooks mbrooks at ufl.edu
Thu Sep 8 14:55:59 PDT 2011


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.

"re	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.
cheers,
Mollie




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

> Hi
>  
> 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
>  
>  
> Charlotte Boyd
> School of Aquatic and Fishery Sciences
> University of Washington
> 1122 NE Boat St Rm 116
> Seattle WA 98105
>  
>  
>  
> library(R2admb)
> library(lme4)
> 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, nobs=nrow(cbpp))
>  
> d1 <- do_admb("test",data=tmpdat,re=TRUE,params=list(beta=rep(0,ncol(X)),sigma_herd=0.1),bounds=list(sigma_herd=c(0.0001,20)),re_vectors=list(u_herd=ncol(Zherd)),
> run.opts=run.control(checkdata="write",checkparam="write"),mcmc=TRUE,mcmc.opts=mcmc.control(mcmcpars=c("beta","sigma_herd")))
>  
> # .tpl file
>  
> PARAMETER_SECTION
>  
>   vector herdvec(1,nobs)
>   vector eta(1,nobs)
>   vector mu(1,nobs)
>  
> PROCEDURE_SECTION
>  
>   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))+
>   elem_prod(size-incidence,log(1.0-mu)));
>  
>   f+=0.5*norm2(u_herd); // log-prior (standard normal)
>  
>  
> _______________________________________________
> Users mailing list
> Users at admb-project.org
> http://lists.admb-project.org/mailman/listinfo/users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.admb-project.org/pipermail/users/attachments/20110908/28d21e25/attachment.html>


More information about the Users mailing list