[R-sig-Geo] BYM model in R-INLA - how to specify priors individually

VIRGILIO GOMEZ RUBIO Virgilio.Gomez at uclm.es
Tue May 6 00:40:54 CEST 2014


Dear James,

You should be able to set the prior of your random effects using hyper=
in the call to f(). In your particular case, you can try:

#Create areas IDs to match the values in nc.adj
nc.sids$ID<-1:100
nc.sids$ID2<-1:100

hyper.besag <-list(prec=list(prior="loggamma", params=c(.1, .1)))
hyper.iid<-list(prec=list(prior="loggamma", params=c(.001, .001)))

#Besag model with random spatial effect (i.e. BYM model)
m2<-inla(SID74~NWPROP+
   f(nc.sids$ID, model="besag", graph="nc.adj", hyper=hyper.besag)+
   f(nc.sids$ID2, model="iid", hyper=hyper.iid),
 family="poisson", E=nc.sids$EXP, data=as.data.frame(nc.sids),
 control.predictor=list(compute=TRUE))


Note that I have defined two different indices. You can probably use
model="bym" to simplify the formula in your model. Also, run
inla.models()$latent$bym to know the default definitions of priors of
the hyperparameters.

Hope this helps.

Virgilio



More information about the R-sig-Geo mailing list