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)
map%>%class
## [1] "SpatialPolygonsDataFrame"
## attr(,"package")
## [1] "sp"
nb <- poly2nb(map)
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)
g <- inla.read.graph(filename = "map.adj")

7.5.2 Inference using INLA

d$idarea <- as.numeric(as.factor(d$county))
d$idarea1 <- d$idarea
d$idtime <- 1 + d$year - min(d$year)

And the model:

formula <- Y ~ f(idarea, model = "bym", graph = g) + f(idarea1, idtime, model = "iid") + idtime
res <- inla(formula,
  family = "poisson", 
  data = d, 
  E = E,
  control.predictor = list(compute = TRUE)
)