Model anatomy
A minimal HOBBS model is a string containing parameter declarations and one sampling block for each parameter that is updated.
model <- '
param beta(p);
param logsigma(1);
func llk() {
double sigma = exp(logsigma(1));
for (i = 1:n) {
y(i) ~ dnorm(mu(i), sigma);
}
}
block beta(j) {
beta(j) ~ dnorm(0, 10);
llk();
} cache mu(n) {
for (i = 1:n) {
for (k = 1:p) {
mu(i) += beta(k) * x(i,k);
}
}
} update mu(n) {
for (i = 1:n) {
mu(i) += (proposal(beta(j)) - current(beta(j))) * x(i,j);
}
}
block logsigma(1) {
logsigma(1) ~ dnorm(0, 2);
llk();
}
'What each piece means
param beta(p); allocates p continuous coordinates. block beta(j) creates a scalar transition for each coordinate. The block target contains the coefficient prior and the likelihood terms that change when that coefficient changes.
The cache mu(n) initializer constructs the predictor once. The attached update mu(n) changes it by the exact rank-one difference for a proposed coefficient. proposal(beta(j)) is the staged value; current(beta(j)) is the accepted value before the proposal.
logsigma(1) receives a separate block because it changes the observation density but does not change the cached predictor.
This separation of statistical state, local target, and deterministic update is the central design pattern used throughout the paper.