Case: housing prices in Boston

We will model the logarithm of the median prices using as covariates the per capita crime (CRIM) and the average number of rooms per dwelling (RM)

For spatial areas, we need an index vector to identify each area for the BYM2 latent model.

map$re_u <- 1:nrow(map)
map$re_v <- 1:nrow(map)

BYM2 also needs a spatial neighbourhood list formatted for INLA

nb <- poly2nb(map)
adjmat_path <- file.path(tempdir(), "map.adj")
nb2INLA(adjmat_path, nb)
g <- inla.read.graph(filename = adjmat_path)
formula <- vble ~ CRIM + RM + f(re_u, model = "bym2", graph = g)