Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Defining Two Offsets in a Joint Poisson Model with INLA

14 views
Skip to first unread message

Felipe Barletta

unread,
May 8, 2025, 5:43:13 PMMay 8
to r-inla-disc...@googlegroups.com

Dear INLA Community,

I am currently working on fitting a joint model using two Poisson responses in INLA, with the need to define two different offsets, one for each response variable, because my data is area-based.

I attempted to use the following approach:

offset = ifelse(joint.data$Y[[1]], log(offset.1), log(offset.2))


However, I'm not sure if it is working. When I inspected the fitted.values I noticed when
the response variables (Y1 and Y2) are zero at the same time, the log(fitted.values) has negative values.

>head(test, 100)
log(Y1.fitted.v) Y1(c.lung) Y2(c.obitos)
          <num>  <int>    <int>
  1:  0.9745005      5        0
  2:  1.1125816      4        1
  3:  0.9148143      2        0
  4:  1.0666845      1        0
  5:  1.0522108      1        0
  6:  0.7990224      3        0
  7:  0.8561808      4        2
  8:  0.9079571      1        1
  9:  0.8729477      2        0
 10:  0.9261394      2        0
 11:  1.0123998      1        0
 12:  1.1035041      3        0
 13:  1.1699939      4        3
 14:  1.0909254      1        1
 15:  1.1069584      4        1
 16:  0.9079571      1        0
 17:  1.1014186      5        1
 18:  1.0509050      4        2
 19:  1.0548733      4        1
 20:  1.1237341      3        0
 21:  1.1546738      2        0
 22:  1.0027626      4        1
 23: -5.1696851      0        0
 24:  0.8800483      4        1

This print is referred only to Y1.
To Y2 is:
> head(test, 100)
             
log(Y2.fitted.v)    Y1(c.lung) Y2(c.obitos)
    <num>  <int>    <int>
  1: -0.4602072      5        0
  2: -0.4602072      4        1
  3: -0.4602072      2        0
  4: -0.4602072      1        0
  5: -0.4602072      1        0
  6: -0.4602072      3        0
  7: -0.4602072      4        2
  8: -0.4602072      1        1
  9: -0.4602072      2        0
 10: -0.4602072      2        0
 11: -0.4602072      1        0
 12: -0.4602072      3        0
 13: -0.4602072      4        3
 14: -0.4602072      1        1
 15: -0.4602072      4        1
 16: -0.4602072      1        0
 17: -0.4602072      5        1
 18: -0.4602072      4        2
 19: -0.4602072      4        1
 20: -0.4602072      3        0
 21: -0.4602072      2        0
 22: -0.4602072      4        1
 23: -0.4602072      0        0
 24: -0.4602072      4        1
.
Could someone please advise on how to correctly set up two separate offsets for the two responses in a joint model?
Is there a more efficient way to ensure the offsets are correctly matched with each response without causing any issue?

The code to model is:

m1 <- inla(Y ~ -1 +
    #Intercepts
    inter +
    #Y1 model
    scale(age60.1) +
   f(idx.sh.1, model = "besag", graph = W.pt, scale.model = TRUE) +
    #Y2 model
    scale(age60.2) +
    f(idx.sh.2, model = "besag", graph = W.pt, scale.model = TRUE) ,
    offset = ifelse(joint.data$Y[[1]],log(offset.1), log(offset.2)),
    #offset = log(offset.1),
    data = joint.data,
    family = c("poisson","poisson"),
    control.predictor = list(link = 1, compute = TRUE),
    control.compute=list(dic = TRUE, cpo = TRUE, return.marginals.predictor = TRUE)
)

Thank you.

Helpdesk (Haavard Rue)

unread,
May 9, 2025, 3:34:15 AMMay 9
to Felipe Barletta, r-inla-disc...@googlegroups.com

you can define the offset in various ways, which can also be combined. with the
poisson, there is a third way as well.

n <- 10
y <- 1:n
off <- log(1:n)

r <- inla(y ~ 1 + offset(off),
data = data.frame(y, off),
family = "poisson")
rr <- inla(y ~ 1,
data = data.frame(y, off, E = exp(off)),
E = E,
family = "poisson")
rrr <- inla(y ~ 1,
data = data.frame(y, off),
offset = off,
family = "poisson")

r$mlik
rr$mlik
rrr$mlik

> --
> You received this message because you are subscribed to the Google Groups "R-
> inla discussion group" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to r-inla-discussion...@googlegroups.com.
> To view this discussion, visit
> https://groups.google.com/d/msgid/r-inla-discussion-group/CAJz4ZjHV0_N%2BbO70jTJHKG0WFTaU_cvT4%2B_YAfAMAchfO7gg%3Dg%40mail.gmail.com
> .

--
Håvard Rue
he...@r-inla.org

Reply all
Reply to author
Forward
0 new messages