# varying-intercept, varying-slope radon model with bsmt as an individual predictor and uranium as a county predictor # modeling the correlation model { for (i in 1:n){ y[i] ~ dnorm (y.hat[i], tau.y) y.hat[i] <- a[county[i]] + b[county[i]]*x[i] } tau.y <- pow(sigma.y, -2) sigma.y ~ dunif (0, 100) for (j in 1:J){ a[j] <- B[j,1] b[j] <- B[j,2] B[j,1:2] ~ dmnorm (B.hat[j,], Tau.B[,]) B.hat[j,1] <- g.a.0 + g.a.1*u[j] B.hat[j,2] <- g.b.0 + g.b.1*u[j] } g.a.0 ~ dnorm (0, .0001) g.a.1 ~ dnorm (0, .0001) g.b.0 ~ dnorm (0, .0001) g.b.1 ~ dnorm (0, .0001) Tau.B[1:2,1:2] <- inverse(Sigma.B[,]) Sigma.B[1,1] <- pow(sigma.a, 2) sigma.a ~ dunif (0, 100) Sigma.B[2,2] <- pow(sigma.b, 2) sigma.b ~ dunif (0, 100) Sigma.B[1,2] <- rho*sigma.a*sigma.b Sigma.B[2,1] <- Sigma.B[1,2] rho ~ dunif (-1, 1) }