gmrfs · latent models

fbesag

A non-stationary spatial model: neighbours can be more alike in one part of the map than in another.

Idea

Each area is pulled towards its neighbours. How strongly is set by a precision $\tau_k$ that differs between sub-regions: high where the map is smooth, low where it is rough. With one sub-region the precision is the same everywhere (the Besag model), so comparing the two tests whether the map is non-stationary. When the sub-regions do not differ, the estimates are the same as with one precision (see the check).

Sub-regions are chosen before seeing the data. They need not be contiguous, and the graph can be a time line.

Model

$$\pi(\mathbf x \mid \tau_1, \dots, \tau_P) \propto \exp\Big(-\frac{1}{2} \sum_{i \sim j} w_{ij}\, (x_i - x_j)^2\Big), \qquad w_{ij} = \frac{\tau_{k(i)} + \tau_{k(j)}}{2},$$
$$x_i \mid \mathbf x_{-i} \sim \mathcal N\Big(\frac{\sum_{j \sim i} w_{ij}\, x_j}{\sum_{j \sim i} w_{ij}},\ \frac{1}{\sum_{j \sim i} w_{ij}}\Big),$$

where $k(i)$ is the sub-region of area $i$. The structure is scaled so that, with all $\tau_k = 1$, the geometric mean of the marginal variances is 1 (Sørbye and Rue, 2014), with a sum-to-zero constraint per connected part of two or more areas. INLA reports $\theta_k = \log\tau_k$ as Theta1, …, ThetaP.

Prior

$$\theta_k = \bar\theta + \gamma_k, \qquad \pi(\boldsymbol\theta) \propto \exp\Big(-\lambda e^{-\bar\theta/2} - \frac{\bar\theta}{2}\Big)\, \exp\Big(-\frac{1}{2\sigma_\gamma^2} \sum_k \gamma_k^2\Big), \qquad \sum_k \gamma_k = 0 .$$

A PC prior (Simpson et al., 2017) on the common level $\bar\theta$, and a normal prior on the deviations $\gamma_k$. As $\sigma_\gamma \to 0$, all $\tau_k$ become equal.

argumentdefaultmeaning
paramlist(p1 = 1, p2 = 1e-5)$P(\text{common sd} > 1) = 10^{-5}$
sd_gamma0.2with five sub-regions, each $\tau_k$ within a factor of about 1.4 of the common level (two sd); with 1, about 6

Example: dengue in Brazil

Dengue cases in April in the 558 microregions of Brazil (Lowe et al., 2021), with the five regions as sub-regions. Data: brazil_558_microregions.RData.

Map of the 558 microregions of Brazil coloured by region
The five regions.
Map of the ratio of observed to expected dengue cases in April
Observed / expected, April.
library(INLA)
library(gmrfs)

load("brazil_558_microregions.RData")      # data, graph, map_df
april  <- subset(data, T1 == 4)
d      <- list(y = april$Y, E = april$E, idx = 1:558)
region <- map_df$region_code               # 1 North, 2 Northeast, 3 Southeast, 4 South, 5 Centre-West

m_besag   <- fbesag(graph, id = rep(1, 558))   # one precision: besag
m_regions <- fbesag(graph, id = region)        # one precision per region

fit_besag   <- inla(y ~ 1 + f(idx, model = m_besag),   family = "poisson", E = E, data = d)
fit_regions <- inla(y ~ 1 + f(idx, model = m_regions), family = "poisson", E = E, data = d)

round(fit_regions$summary.hyperpar[, c("mean", "0.025quant", "0.975quant")], 2)
fit_regions$mlik[2] - fit_besag$mlik[2]        # log Bayes factor for the regions
                mean 0.025quant 0.975quant
Theta1 for idx -1.06      -1.38      -0.75
Theta2 for idx -1.08      -1.28      -0.88
Theta3 for idx -1.66      -1.87      -1.46
Theta4 for idx -1.12      -1.47      -0.77
Theta5 for idx -1.02      -1.35      -0.70
[1] 10.60896
Posterior means and 95 percent intervals of the log precision of each region in April, with the single besag value
$\theta_k$ with 95% intervals. Grey: besag.

The Southeast is rougher than the other regions.

Precision of each area

