[R-sig-Geo] BYM model in R-INLA - how to specify priors individually
James Rooney
ROONEYJ4 at tcd.ie
Tue May 6 09:08:26 CEST 2014
Dear Virgilio,
Many thanks - yes that is helpful!
However in my own dataset I am finding those values lead to an oversmoothed model - i.e. the output is very uniform - practically flat across all areas. But I know from BUGS smoothing and also from cluster analysis that there should be areas of variation.
What is if that controls the "degree of smoothing" for want of a better term!
Many thanks,
James
________________________________________
From: VIRGILIO GOMEZ RUBIO [Virgilio.Gomez at uclm.es]
Sent: 05 May 2014 23:40
To: James Rooney
Cc: r-sig-geo at r-project.org
Subject: Re: [R-sig-Geo] BYM model in R-INLA - how to specify priors individually
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