I am trying to simulate the "time" of observation as a random variable using OpenBUGS via R (R2OpenBUGS). If all the observation time is available (no NA), everything works, but if I set one of the NA times, nothing will happen. I tested the same code with WinBUGS, and I get a "NIL break (read)" trap error. So my question is is there something really wrong in my code, or is my model too weird for BUGS?
My model looks like this:
model{ for(i in 1:k){ obs[i] ~ dbern(p)
And the R code looks like this:
library(R2OpenBUGS) x<-obs<-rep(NA,5) for(i in 1:k) { obs[i]<-sample(c(0,1),1) #observation time of ith observation x[i]<-rnorm(1) #observed values } obs[2]<-NA #one of the sampling times is missing INITS <- list(list(tau=1,mu=0,p=0.5)) DATA <- list(x=x,n=n,k=k,obs=obs) ob <- bugs( data=DATA, inits=INITS, parameters.to.save=c("tau","mu","p","y"), model.file="BUGSModel.R", n.chains=1, n.iter=50, n.burnin=10, n.thin=1, DIC=FALSE)
source share