I have managed to modify the "Alli" code so that
the for( ) loops are not nested, but the modifications
yield the same results. Does anyone know:
(1) why the authors of the "Alli" code found it necessary to
nest the #Likelihood section within the for(i in 2:I){} and
for(j in 2:J){} loops?
(2)what advantages there are to using such a nesting?
I have pasted my modified code at the bottom of this message.
Regards,
David Alan Paul, Ph.D.
Battelle Memorial Institute - SDAS
[log in to unmask]
614-424-3176
614-424-4611 (fax)
http://www.battelle.org/statistics
model A
{
#PRIORS
alpha[1] <- 0
for (k in 2 : K)
{ alpha[k] ~ dnorm(0, 0.00001)}
# Loop around lakes:
for(i in 1:I){beta[i,1] <- 0}
for(k in 2:K){beta[1,k] <- 0}
for(i in 2:I){
for(k in 2:K){
beta[i,k] ~ dnorm(0.0,1.0E-6)
}}
for(j in 1:J){gamma[j,1] <- 0}
for(k in 2:K){gamma[1,k] <- 0}
for(j in 2:J){
for(k in 2:K){
gamma[j,k] ~ dnorm(0.0,1.0E-6)
}}
#LIKELIHOOD
for (i in 1 : I){
for (j in 1 : J){
#Multinomial response
X[i,j,1:K] ~ dmulti( p[i,j,1:K] , n[i,j] )
n[i,j] <- sum(X[i,j,])
for (k in 1:K){
p[i,j,k] <- phi[i,j,k] / sum(phi[i,j,])
log(phi[i,j,k]) <- alpha[k] + beta[i,k] + gamma[j,k]}
#lambda[i, j] ~ dnorm(0, 0.00001)
#for (k in 1 : K)
#{
#X[i,j,k] ~ dpois(mu[i,j,k])
#log(mu[i,j,k]) <- lambda[i,j]+alpha[k]+beta[i,k]+gamma[j,k]
#}
}}
# TRANSFORM OUTPUT TO ENABLE COMPARISON
# WITH AGRESTI'S RESULTS
for (k in 1:K){# loop around foods
for (i in 1:I){# loop around lakes
b[i,k] <- beta[i,k] - mean(beta[,k])}
for (j in 1:J){
g[j,k] <- gamma[j,k] - mean(gamma[,k])
}}
}
-------------------------------------------------------------------
This list is for discussion of modelling issues and the BUGS software.
For help with crashes and error messages, first mail [log in to unmask]
To mail the BUGS list, mail to [log in to unmask]
Before mailing, please check the archive at www.jiscmail.ac.uk/lists/bugs.html
Please do not mail attachments to the list.
To leave the BUGS list, send LEAVE BUGS to [log in to unmask]
If this fails, mail [log in to unmask], NOT the whole list
|