[R] R2WinBUGS problem
Troels Ring
tring at gvdnet.dk
Thu Jul 24 15:45:26 CEST 2008
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
Troels
cat("
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[],
upper[])
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)
}",
file="ml3_pig.bug")
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),
rho=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 - -
tring at gvdnet.dk
More information about the R-help
mailing list