$$\tau_i = \frac{n_i\, \tau_{k(i)} + \sum_{j \sim i} \tau_{k(j)}}{2\, n_i}$$
tau <- exp(fit_regions$summary.hyperpar$mean)[region]   # tau of each area's region
W   <- -graph; diag(W) <- 0                              # the neighbours
map_df$log_tau <- log((diag(graph) * tau + drop(W %*% tau)) / (2 * diag(graph)))

library(ggplot2)
ggplot(map_df) + geom_sf(aes(fill = log_tau), colour = NA)
Map of the log precision of each microregion in April
$\log\tau_i$. It changes over a band of areas at the borders of the Southeast.

Maps

x_regions <- fit_regions$summary.random$idx$mean
x_besag   <- fit_besag$summary.random$idx$mean
# observed over expected, relative to the whole country
map_df$smr  <- (d$y / d$E) / (sum(d$y) / sum(d$E))
map_df$rr   <- exp(x_regions)
map_df$diff <- x_regions - x_besag

brks <- c(0, 0.2, 0.5, 1, 2, 5, Inf)
cols <- c("#2c7bb6", "#abd9e9", "#e0f3f8", "#fee090", "#fdae61", "#d7191c")
ggplot(map_df) + geom_sf(aes(fill = cut(rr, brks, right = FALSE)), colour = NA) +
  scale_fill_manual(values = cols, drop = FALSE)
ggplot(map_df) + geom_sf(aes(fill = diff), colour = NA) +
  scale_fill_gradient2(low = "#2c7bb6", high = "#d7191c")

# the largest difference in each region
region_names <- c("North", "Northeast", "Southeast", "South", "Centre-West")
round(tapply(abs(map_df$diff), region_names[region], max)[region_names], 2)
      North   Northeast   Southeast       South Centre-West
       0.22        0.18        0.31        0.29        0.13 
Map of the fbesag posterior relative risk of dengue in April
fbesag: $\exp$ of the posterior mean of $x_i$.
Map of the difference between the fbesag and besag posterior means of the spatial effect
fbesag minus besag, posterior mean of $x_i$.

Testing for non-stationarity

$$\log \text{BF} = \log \pi(\mathbf y \mid \text{fbesag, } P \text{ sub-regions}) - \log \pi(\mathbf y \mid \text{fbesag, one})$$

Compare with fbesag with one sub-region, not INLA's besag, whose default prior is different.

$\sigma_\gamma = 0.2$$\sigma_\gamma = 1$
log BF, April10.610.4

fbesag has no noise term, so a rough region can also be noise. fbym2, which has one, also finds the Southeast rougher in April ($d = -0.48$, 95% interval $-0.69$ to $-0.26$; log BF 10.0).

Simulated check

20 data sets per setting on the same map, with the expected counts of April:

x <- gmrf_sample(m_regions, theta = c(-1, -1, -1.8, -1, -1))
truth$\sigma_\gamma$log BF, median (range)log BF > 0$\theta$ Southeast, meaninterval covers truth
stationary, all $-1.3$0.2−0.9 (−1.7 to 0.6)4 of 20−1.2919 of 20
1−5.8 (−7.0 to −2.8)0 of 20−1.3119 of 20
Southeast $-1.8$, others $-1.0$0.213.1 (3.9 to 19.3)20 of 20−1.608 of 20
113.4 (0.7 to 21.1)20 of 20−1.7517 of 20

The default $\sigma_\gamma$ pulls the Southeast towards the others; $\sigma_\gamma = 1$ recovers it.

With no difference between the regions (stationary truth), the estimates and intervals of $x_i$ are the same as with one precision:

modelRMSE, SoutheastRMSE, other regionscoverage, Southeastcoverage, other regions
one precision0.1700.2040.9470.949
fbesag, $\sigma_\gamma = 0.2$0.1700.2030.9480.949
fbesag, $\sigma_\gamma = 1$0.1700.2030.9490.949

Use in MCMC

functionreturns
gmrf_Q(m_regions, theta)the precision matrix $Q(\boldsymbol\theta)$
gmrf_log_prior(m_regions, theta)the log prior of $\boldsymbol\theta$
gmrf_log_density(m_regions, x, theta)$\log \pi(\mathbf x \mid \boldsymbol\theta)$, with the sum-to-zero constraints
gmrf_sample(m_regions, theta)draws of $\mathbf x \mid \boldsymbol\theta$ on the constraints

References