So I'm trying to do this bayesian data modeling project and I went back to my notes from my bayesian stats class on rjags where my professor went over a really similar model. I was able to run that one without any issues, but when I adapt it to my model I'm getting an error as my output.
Here is my code:
library(rjags)
set.seed(12196)
# Number of bear reports
Y <- black_bears$Y # Number of surveys saying there was a reported bear sighting
N <- black_bears$N # Number of surveys submitted on whether a bear was seen or not
q <- Y/N # proportion of the non-bear sightings submitted
n <- length(Y)
X <- log(q)-log(1-q) # X = logit(q)
data <- list(Y=Y,N=N,X=X)
params <- c("beta")
model_string <- textConnection("model{
# Likelihood
for (i in 1:n){
Y[i] ~ dbinom(p[i], N[i])
logit(p[i] <- beta[1] + beta[2]*X[i])
}
# Priors
beta[1] ~ dnorm(0, 0.01)
beta[2] ~ dnorm(0, 0.01)
}")
model <- jags.model(model_string,data = data, n.chains=2,quiet=TRUE)
update(model, 10000, progress.bar="none")
samples1 <- coda.samples(model, variable.names=params, thin=5, n.iter=20000, progress.bar="none")
plot(samples1)
I'm getting presented with this error:
Any and all help is appreciated. Thank you!