# How to formulate the offset of a GLM

I am trying to build a generalized linear model in R for some count data. Basically I have counted the number of animals per unit after having them presented with a treatment (for all units there was a 6 week exposure). That is, depending on treatment there could be more, fewer or the same number of animals after the treatment. Because the units had varying numbers of animals to begin with I could either use a proportion, or the actual counts after the treatment with the initial number of animals as an offset. I heard the last option is favorable.

I have seen that for a Poisson model one adds the offset like this: offset(log(initial_no)). However I lean toward using a negative binomial model. Would one then set the link function of that in front of the offset? I have also seen offset(1|initial_no). When is this term used?

• Are your data number that survived out of a known initial total? Is the survival assessed after an identical temporal interval for all animals? Do you know the time when each animal died during the study period? – gung Oct 1 '16 at 23:25
• @gung: I have edited my question according to your questions. The animals didn't have individual tags, so I don't know when exactly wich one died, but I do have counts after each of the 6 weeks of the experiment. However modeling repeated measures seems more complicated and maybe not necessary for my research question... – Dunen Oct 2 '16 at 14:07
• Are there any cases where there are actually more animals afterwards than before? If you want to know about other links, you'll need to specify the link you are thinking about. However, I don't really see an advantage to using a different link from the log. If you think the curvature specified by the log / exp transformation is wrong, you could add polynomial or spline terms. I would still stick with the log link. – gung Oct 2 '16 at 15:42
• Yes, in maybe a little less than half the cases there were more animals afterwards. In about a third of the cases there were no or very little animals after the treatment. – Dunen Oct 2 '16 at 22:35

I don't know where you heard that a Poisson or negative binomial with an offset is preferable to a binomial model for a number of individuals surviving out of an initial number; I would normally prefer a binomial as it is closer to the actual stochastic process we think is going on. Note that the binomial model would be a binomial GLM,

$$n_{\textrm{surv}} \sim \textrm{Binomial}(p,N)$$ — different from computing the proportion n/N and using a linear model (or something like that).

However, given that (the edited version of) the question allows for there to be more individuals at the end than at the beginning of the period, the binomial models (and variants such as quasi- or betabinomial) won't work, as they don't allow for an increase in numbers.

In a typical case (not yours) where individuals can only be lost and not gained, the Poisson or negative binomial models will only give sensible answers if the proportion surviving (or the proportion dying, if you quantify mortality rather than survival) is much smaller than 1. In general the variation in the number surviving becomes small as the survival probability approaches 1; the binomial model capture this phenomenon naturally, the Poisson / NB models don't. (The variance becomes small in both models as the probability approaches 0.)

If you do want to use an offset-count model instead, the method for incorporating the offset doesn't differ between Poisson and NB models, both of which almost always use a log link. That is, the model would be written as: $$\begin{split} n_{\textrm{surv}} & \sim \textrm{Poisson}(\mu) \quad \textrm{or} \quad \sim \textrm{NegBinom}(\mu,k) \\ \mu & = \exp(\beta + \log(N)) = N \exp(\beta) \end{split}$$ the second line could also be written as $\log(\mu) = \beta + \log(N)$ (which looks like the regression formula containing an offset) or $\mu/N = \exp(\beta)$, which shows that you're modeling $\beta$ as the log-proportion of survival. In the case where the numbers can increase, $\beta$ would be positive and would represent the log of the expected proportional increase in numbers.

If you happened to decide on an identity link instead (which I wouldn't usually recommend, as it's easy in that case for the optimization process to try negative values for the Poisson/NB mean, which might break the computation), then you'd use an offset of $N$ (not $\log(N)$) so that $\mu = \beta + N$, so $\beta$ represents the additive change in numbers. While sometimes computationally difficult, this does make conceptual sense ...

One possible advantage of the NB model would be that it accounts for overdispersion (e.g., among-individual variation in survival probability), which the binomial or Poisson models don't. You could handle that in the binomial world by switching to a beta-binomial or to a quasi-binomial model ...

If you were using R, assuming your variables are n (surviving number), N (initial number), ttt (a factor/categorical variable specifying treatment group), you would use

• glm(n/N~ttt, family=binomial, weights=N) or
• glm(n/N~ttt, family=quasibinomial, weights=N) or
• glm(n~ttt+offset(log(N)), family=poisson) or
• MASS::glm.nb(n~ttt+offset(log(N)))

I've never seen a model with offset(1|initial_no) in it; what software was using this ... ?

• Sorry, I think I didn't specify well enough that the animals also replicated in some treatments, i.e. there are more than a ratio of 1 in some treatments, while in other there are less than one. Does that exclude the use of the binomial than? But your answer suggests it also excludes the poisson and neg binomial? I do have a lot of units though where no animals are left. I have seen the offset(1|initial_no) in R, but I don't remember in wich context... – Dunen Oct 2 '16 at 14:19
• Just to clarify: If I had another link function I than would add the term of that link function in front of the offset? – Dunen Oct 2 '16 at 14:21
• what other link function would you be thinking about using? – Ben Bolker Oct 2 '16 at 16:34