[R] R2WinBUGS problem

From: Troels Ring <tring_at_gvdnet.dk>
Date: Wed, 23 Jul 2008 23:49:35 +0200

Dear friends - I'm on winXP, R 2.71 - I have with some help dveloped this multivariate normal model, which gives very plausible results in WinBUGS even without any
initial values specified. However, when I then try to run the same model via the bugs function in R2WinBUGS with inits specified as inits=NULL the program stops in a dead end. So I have tried to make inits for the bugs function as shown below. But then WinBUGS come to a halt while these inits are being handled so they are seemingly wrong. This is a bit annoying and I would like to know how I managed to corrupt the inits. This is sent both to WinBUGS and R with hope and some anxiety. Best wishes

model {
  for (i in 1:126) {

         dep[i]   ~   dnorm(mu.dep[i],tau.dep)
       mu.dep[i]  <-  alpha[ID[i]]*NAK.cor[i]+beta[ID[i]]*TBW.cor[i]
       fit[i]     <-  mu.dep[i]+CONST[i]
  tau.dep     <-  pow(sigma_dep,-2)

  sigma_dep ~ dunif(0,100)
  for (j in 1:16) {
  alpha[lev[j]]         <-   AB[lev[j],1]
  beta[lev[j]]          <-   AB[lev[j],2]
  AB[lev[j],1:2]        ~   dmnorm(AB.hat[lev[j],],tau.AB[,])I(lower[], 
  AB.hat[lev[j],1]      <-  mu.alpha
  AB.hat[lev[j],2]      <-  mu.beta
  lower[1]            <- 0
   lower[2]           <- -100
   upper[1]           <- 100
   upper[2]           <- 0

  mu.alpha        ~ dnorm(0,0.0001)
  mu.beta         ~ dnorm(0,0.0001)

  tau.AB[1:2,1:2] <- inverse(sigma.AB[,])

  sigma.AB[1,1]   <-  pow(sigma.alpha,2)
  sigma.alpha     ~   dunif(0,100)
  sigma.AB[2,2]   <-  pow(sigma.beta,2)
  sigma.beta      ~   dunif(0,100)
  sigma.AB[1,2]   <-  rho*sigma.alpha*sigma.beta
  sigma.AB[2,1]   <-  sigma.AB[1,2]
  rho              ~  dunif(-1,1)

pigs3.inits <- function () {
  list (AB=array(c(runif(16,0,10),runif(16,-30,0)),c(16,2)),
  mu.alpha=runif(1,0,10), mu.beta=runif(1,-30,0),
  sigma.dep=runif(1), sigma.alpha=runif(1), sigma.beta=runif(1), 

pigs.parameters <- c ("mu.alpha", "mu.beta", "sigma_dep","alpha","beta", "fit","deviance","rho")

pigs3 <- bugs (ml_pig.data, debug=TRUE,inits=pigs3.inits, pigs.parameters, "ml3_pig.bug", n.iter=2000,n.chains=3, bugs.directory = bugs.directory)


Troels Ring - -
Department of nephrology - - 
Aalborg Hospital 9100 Aalborg, Denmark - -
+45 99326629 - -

R-help_at_r-project.org mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Wed 23 Jul 2008 - 21:52:55 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 23 Jul 2008 - 22:32:51 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive