gmrfs · latent models

fbym2

A non-stationary spatial model with noise: a spatial part whose smoothness differs between sub-regions, plus noise of each area.

Idea

The effect of each area is a spatial part, shared with its neighbours, plus noise of its own. The spatial part is an fbesag field, so its smoothness differs between sub-regions. With the same smoothness everywhere it is the BYM2 model (Riebler et al., 2016), with the same priors, so comparing the two tests whether the map is non-stationary. When the sub-regions do not differ, the estimates are almost the same as BYM2's (see the check).

Model

$$\mathbf v = \frac{1}{\sqrt\tau}\Big(\sqrt{1-\phi}\;\mathbf w + \sqrt{\phi}\;\mathbf u\Big), \qquad \mathbf w \sim \mathcal N(\mathbf 0, I),$$
$$\pi(\mathbf u \mid \mathbf d) \propto \exp\Big(-\frac{1}{2} \sum_{i \sim j} \frac{e^{d_{k(i)}} + e^{d_{k(j)}}}{2}\, (u_i - u_j)^2\Big), \qquad \sum_k d_k = 0 .$$
parametermeaning
$\tau$precision of $v_i$
$\phi$spatial share of the variance
$d_k$log precision of the spatial part in sub-region $k$, relative to the map: $d_k > 0$ smoother, $d_k < 0$ rougher

As in INLA's bym2, the latent vector is $(\mathbf v, \mathbf u)$, of length $2n$:

$$Q = \begin{pmatrix} \dfrac{\tau}{1-\phi} I & -\dfrac{\sqrt{\phi\tau}}{1-\phi} I \\[1.5ex] -\dfrac{\sqrt{\phi\tau}}{1-\phi} I & \dfrac{\phi}{1-\phi} I + Q_{\text{fb}}(\mathbf d) \end{pmatrix}.$$

Priors

$\boldsymbol\theta = (\log\tau,\ \text{logit}\,\phi,\ d_1, \dots, d_{P-1})$, reported as Theta1, Theta2, …; $d_P = -(d_1 + \dots + d_{P-1})$.

parameterpriordefaultmeaning
$\tau$PCprec = c(1, 0.01)$P(1/\sqrt\tau > 1) = 0.01$
$\phi$PC of BYM2phi = c(0.5, 0.5)$P(\phi < 0.5) = 0.5$
$\mathbf d$$\mathcal N\big(\mathbf 0, \sigma_\gamma^2 (I - \tfrac1P J)\big)$sd_gamma = 0.2as in fbesag; $\sigma_\gamma \to 0$ gives bym2

Example: rough and smooth regions

Simulated on the 558 microregions of Brazil (brazil_558_microregions.RData), 5 expected cases each.

Map of Brazil: North and Northeast rough, Southeast and South smooth, Centre-West in between
The true $d_k$.
library(INLA)
library(gmrfs)

load("brazil_558_microregions.RData")      # graph, map_df
region <- map_df$region_code               # 1 North, 2 Northeast, 3 Southeast, 4 South, 5 Centre-West
m_regions <- fbym2(graph, id = region, sd_gamma = 1)

# theta = (log tau, logit phi, d_1, ..., d_4); d_5 = 0
set.seed(1)
v <- gmrf_sample(m_regions, theta = c(1, qlogis(0.8), -2, -2, 2, 2))[1:558]
E <- rep(5, 558)
d <- list(y = rpois(558, E * exp(v)), E = E, idx = 1:558)

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

round(fit_regions$summary.hyperpar[, c("mean", "0.025quant", "0.975quant")], 2)
fit_regions$mlik[2] - fit_bym2$mlik[2]     # log Bayes factor for the regions
                mean 0.025quant 0.975quant
Theta1 for idx  0.87       0.52       1.22
Theta2 for idx  1.70       0.64       2.75
Theta3 for idx -1.68      -2.29      -1.07
Theta4 for idx -1.81      -2.29      -1.33
Theta5 for idx  1.52       0.66       2.39
Theta6 for idx  1.64       0.56       2.72
[1] 56.71699

