unknown type of logical function
Code:
blog comments powered by Disqus
n <- 10
x <- rnorm(n)
b <- rnorm(n)
rho <- exp(x*b)
N <- rpois(n,rho)
y <- rbinom(n,N,.5)
library(R2OpenBUGS)
model <- function() {
for (i in 1:n) {
y[i] ~ dbin(0.5,N[i])
N[i] <- dpois(rho[i])
rho[i] <- exp(x[i]*b)
}
b ~ dnorm(0,1)
}
fn <- file.path(tempdir(), "model.txt")
write.model(model,fn)
data <- list(n=n,y=y,x=x)
inits <- list(list(N=10))
parameters <- c("N")
sim <- bugs(data,inits,parameters,fn,n.chains=1,n.burnin=1,n.thin=1,n.iter=1e3)
produced the error:
OpenBUGS version 3.2.1 rev 781
type 'modelQuit()' to quit
OpenBUGS> unknown type of logical function error pos 76 (error on line 5)
OpenBUGS> model must be checked before data is loaded
OpenBUGS> model must be checked before compiling
OpenBUGS> model must have been compiled but not updated to be able to change RN generator
OpenBUGS> model must be compiled before initial values loaded
OpenBUGS> model must be compiled before generating initial values
OpenBUGS> model must be initialized before updating
OpenBUGS> model must be initialized before monitors used
OpenBUGS> model must be initialized before monitors used
OpenBUGS> model must be initialized before monitors used
OpenBUGS> model must be initialized before monitors used
OpenBUGS> model must be initialized before DIC can be monitored
OpenBUGS> model must be initialized before updating
OpenBUGS> model must be initialized before monitors used
OpenBUGS> model must be initialized before monitors used
OpenBUGS> DIC monitor not set
OpenBUGS>
due to:
N[i] <- dpois(rho[i])
which should have been
N[i] ~ dpois(rho[i])
blog comments powered by Disqus