I'm working on a project where I'd like to compare the performance of BYM latent models as run in three different software packages (winBUGS, CARBayes, and R-INLA) on the same data. Part of this involves trying to create as much comparability between the three models as possible -- such as trying to specify the same prior distributions for parameters in the BYM models.

So far, I've been able to do a decent job of this between winBUGS and CARBayes. However in R-INLA (which I'm new to), I'm running into a problem; I'd like to specify a gamma distribution for a prior, but the R-INLA only has a log-gamma distribution option. I see from here that's it's possible to create one's own prior distributions for use in R-INLA models, but I'm a bit unclear about how to actually do this.

Here's an example of what I have for my R-INLA code at the moment for my BYM model (I'm modeling count data with a Poisson likelihood):

###My model### 
form_INLA<-O~1+offset(log(E))+depriv+ f(London_data$idx, model = "bym", graph = adj, 
      hyper = list(prec.unstruct = list(prior = "loggamma", param = c(0.001, 0.001)), ###prior specification###
                    prec.spatial = list(prior = "loggamma", param = c(0.1, 0.1)))) ###prior specification###

###Run the model###
    INLA_BYM <- inla(form_INLA, family = "poisson", data = as.data.frame(London_data), 
                     control.compute = list(dic = TRUE), 
                     control.inla = list(tolerance = 1e-20, h = 1e-08), 
                     control.predictor = list(compute = TRUE)) 

Also, would any of you know if it's possible to set prior distributions in the R-INLA BYM model for parameters other than the random effects terms (i.e. for the intercept term and beta coefficient term)?

1 Answer 1


INLA considers for the precision parameter tau the following distribution log(tau) ~ logGamma(a,b). In this way tau follows a gamma distribution as in Winbugs, but the log trasformation ensures a correct value for the parameter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.