weights argument

22 views
Skip to first unread message

Sylvan Benaksas

unread,
May 29, 2025, 8:03:25 AM5/29/25
to R-inla discussion group
Hi INLA team,

I am trying to correct for class imbalance in my binomial model, is it appropriate to use the weights argument in the Inla call as follows?:

> table(dat$gw_influence_08) AC GW 160 82

weights=ifelse(dat$gw_influence_08=="AC",1,2)

inla(..weights=weights..)

Many thanks any advice would be appreciated,
Sylvan

Helpdesk (Haavard Rue)

unread,
May 30, 2025, 8:36:38 AM5/30/25
to Sylvan Benaksas, R-inla discussion group
the weights argument will scale the log-likelihood, and this might or might be
what you want.

with weights, the log-likelihood is

\sum_i w_i loglik_i()

where default, w_i=1 for all i

for the Gaussian case, then weights as the same effect as 'scale'


> r=inla(y~1,data=data.frame(y=c(1,2)), family="stdnormal", scale=c(2,3))
> rr=inla(y~1,data=data.frame(y=c(1,2)), family="stdnormal", weights=c(2,3))
> r$summary.fixed
mean sd 0.025quant 0.5quant 0.975quant mode kld
(Intercept) 1.6 0.4472135955 0.7234774594 1.6 2.476522541 1.6 0
> rr$summary.fixed
mean sd 0.025quant 0.5quant 0.975quant mode kld
(Intercept) 1.6 0.4472135955 0.7234774594 1.6 2.476522541 1.6 0


and together

> rrr=inla(y~1,data=data.frame(y=c(1,2)), family="stdnormal",
weights=sqrt(c(2,3)), scale=sqrt(c(2,3)))
> rrr$summary.fixed
mean sd 0.025quant 0.5quant 0.975quant mode kld
(Intercept) 1.6 0.4472135955 0.7234774594 1.6 2.476522541 1.6 0


its all the same
> --
> 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/b3ce47c4-247e-4cf9-a56b-52062590b8cdn%40googlegroups.com
> .

--
Håvard Rue
he...@r-inla.org
Reply all
Reply to author
Forward
0 new messages