7.5 Modeling
Relative risk of lung cancer for each Ohio county and year is estimated with the Bernardinelli model (Bernardinelli et al. 1995).
\[Y_{ij}\sim Po(E_{ij}\theta_{ij})\] \[log(\theta_{ij})=\alpha+u_i+v_i+(\beta+\delta_i) \text{ x }t_j\]
7.5.1 Neighborhood matrix
library(INLA)
library(spdep)
%>%class map
## [1] "SpatialPolygonsDataFrame"
## attr(,"package")
## [1] "sp"
<- poly2nb(map)
nb head(nb)
## [[1]]
## [1] 26 55 71 72 80 85
##
## [[2]]
## [1] 19 35 42 70 82 86
##
## [[3]]
## [1] 5 8 16 25 30 59 69
##
## [[4]]
## [1] 14 27 28 34 49 51
##
## [[5]]
## [1] 3 16 29 30 44
##
## [[6]]
## [1] 11 12 83 84
?poly2nb
?nb2INLA ?inla.read.graph
nb2INLA("map.adj", nb)
<- inla.read.graph(filename = "map.adj") g
7.5.2 Inference using INLA
$idarea <- as.numeric(as.factor(d$county))
d$idarea1 <- d$idarea
d$idtime <- 1 + d$year - min(d$year) d
And the model:
<- Y ~ f(idarea, model = "bym", graph = g) + f(idarea1, idtime, model = "iid") + idtime formula
<- inla(formula,
res family = "poisson",
data = d,
E = E,
control.predictor = list(compute = TRUE)
)