Random Effect with Three-Way Interaction

208 views
Skip to first unread message

Amal Abdi

unread,
Jul 9, 2021, 8:52:37 PM7/9/21
to R-inla discussion group
Hello!

I am new to INLA and Bayesian statistics. I'm trying to build up a model. Please let me know if I should provide more information or be more specific!

Right now, I'm trying to fit a model with only age, sex, and year random effects. Then I will add covariates. In the data, there are 2 sexes, 14 age bins and 21 years. There are 51 observations for each age-sex-year combinations (50 US states + DC). To make it faster to experiment with, I took a sample of the data so it has about 3500 observations. I want age groups to be correlated.

form <- y ~ f(as.integer(year), model = "ar1", replicate = as.factor(sex), group = as.integer(age), control.group = list(model = "rw1"))
mod_obj <- inla(formula = form, family = "gaussian", data = dt_sample, control.predictor = list(compute = FALSE, link = 1), control.inla = list(int.strategy = "eb"), control.compute = list(config = FALSE, waic = TRUE), verbose = TRUE)

In the output of the model bove, I get a lot of messages like:
file: smtp-taucs.c  1f6a39183ef43d8ef33f10ff3f04fd13f8432758 - Mon Feb 22 21:27:50 2021 +0300
Function: GMRFLib_factorise_sparse_matrix_TAUCS(), Line: 872, Thread: 0
Fail to factorize Q. I will try to fix it...
It seems I'm poorly specifying the model. Is there some way I could combine age, sex and year or should I break them up?

Thanks so much,
Amal

Helpdesk

unread,
Jul 10, 2021, 8:21:28 AM7/10/21
to Amal Abdi, R-inla discussion group

make sure as.integer(age), give values 1,2,3...., otherwise, just
subtract to get there.

add control.fixed=list(prec=1,prec.intercept=1)

let me know if that does not work
> --
> 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/aaec75b0-2690-44f3-ab36-b68c2bbdf285n%40googlegroups.com
> .

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

Amal Abdi

unread,
Jul 12, 2021, 1:04:58 PM7/12/21
to R-inla discussion group
Thank you so much for your help,  Håvard! That seemed to solve the issue.
Reply all
Reply to author
Forward
0 new messages