Orange Trees: Non-linear growth curve

This example uses the orange tree growth data of Draper and Smith (1981), later reanalysed by Lindstrom and Bates (1990). The trunk circumference of each of $K = 5$ trees was recorded on the same $n = 7$ occasions, at $x_j = 118, 484, 664, 1004, 1231, 1372$ and $1582$ days, giving a 5-by-7 matrix $Y$ of measurements that grow from around 30 at the first occasion to between 140 and 214 at the last. The trees follow visibly similar S-shaped trajectories but differ in how large they get and how quickly they get there, so the question is how to estimate a common growth pattern while letting each tree have its own curve.

The model is a logistic growth curve fitted as a nonlinear random-effects model. Tree $i$ has three parameters $\phi_{i1}, \phi_{i2}, \phi_{i3}$: an asymptotic circumference, a term setting the size at time zero, and a negative rate constant.

\[\begin{aligned} Y_{ij} &\sim \text{Normal}(\eta_{ij}, \tau_C) \\ \eta_{ij} &= \frac{\phi_{i1}}{1 + \phi_{i2} \exp(\phi_{i3} x_j)} \end{aligned}\]

Each $\phi$ is a fixed transformation of an unconstrained parameter $\theta$, namely $\phi_{i1} = \exp(\theta_{i1})$, $\phi_{i2} = \exp(\theta_{i2}) - 1$ and $\phi_{i3} = -\exp(\theta_{i3})$. The transformations do the work of the constraints: whatever value $\theta$ takes, the asymptote stays positive and the rate constant stays negative, so the curve is always increasing towards a finite limit. The random effects are placed on the unconstrained scale, with $\theta_{ik} \sim \text{Normal}(\mu_k, \tau_k)$ independently for $k = 1, 2, 3$, and the population parameters $\mu_k$, $\tau_k$ and the residual precision $\tau_C$ are given vague priors. As elsewhere in BUGS, the second argument of a normal is a precision rather than a variance, and the reported sigma quantities are the corresponding standard deviations.

The example appears in Volume 2 of the classic BUGS examples; see also the OpenBUGS version of this example and the multivariate variant, which replaces the three independent normal priors with a single multivariate normal.

The model definition, data, initial values, and published reference results shown here all come from JuliaBUGS.BUGSExamples.VOLUME_2.orange_trees, which ships with the package.

Model

using JuliaBUGS

example = JuliaBUGS.BUGSExamples.VOLUME_2.orange_trees
example.model_def
quote
    for i = 1:K
        for j = 1:n
            Y[i, j] ~ dnorm(eta[i, j], tauC)
            eta[i, j] = phi[i, 1] / (1 + phi[i, 2] * exp(phi[i, 3] * x[j]))
        end
        phi[i, 1] = exp(theta[i, 1])
        phi[i, 2] = exp(theta[i, 2]) - 1
        phi[i, 3] = -(exp(theta[i, 3]))
        for k = 1:3
            theta[i, k] ~ dnorm(mu[k], tau[k])
        end
    end
    tauC ~ dgamma(0.001, 0.001)
    var"sigma.C" = 1 / sqrt(tauC)
    for k = 1:3
        mu[k] ~ dnorm(0, 0.0001)
        tau[k] ~ dgamma(0.001, 0.001)
        sigma[k] = 1 / sqrt(tau[k])
    end
end

The program as it appears in the original BUGS distribution:

print(example.original_syntax_program)
model {
    for (i in 1:K) {
        for (j in 1:n) {
            Y[i, j] ~ dnorm(eta[i, j], tauC)
            eta[i, j] <- phi[i, 1] / (1 + phi[i, 2] * exp(phi[i, 3] * x[j]))
        }
        phi[i, 1] <- exp(theta[i, 1])
        phi[i, 2] <- exp(theta[i, 2]) - 1
        phi[i, 3] <- -exp(theta[i, 3])
        for (k in 1:3) {
            theta[i, k] ~ dnorm(mu[k], tau[k])
        }
    }
    tauC ~ dgamma(1.0E-3, 1.0E-3)
    sigma.C <- 1 / sqrt(tauC)
    for (k in 1:3) {
        mu[k] ~ dnorm(0, 1.0E-4)
        tau[k] ~ dgamma(1.0E-3, 1.0E-3)
        sigma[k] <- 1 / sqrt(tau[k])
    }
}

Data

example.data
(n = 7, K = 5, x = [118.0, 484.0, 664.0, 1004.0, 1231.0, 1372.0, 1582.0], Y = [30.0 58.0 … 142.0 145.0; 33.0 69.0 … 203.0 203.0; … ; 32.0 62.0 … 209.0 214.0; 30.0 49.0 … 174.0 177.0])

Compiling the model

model = JuliaBUGS.compile(example.model_def, example.data, example.inits)
BUGSModel (parameters are in transformed (unconstrained) space, with dimension 22):

  Model parameters:
    mu[3], mu[2], mu[1]
    tauC
    theta[5, 3], theta[5, 2], theta[5, 1], theta[4, 3], theta[4, 2], theta[4, 1], theta[3, 3], theta[3, 2], theta[3, 1], theta[2, 3], theta[2, 2], theta[2, 1], theta[1, 3], theta[1, 2], theta[1, 1]
    tau[3], tau[2], tau[1]

  Variable sizes and types:
    n: type = Int64
    eta: size = (5, 7), type = Matrix{Float64}
    K: type = Int64
    phi: size = (5, 3), type = Matrix{Float64}
    sigma: size = (3,), type = Vector{Float64}
    sigma.C: type = Float64
    x: size = (7,), type = Vector{Float64}
    mu: size = (3,), type = Vector{Float64}
    Y: size = (5, 7), type = Matrix{Float64}
    tau: size = (3,), type = Vector{Float64}
    tauC: type = Int64
    theta: size = (5, 3), 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
(var"mu[1]" = (mean = 5.257, std = 0.1252), var"mu[2]" = (mean = 2.198, std = 0.1171), var"mu[3]" = (mean = -5.874, std = 0.09403), var"sigma[1]" = (mean = 0.2369, std = 0.1258), var"sigma[2]" = (mean = 0.2636, std = 0.1282), var"sigma[3]" = (mean = 0.2302, std = 0.1073), var"sigma.C" = (mean = 7.972, std = 1.188))