# Code for the one-way ANOVA of the ant nest data (Gotelli & Ellison 2004, Chapter 5).
model {for (i in 1:N) {x[i] ~ dnorm(lambda[T[i]],tau)}
#
# Enter prior estimate of among-group variance s0 into the formula for precision (tau)
# as dgamma(nu/2, nu*s0/2), where
# nu is the "strength of belief", expressed as an integer "degrees of freedom"
# variance =1/precision.
# An uninformative prior on precision would be dgamma(0.0001, 0.0001)
# hence in an uninformative prior, precision is small and variance is very large.
#
# Example: estimate prior variance as 1 with modest belief (nu = 2)
# enter tau ~ dgamma(1, 1)
tau ~ dgamma(5,5)
s2 <- 1/tau
#Alternatively, priors could be uninformative
tau ~ dgamma(0.001,0.001)
s2 <- 1/tau
# BE SURE TO COMMENT OUT THE PRIORS YOU DON'T WANT!
# Enter prior estimates for within-group means for lambda[1] and lambda[2]
# Here, lambda[i] is assumed normal; for "sharp" initial estimates of lambda, set
# lambda[i] ~ dnorm(prior estimated mean, prior estimated variance), where
# prior estimated mean is initial estimate, and prior estimated variance is small.
# Increasing the value for prior estimated within-group variance reflects a lower
# confidence in the prior estimate
lambda[1] ~ dnorm(5,0.001)
lambda[2] ~ dnorm(15,0.001)
#Alternatively, priors on lambda could be uninformative by substituting the following line
#for the first line of the 'for loop' in the next section.
for (i in 1:G) {lambda[i] ~ dnorm(0,0.001)
# BE SURE TO COMMENT OUT THE PRIORS YOU DON'T WANT!
for (i in 1:G) {wlam[i] <- lambda[i]*K[i]
delta[i] <- lambda[i]-lambda.G
s.delta[i] <- K[i]*pow(delta[i],2)}
lambda.G <- sum(wlam[])/sum(K[])
s1 <- sum(s.delta[1:G])
Fhat <- s1/(s2*G-s2)
# compare Fhat to 5% sig level for F(1,8)
test <- step(Fhat-5.32)}
Data
list(x=c(9,6,4,6,7,10,12,9,12,10),
T=c(1,1,1,1,1,1,2,2,2,2),
K=c(6,4),
G=2,N=10)
#For one chain...
Inits
list(tau=1)