3

Using the offset as argument and in a formula should give the same output. As one can see here https://stackoverflow.com/a/29233096/426176.

However, using glm.nb I get different results:

mod1 <- glm.nb(y ~ x1 + x2 + offset(log(pop)))
mod2 <- glm.nb(y ~ x1 + x2, offset(log(pop)))

I'm a bit confused about which is the most adequate when using glm.nb.

I also use gam with a negative binomial and a poison family and I also get different results, which make sense when using predict as the offset as an argument is ignored. Hence predicting the number of cases and not incidence.

From GAM help page: "offset: Can be used to supply a model offset for use in fitting. Note that this offset will always be completely ignored when predicting, unlike an offset included in formula: this conforms to the behaviour of lm and glm."

psoares
  • 4,733
  • 7
  • 41
  • 55
  • 2
    For `glm`, it's the same when passed as a named parameter so `glm(y ~ x1 + x2, offset=log(pop))` NOT `glm(y ~ x1 + x2, offset(log(pop)))` but the documentation for `glm.nb` specifically says "Note that these [arguments] exclude `family` and `offset` (but `offset()` can be used)." This means you need to use the `mod1` syntax. – MrFlick Jul 03 '20 at 14:20
  • Yes, sorry it's `=` for the argument. So for `glm.nb`, `offset` can be used only inside the formula? I assumed that it could be used as an argument as I got no error =/ I will use the `offset` inside the formula then. Thank you for the clarification! – psoares Jul 03 '20 at 14:25
  • It would be great if you could include a [mcve] – Ben Bolker Jul 03 '20 at 14:32
  • 1
    @MrFlick, post as answer ... ? – Ben Bolker Jul 03 '20 at 14:32
  • 2
    @psoares, if the information in the comments has given you enough information to post an answer to your own question, you're encouraged to do so (I don't know if there's some time window before you can do so) – Ben Bolker Jul 03 '20 at 14:58
  • Hi, thank you both. I'm just trying to understand a bit more about this difference. It's not urgent since I'm not doing any work on this at the moment. So I will wait a bit more and try to understand what's happening, though @MrFlick answer was already useful! – psoares Jul 09 '20 at 09:47

0 Answers0