Posterior sample interaction terms

16 views
Skip to first unread message

ChooChoo JC

unread,
Nov 23, 2022, 10:56:58 AM11/23/22
to R-inla discussion group
Hi,

For the inla.posterior.sample() function, there is an argument that passes the desired parameters.(selection = list()). I can use it with the main effect with no problem by using the defined variable names. But I am wondering if it is possible to use this argument for the interaction terms. And if so, what should I pass in the argument specification.

Thank you so much in advance. Have a good one.


Best,
Jocelyn

Helpdesk (Haavard Rue)

unread,
Nov 24, 2022, 4:13:13 AM11/24/22
to ChooChoo JC, R-inla discussion group

I do not think the 'selection' argument in posterior.sample was that
great of an idea as it onle save storage not computational cost, and it
just lead to confusion, so...

I rather prefer to just use inla.posterior.sample.eval to exact terms
you like. there is a vignette about this function, please check (need
new testing version).

there is an example


n <- 100
x <- rnorm(n)
xx <- rnorm(n)
y <- rnorm(n)

r <- inla(y ~ 1 + x*xx,
data = data.frame(y, x, xx),
control.compute = list(config = TRUE))

fun <- function() {
return (c(x, xx, get("x:xx")))
}

xx <- inla.posterior.sample(1000, r)
coeffs <- inla.posterior.sample.eval(fun, xx)
> --
> 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 on the web, visit
> https://groups.google.com/d/msgid/r-inla-discussion-group/caab3dc3-1fef-492c-8aaf-60eb211b4f5en%40googlegroups.com
> .

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