model {
  for (i in 1:N) {
    for (j in 1:M) {

      # Survival times
      censored[i,j] ~ dinterval(t[i,j], t.cen[i,j]);
      t[i,j] ~ dweib(r,mu[i,j]);

      log(mu[i,j]) <- alpha + beta.age*age[i,j] 
                  + beta.sex*sex[i]  
                  + beta.disease[disease[i]] + b[i];
      }
      # Random effects:
      b[i] ~ dnorm(0.0, tau)   
  }

  # Priors:
  alpha ~ dnorm(0.0, 0.0001);
  beta.age ~ dnorm(0.0, 0.0001);
  beta.sex ~ dnorm(0.0, 0.0001);
  beta.disease[1] <- 0;  # corner-point constraint
  for(k in 2:4) {
    beta.disease[k] ~ dnorm(0.0, 0.0001);
  }
  tau ~ dgamma(1.0E-3, 1.0E-3);
  r ~ dgamma(1.0, 1.0E-3); 
  sigma <- 1/sqrt(tau); # s.d. of random effects
}
