I am working in population ecology and I am trying to write a linear regression using in JAGS. It is a simple model where I intend to relate population density with annual productivity. Population density (animals/km2)values were obtained using count data and indirect detection measures, and so I intend to use a Poisson distribution, but the observed data are continuous. When I run the code, I get this error: Error in jags.model(file = model.file, data = data, inits = inits, n.chains = n.chains, :
Error in node o[1]
I am thinking that this might be because of the nature of the variable. Densities are a continuous variable but since they come from count data, I think that any continuous distribution, like gamma or lognormal, would be wrong. Any suggestions regarding this problem?
> o<-c(22.77619, 19.07782, 22.08817, 16.32168, 32.57081, 10.48027, 15.93440, 27.54557, 33.39933)
> evi<-c(0.07289889,0.06288981,0.065947587,0.05886781,0.07037986,0.06540081,0.07219641,0.0798039,0.08368564)
> n<-9
> cat(file = "reg.bug", "
+ #Likelihood:
+ model {
+ for(i in 1:9){
+ o[i] ~ dpois(mu[i])
+ mu[i] <- b0 + b1 *(evi[i])
+ }
+ #priors:
+ b0 ~ dlnorm(1,0.0001)
+ b1 ~ dlnorm(1,0.0001)
+ }")
> #linear regression
> reg.data<-c("o","evi")
> inits<-function()list(b0=rlnorm(1,1,1),b1=rlnorm(1,1,1))
> params<-c("b0","b1")
> ni <- 10000
> nt <- 1
> nb <- 5000
> nc <- 3
> library(jagsUI)
> reg.model <- jags (model.file = "reg.bug", data = reg.data, parameters.to.save = params,
+ inits=inits, n.burnin=nb,n.chains = nc,n.iter = ni)