Regional deviations

set.seed(1)
th <- inla.hyperpar.sample(4000, fit_regions, intern = TRUE)   # log tau, logit phi, d_1, ..., d_4
dk <- cbind(th[, 3:6], -rowSums(th[, 3:6]))                     # d_5 = -(d_1 + ... + d_4)
colnames(dk) <- c("North", "Northeast", "Southeast", "South", "Centre-West")
q <- apply(dk, 2, quantile, c(0.025, 0.5, 0.975))
round(q, 2)

library(ggplot2)
qd <- data.frame(region = colnames(q), lo = q[1, ], mid = q[2, ], hi = q[3, ])
ggplot(qd, aes(y = region, x = mid, xmin = lo, xmax = hi)) + geom_pointrange() + geom_vline(xintercept = 0)
      North Northeast Southeast South Centre-West
2.5%  -2.28     -2.28      0.68  0.54       -0.46
50%   -1.69     -1.81      1.52  1.64        0.33
97.5% -1.09     -1.33      2.39  2.72        1.12
Posterior medians and 95 percent intervals of d_k for each region, with the true values
$d_k$, median and 95% interval, and the truth.

Estimates

# error of the posterior mean of v, by region
rmse <- function(fit) sqrt(tapply((fit$summary.random$idx$mean[1:558] - v)^2, region, mean))
round(rbind(bym2 = rmse(fit_bym2), fbym2 = rmse(fit_regions)), 2)

map_df$truth <- v
map_df$bym2  <- fit_bym2$summary.random$idx$mean[1:558]
map_df$fbym2 <- fit_regions$summary.random$idx$mean[1:558]
ggplot(map_df) + geom_sf(aes(fill = fbym2), colour = NA) + scale_fill_gradient2()
         1    2    3    4    5
bym2  0.72 0.59 0.34 0.35 0.36
fbym2 0.66 0.50 0.25 0.28 0.33
Maps of the true v and the posterior means from bym2 and fbym2
Posterior mean of $v_i$.

The two estimates differ by 0.11 to 0.16 on average, too little to see on this colour scale. With one spatial precision, bym2 smooths the North more than fbym2 and the Southeast and South less; its error is higher in every region.

Repeated: 20 data sets

20 simulated data sets for each truth: the example above, and no difference between the regions.

RMSE of the posterior mean of v by region for bym2 and fbym2, averaged over 20 simulated data sets
Error of the posterior mean of $v_i$, by region.
truthmodelNorthNortheastSoutheastSouthCentre-West
regions differRMSEbym20.5270.4950.3280.3450.331
fbym20.4850.4420.2500.2580.303
coveragebym20.8860.8890.9770.9730.968
fbym20.9280.9460.9590.9530.937
no difference, all $d_k = 0$RMSEbym20.3160.3200.3200.3010.302
fbym20.3180.3210.3210.3030.306
coveragebym20.9490.9450.9450.9410.957
fbym20.9430.9490.9420.9430.945

When the regions differ, fbym2 has the lower error in 16 to 20 of the 20 data sets in every region, and the log BF favours it in all 20 (38 to 74). When they do not, the two are almost the same (error at most 0.004 higher), and the log BF has median $-2.3$ and is at most 1.4.

Testing for non-stationarity

$$\log \text{BF} = \log \pi(\mathbf y \mid \text{fbym2}) - \log \pi(\mathbf y \mid \text{bym2})$$

If you change the priors of fbym2, give bym2 the same hyper.

Beyond $\text{logit}\,\phi = 12$, INLA's bym2 prior is flat (improper) and fbym2's is the exact PC tail. If the posterior of $\phi$ reaches 1, compare with fbym2 with id = rep(1, n) instead of bym2.

Use in MCMC

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

Example: demo("fbym2_mcmc", package = "gmrfs").

References