# When to use offset() in negative binomial/poisson GLMs in R

I'm trying to detect relationships between species abundances (counts) and time (years) for many species using either Negative Binomial or Poisson regressions (depending on degree of dispersion). Sampling time (minutes) is not the same for all collections so my questions are:

1) What is the best way of determining when to use negative binomial vs. Poisson?

2) Is this an appropriate instance to include sampling time in an offset term? In most cases, sampling occurs for 10 minutes, but it is sometimes 15 or 20 minutes.

Any suggestions or advice would be appreciated.

1. What is the best way of determining when to use neg. binom. vs. poisson?

A common way (not necessarily the best --- what's 'best' depends on your criteria for bestness) to decide this would be to see if there's overdispersion in a Poisson model (e.g. by looking at the residual deviance.

For example, look at summary(glm(count~spray,InsectSprays,family=poisson)) - this has a residual deviance of 98.33 for 66 df. That's about 50% larger than we'd expect, so it's probably big enough that it could matter for your inference.

[If you want a formal test, pchisq(98.33,66,lower.tail=FALSE), but formal testing of assumptions is generally answering the wrong question.]

So I'd be inclined to consider a negative binomial for that case. Indeed, anticipating potential for heterogeneity, I'd probably have started there.

More generally, if you're not reasonably confident that the Poisson makes sense, you could simply use negative binomial as a default, since it encompasses the Poisson as a limiting case.

1. Is this an appropriate instance to include sampling time in an offset term?

Yes, that's appropriate, and it would be my first instinct to include sampling time as an offset (rather than a predictor), since count would be expected to simply be proportional to the length of the sampling interval.

• I would consider adding log(sampling_time) as a predictor and seeing whether its coefficient is very different from 1 (proportionality). I can imagine, and have seen, plenty of situations where this is not true, e.g. increase in count decelerates as sampling time increases ... Dec 17, 2014 at 3:14
• @BenBolker It's certainly possible that the coefficient isn't reasonably consistent with 1; if I was less than confident in it, I'd be more inclined to use a diagnostic tool rather than formal test, but you could certainly do a test. If I were to test it, I'd even consider putting it in both places (assuming it will let you without making a dummy copy or something) and see whether the remaining effect differed from 0. Dec 17, 2014 at 3:31
• At least in R, you can do that. I believe there's an example in the "owls" project at groups.nceas.ucsb.edu/non-linear-modeling/projects Dec 17, 2014 at 3:36
1. What is the best way of determining when to use negative binomial vs. Poisson?

Answer: Poisson GLMs assume the mean and variance of the response variable are approximately equal. Overdispersion can occur when this assumption is not met; variance in the data is naturally larger than the mean. This situation is termed "true overdispersion". True overdispersion is dealt with by fitting a model to the data such that the variance is greater than the mean in the response variable.

However, the negative binomial GLM does not assume that the variance of the response variable is equal to its mean and, therefore, can be used to model overdispersed data, which is a common property of ecological data.

To check if a model is overdispersed or not we divide deviance by residual. For example:

model1 <- glm(weight ~ height + age, data = df1, family = poisson(link = "log"))
ods <- model1$$deviance/model1$$df.residual
ods

If the value of ods is around 1 then the model is not overdispersed. If ods is around 2 or above the model is overdispersed and the prediction/assumption from the model output can be problematic. In such a situation, negative binomial can be use because it does not assume that the variance of the response variable is equal to its mean.

1. Is this an appropriate instance to include sampling time in an offset term? In most cases, sampling occurs for 10 minutes, but it is sometimes 15 or 20 minutes.

Answer: Yes, because more sampling efforts mean more species is counted. To give each sampling effort an equal opportunity/weight in the model we need to use this as an offset term. The same logic can be applied for locations with variable survey efforts to observe species abundance (count).