Sampling blocks

A HOBBS block is a local posterior target for one scalar coordinate. It does not have to evaluate the complete log posterior.

Suppose a proposal changes only coordinate \(\theta_j\) and the posterior can be written as

\[ \pi(\theta) \propto A_j(\theta_j,\theta_{-j}) B_j(\theta_{-j}). \]

The factor \(B_j\) is unchanged by the proposal, so it cancels from the Metropolis ratio. The block only needs to evaluate \(A_j\).

block beta(j) {
  beta(j) ~ dnorm(0, 10);
  llk();
}

The correctness rule

The update rule for each block is to evaluate the prior contribution for the parameter being updated and then evaluate all direct children of that parameter.

This makes each block an explicit dependency contract. Omitting a changing term changes the target and is incorrect; including an unchanged term is generally correct but wastes computation.

Locality in grouped models

For a random effect belonging to group j, only that group’s observations need to be revisited:

block u(j, l) {
  build_sig();
  u(j, 1:2) ~ dmvn(zero2, Sigma_u);

  for (i = gstart(j):gend(j)) {
    y(i) ~ dnorm(mu(i), sigma);
  }
}

Although u(j,l) changes one scalar coordinate, the bivariate prior is reevaluated because the two random-effect components are coupled. The observation likelihood is restricted to the rows whose values can actually change.

Different parameters can therefore have very different block scopes: fixed effects may touch all observations, group effects may touch one group, covariance parameters may touch every random-effect vector but no observation likelihood, and a residual scale may touch every observation but no predictor cache.