1
$\begingroup$

I am trying to apply a glmer on syllable-count data obtained from bird song. I include the record ID as a random factor (1 | rec_ID) due to variation in the number of songs per recording, and consider the counted data as a rate due to the song lengths differing between each song. The recordings are obtained over a latitudinal range from 0 to -30 in South America. My goal is to investigate differences in total syllables over this latitudinal range. This leads to the following glmer formula:

glmer(total_syllables ~ latitude + offset(log(song_length)) +
                      (1 | rec_id), data = song_data, family = poisson(link = "log"))

From what I understand about the offset, I have to log the song_length variable due to using poisson as the family. The model outputs are as follows:

Fixed effects:
             Estimate Std. Error z value Pr(>|z|)    
(Intercept)  2.199780   0.094403  23.302   <2e-16 ***

latitude    -0.006731   0.005398  -1.247    0.212    

In this study, the model estimates are important for visualization and analysis purposes. However, the model estimates are nowhere near the true data, and i suspect that is due to the log(song_length) within the offset term. I cannot find any comparable problem, as the only examples either include a random effect OR offset in a glmer, and not both. Can someone clarify what the log in the offset does to the model outputs, and how to interpret these estimates?

$\endgroup$
1
  • 2
    $\begingroup$ You say that "the model estimates are nowhere near the true data," but it's not clear what that means. Please edit the question to provide an example of "true data" that differ from the model estimates. For example, what is the average number of syllables per unit time of song_length? How many typical observations per rec_id? What's a typical song_length? Strictly speaking, you use the log of song_length as the offset to correspond to the log link of the Poisson model. It's possible (if unusual) to use other links, which would require different offset forms. $\endgroup$
    – EdM
    Commented Oct 29, 2022 at 16:04

2 Answers 2

1
$\begingroup$

My understanding is that you need to log() the offset term because the Poisson (and negative binomial) uses a log-link function and this keeps the units consistent with what is happening to the count. Each 1 unit increase in latitude equates to an e^-0.006731 change in the variable "total_syllables" (FYI: I had a similar question so I might be getting this wrong).

$\endgroup$
0
$\begingroup$

To interpret the coefficient on latitude, exponentiate and interpret as a rate.

> exp(-0.006731)
[1] 0.9932916

That's about 0.99. Therefore for every one unit increase in latitude we expect to see about a 1% decrease in total_syllables. Of course the standard error is large and z value is small. It's not altogether clear whether this effect is positive or negative. Another sample could result in a positive coefficient for latitude. Whatever the effect of latitude, it appears to be small.

The offset is added to the linear predictor during estimation. It's basically a predictor in your model with a coefficient of 1. The reason we take the log is due to some algebra and logarithm rules. The linear predictor is

$$\text{log}\left( \frac{\text{total_syllables}}{\text{song_length}} \right) = \beta_0 + \beta_1\text{latitude}$$

Recalling the rules of logs we can re-write the left-hand side:

$$\text{log}(\text{total_syllables}) - \text{log}(\text{song_length}) = \beta_0 + \beta_1\text{latitude}$$

And then we can add $\text{log}(\text{song_length})$ to both sides.

$$\text{log}(\text{total_syllables}) = \beta_0 + \beta_1\text{latitude} + \text{log}(\text{song_length})$$

That's your model (without the random effects).

Using your model coefficients we can estimate marginal expected total_syllable rates for say, latitude = -10 and latitude = -9. Notice we need to use the log offset in the estimation. I arbitrarily picked 1000. It doesn't matter what you pick, you'll get the same answer.

> est1 <- exp(2.199780 + -0.006731 * -10 + log(1000)) / 1000
> est1
[1] 9.651275
> est2 <- exp(2.199780 + -0.006731 * -9 + log(1000)) / 1000
> est2
[1] 9.58653

If we take the ratio of est2/est1, we get the same answer we got when we exponentiated the latitude coeffient.

> est2/est1
[1] 0.9932916
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.