# Random effects model
for (i in studies) {
	# Study-level relative effects
	w[i, 1] <- 0
	delta[i, 1] <- 0
	for (k in 2:na[i]) { # parameterize multi-arm trials using a trick to avoid dmnorm
		delta[i, k] ~ dnorm(md[i, k], taud[i, k])
		md[i, k] <- d[t[i, 1], t[i, k]] + sw[i, k]
		taud[i, k] <- tau.d * 2 * (k - 1) / k
		w[i, k] <- delta[i, k] - (d[t[i, 1], t[i, k]])
		sw[i, k] <- sum(w[i, 1:(k-1)]) / (k - 1)
	}
}

# Random effects variance prior
$hy.prior$
