An offset is generally just a coefficient set to a specific value. To get more than one offset, in general you just need to combine the different variables in a way that is consistent to get that fixed value.
In a Poisson equation if you set $Z$ as the offset (or exposure its sometimes called):
$$\log(\mathbb{E}[Y]) = \beta_0 + \beta_1X + 1\cdot Z$$
And you exponentiate both sides you then have:
$$\mathbb{E}[Y] = \text{exp}(\beta_0 + \beta_1X) \cdot \text{exp}(Z)$$
You can then interpret this as a rate per some unit $t$ if $Z = \text{log}(t)$:
$$\mathbb{E}[Y]/\text{exp}(\text{log}(t)) = \mathbb{E}[Y]/t = \text{exp}(\beta_0 + \beta_1X)$$
To get say two offsets we then start with:
$$\log(\mathbb{E}[Y]) = \beta_0 + \beta_1X + 1\cdot Z_1 + 1\cdot Z_2$$
Which we can exponentiate and regroup to be:
$$\mathbb{E}[Y] = \text{exp}(\beta_0 + \beta_1X) \cdot [\text{exp}(Z_1) \cdot \text{exp}(Z_2)]$$
Hopefully you see where I am going with this at this point. So if $Z_1 = \log(t_1)$ and $Z_2 = \log(t_2)$ we then have:
$$\mathbb{E}[Y]/(t_1 \cdot t_2) = \exp(\beta_0 + \beta_1X)$$
There are plenty of times to do this. Say you have people and then you have different exposure times for individuals, so you want the rate to be # of people*exposure time
.
So to get two offsets in any software you simply need to add $\log(t_1) + \log(t_2)$, or equivalently $\log(t_1 \cdot t_2)$, and then specify that new variable as the offset. So in R you would just have offset(log(hours*no.males))
in your example. In other software you may need to calculate $\log(t_1 \cdot t_2)$ as one new variable and specify that (I think in Stata and SPSS you would need to do it that way at least).
Note for your particular example, that when setting an exposure term it is a restricted model compared to letting the effect of say log(hours)
be something other than one. So I would suggest testing this via a likelihood ratio test, so something like:
Mod1 <- glmer.nb(no.aggression ~ log(no.males) + log(no.females)
+ (1|id_target) + offset(log(hours)), data=x)
Mod2 <- glmer.nb(no.aggression ~ log(no.females)
+ (1|id_target) + offset(log(hours*no.males)), data=x)
anova(Mod1,Mod2)
Where Mod2
is a more specific case of Mod1
.
You could even have offset(log(hours*no.males*no.females))
. This would make it a rate per all potential pairwise interactions (multiplied by hours). That does not sound too potentially inconsistent with what you have described, but currently you only have the linear no.males
and no.females
in the equation.