2

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)



Michael R. Chernick
  • 39,640
  • 28
  • 74
  • 143
Antonela
  • 33
  • 4
  • Could you explain what you mean by "observed data are continuous"? In what sense are you conceiving of your animal counts as continuous responses? – whuber Dec 30 '19 at 17:15
  • I don't get your scruples about Gamma here, if you're estimating population *densities*. It would be silly if you were fitting *counts*, but your phrasing seems to indicate the former. – jkm Dec 30 '19 at 17:40
  • I mean, I count animals in the field, but, since there might be animals that were not detected (that is why I used indirect detection methods to estimate density) I estimate the number of animals/km2. This is a common way of working in ecology. Most of the books on the topic (Eg: Dietze 2017), state that the variable should be treated as discrete because the data obtained in the field is were the number of animals. – Antonela Dec 30 '19 at 18:43
  • I have density estimations for a few years (9) and I intend to relate this with another variable – Antonela Dec 30 '19 at 18:44

2 Answers2

2

You have stated in your question that the response variable population_density (quantifying animals per square kilometer) is continuous. That is unsurprising, since that variable is the ratio of a count variable and an area value. Presumably then, it must have been based constructed from an underlying count of animals in an area, and the area_size. If you would like to implement a count model on the data (e.g., Poisson GLM, negative binomial GLM, etc.), you will need to find the underlying variables that were used to compute the ratio value. This data will probably exist somewhere, so go back to the source and see if you can get it.

Assuming that you are able to recover the underlying count variable animals you are then in a position to be able to implement a regression method for count data. For reasons described elsewhere (see here), I counsel against using a Poisson GLM --- this is a one-parameter model that fails to fit the variability of the data, and requires an "over-dispersion test". You are far better off starting with a two-parameter count model such as a negative binomial GLM. (That is my usual starting point for regression analysis with a count variable as the response.)

Ben
  • 91,027
  • 3
  • 150
  • 376
1

If you want to model with a Poisson distribution then your outcome data should be in counts, not converted to densities. Modeling with a Poisson in terms of counts has the simplifying advantage that the variance equals the mean, but if you convert the counts to densities then I suspect that the software wouldn't know how to proceed (although I have no experience with JAGS).

One standard way to deal with this issue is to use the actual counts as the outcome variable while including an offset as a predictor to account, in your case, for the area sampled.

Alternatively, as a comment on your question indicates, you could model the densities while accepting that you will then be using continuous distributions that will probably have more free parameters to fit than for a Poisson.

EdM
  • 57,766
  • 7
  • 66
  • 187