A quetion

June 21, 2010

(This article was first published on Shige's Research Blog, and kindly contributed to R-bloggers)

I posted a question to the R-Mixed-Model mailing list but have not had any responses yet:

Dear All,

I wonder if anybody has tried to make glmmBUGS work with JAGS. My
attempt was not successful.

Here is the simple example I copied from the glmmBUGS Vignettes:


bacterianew <- bacteria
bacterianew$yInt = as.integer(bacterianew$y == "y")

levels(bacterianew$trt) <- c("placebo", "drug", "drugplus")


bacrag <- glmmBUGS(formula = yInt ~ trt + week, data=bacterianew,
effects = "ID",
modelFile="model.bug", family="bernoulli")



startingValues = bacrag$startingValues

With WinBUGS, it runs well:


bacResult1 = bugs(bacrag$ragged, getInits, model.file="model.bug", n.chain=3,
n.iter=2000, n.burnin=100, parameters=names(getInits()), n.thin=10)

But with JAGS, I got error message "Error in FUN(50L[[1L]], ...) :
invalid first argument"



bacResult = jags(data=bacrag$ragged, n.chain=3, n.iter=2000,

I hope somebody can help me figuring out how to make this work. Many thanks.



Here is the answer from Jens Åströ

Not an expert by any means, but I got it to run by doing this:

1) change inprod2 to inprod in the model file (JAGS does not have
inprod2 function)

2) change ~dflat() to other uninformative prior, e.g.
~dnorm(0.0,1.0E-6) (Jags does not have dflat distribution)

3) specify/compile the model with e.g.

4) update it, update(bac.jags,1000)

5) Collect coda samples,

This seemed to converge well, (gelman.diag(bacResult))

Good luck

It works.

To leave a comment for the author, please follow the link and comment on their blog: Shige's Research Blog.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Tags: , ,

Comments are closed.

Search R-bloggers


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)