Jaws: repeated measures analysis of variance
Elston and Grizzle (1962) tracked the ramus bone, part of the jaw, in 20 boys, recording its height four times at six-monthly intervals. The readings fall at $\text{age}_j = 8, 8.5, 9, 9.5$ years, so the data matrix Y is 20 by 4. What is wanted from them is the growth curve of the bone in the population, not a curve for any individual boy.
The four readings on a boy are repeated measurements of the same bone and are clearly not independent, so they are modelled jointly: each row of Y is drawn from a multivariate normal with a common mean vector $\mu$ and a common 4-by-4 precision matrix Omega, left entirely unstructured so that the correlations between occasions are estimated from the data rather than assumed. The mean follows a linear growth curve in age, $\mu_j = \beta_0 + \beta_1 \text{age}_j$. The original write-up fits a constant, a linear, and a quadratic curve in turn; the linear one is what is coded here.
\[\begin{aligned} Y_i &\sim \text{MVNormal}(\mu,\ \Omega), \qquad i = 1, \ldots, 20 \\ \mu_j &= \beta_0 + \beta_1\, \text{age}_j \\ \Omega &\sim \text{Wishart}(R,\ 4) \end{aligned}\]
As with the univariate normal, BUGS parameterises the multivariate normal by its precision matrix $\Omega$ rather than its covariance; the model records the covariance separately as Sigma, the inverse of $\Omega$. The Wishart prior is made as vague as it can be by taking the degrees of freedom to be 4, the rank of the matrix, and by setting the scale matrix R to the 4-by-4 identity, which states only the rough scale on which the four measurements are expected to covary. The regression coefficients $\beta_0$ and $\beta_1$ get independent normal priors with precision 0.001. This is one of the examples in Volume 2 of the classic BUGS examples; see also the OpenBUGS version of this example.
The model definition, data, initial values, and published reference results shown here all come from JuliaBUGS.BUGSExamples.VOLUME_2.jaws, which ships with the package.
Model
using JuliaBUGS
example = JuliaBUGS.BUGSExamples.VOLUME_2.jaws
example.model_defquote
beta0 ~ dnorm(0.0, 0.001)
beta1 ~ dnorm(0.0, 0.001)
for i = 1:N
Y[i, 1:M] ~ dmnorm(mu[:], Omega[:, :])
end
for j = 1:M
mu[j] = beta0 + beta1 * age[j]
end
Omega[1:M, 1:M] ~ dwish(R[:, :], 4)
Sigma[1:M, 1:M] = inverse(Omega[:, :])
endThe program as it appears in the original BUGS distribution:
print(example.original_syntax_program)model
{
beta0 ~ dnorm(0.0, 0.001)
beta1 ~ dnorm(0.0, 0.001)
for (i in 1:N) {
Y[i, 1:M] ~ dmnorm(mu[], Omega[ , ])
}
for(j in 1:M) {
mu[j] <- beta0 + beta1* age[j]
}
Omega[1 : M , 1 : M] ~ dwish(R[ , ], 4)
Sigma[1 : M , 1 : M] <- inverse(Omega[ , ])
}Data
example.data(M = 4, N = 20, Y = [47.8 48.8 49.0 49.7; 46.4 47.3 47.7 48.4; … ; 46.2 47.5 48.1 48.4; 46.3 47.6 51.3 51.8], age = [8.0, 8.5, 9.0, 9.5], R = [1 0 0 0; 0 1 0 0; 0 0 1 0; 0 0 0 1])Compiling the model
model = JuliaBUGS.compile(example.model_def, example.data, example.inits)BUGSModel (parameters are in transformed (unconstrained) space, with dimension 12):
Model parameters:
beta0
Omega[1:4, 1:4]
beta1
Variable sizes and types:
N: type = Int64
M: type = Int64
R: size = (4, 4), type = Matrix{Int64}
age: size = (4,), type = Vector{Float64}
beta0: type = Int64
mu: size = (4,), type = Vector{Float64}
Y: size = (20, 4), type = Matrix{Float64}
Omega: size = (4, 4), type = Matrix{Float64}
beta1: type = Int64
Sigma: size = (4, 4), type = Matrix{Float64}
The example's own initial values are passed in here. Several of these models fail from random starting values, so example.inits is not optional in practice; a second set is available as example.inits_alternative.
See Getting Started for the recipe that takes a compiled model to posterior samples.
Reference results
The posterior summaries published with the original example. A converged chain should reproduce these up to Monte Carlo error.
example.reference_results(beta0 = (mean = 33.52, std = 33.57), beta1 = (mean = 1.889, std = 1.882), var"mu[1]" = (mean = 48.63, std = 48.64), var"mu[2]" = (mean = 49.58, std = 49.58), var"mu[3]" = (mean = 50.52, std = 50.52), var"mu[4]" = (mean = 51.48, std = 51.48))