[ADMB Users] R2admb with random effects
Charlotte Boyd
boydchar at uw.edu
Thu Sep 8 14:26:34 PDT 2011
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)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.admb-project.org/pipermail/users/attachments/20110908/1f998263/attachment.html>
More information about the Users
mailing list