Besag model for spatial effects
Parametrization
The besag model for random vector x = (x1 , . . . , xn ) is defined asxi |xj , i ̸= j, τ ∼ N (1 X1xj ,)ni i∼jni τ(1)where ni is the number of neighbours of node i, i ∼ j indicates that the two nodes i and j areneighbours.

Hyperparameters
The precision parameter τ is represented as
θ1 = log τand the prior is defined on θ1 .

Specification
The besag model is specified inside the f() function asf(<whatever>,model="besag",graph=<graph>,hyper=<hyper>, adjust.for.con.comp = TRUE,scale.model = FALSE)
The neighbourhood structure of x is passed to the program through the graph argument.
If the option adjust.for.con.comp=TRUE then the model is adjusted if the graph has morethan one connected compoment. This adjustment can be disabled setting this option to FALSE. If
adjust.for.con.comp=TRUE then constr=TRUE is interpreted as a sum-to-zero constraint on eachconnected component in the graph and the rankdef parameter is set to the number of connectedcomponents.
The logical option scale.model determine if the model should be scaled to have an averagevariance (the diagonal of the generalized inverse) equal to 1. This makes prior spesification mucheasier. Default is FALSE so that the model is not scaled.
Hyperparameter spesification and default values
doc The Besag area model (CAR-model)
hyper
theta
hyperid 8001
name log precision
short.name prec
prior loggamma
param 1 5e-05
initial 4
fixed FALSE
to.theta function(x) log(x)from.theta function(x) exp(x)1constr TRUE
nrow.ncol FALSE
augmented FALSE
aug.factor 1
aug.constr
n.div.byn.required TRUE
set.default.values TRUE
pdf besag

ExampleFor examples of application of this model see the Bym, Munich, Zambia or Scotland examples inVolume I.

Details on the implementation
This gives some details of the implementation, which depends on the following variables
nc1 Number of connected components in the graph with size 1. These nodes, singletons, have noneighbours.
nc2 Number of connected components in the graph with size ≥ 2.
scale.model The value of the logical flag, if the model should be scaled or not. (Default FALSE)
adjust.for.con.comp The value of the logical flag if the constr=TRUE option should be reinterpreted.
The case (scale.model==FALSE && adjust.for.con.comp == FALSE)
The option constr=TRUE is interpreted as a sum-to-zero constraint over the whole graph. Singletons
are given a uniform distribution on (−∞, ∞) before the constraint.
The case (scale.model==TRUE && adjust.for.con.comp == FALSE)
The option constr=TRUE is interpreted as a sum-to-zero constraint over the whole graph. Let Q = τ R
be the standard precision matrix from the besag-model with precision parameter τ . Then R, except
the singletons, are scaled so that the geometric mean of the marginal variances is 1, and R is modified
so that singletons have a standard Normal distribution.
The case (scale.model==FALSE && adjust.for.con.comp == TRUE)
The option constr=TRUE is interpreted as one sum-to-zero constraint over each of the nc2 connectedcomponents of size ≥ 2. Singletons are given a uniform distribution on (−∞, ∞).

2

The case (scale.model==TRUE && adjust.for.con.comp == TRUE)
The option constr=TRUE is interpreted as nc2 sum-to-zero constraints for each of the connectedcomponents of size ≥ 2. Let Q = τ R be the standard precision matrix from the besag-model with
precision parameter τ . Then R, are scaled so that the geometric mean of the marginal variances ineach connected component of size ≥ 2 is 1, and modified so that singletons have a standard Normal
distribution.

Notes
The term 21 log(|R|∗ ) of the normalisation constant is not computed, hence you need to add this partto the log marginal likelihood estimate, if you need it. Here R is the precision matrix with a unit
precision parameter.

3