I need to know how to impose constraints of the form sum(array elements) = 0
in WinBUGS.
I am fitting a loglinear model to Agresti's nominal alligator data and keep
getting error messages
when I try to Compile. My code is below. The lines where a zero has been
assigned to a
vector are my attempts at implementing these restrictions.
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
{
for(i in 1:I){
for(j in 1:J){
for(k in 1:K){
for(l in 1:L){
first.part[i,j,k,l] <- mean + lam1[i] + lam2[j] + lam3[k] + lam4[l]
second.part[i,j,k,l] <- lam12[i,j] + lam13[i,k] + lam14[i,l]
log(mu[i,j,k,l]) <- first.part[i,j,k,l] + second.part[i,j,k,l] +
lam234[j,k,l]
thelogit[i,j,k,l] <- log(mu[i,j,k,l]/mu[1,j,k,l])
n[i,j,k,l] ~ dpois(mu[i,j,k,l])
}}}}
oneway.sum <- sum(lam1[])+sum(lam2[])+sum(lam3[])+sum(lam4[])
oneway.sum <- 0
for(i in 1:I)
{
temp12[i] <- sum(lam12[i,])
temp13[i] <- sum(lam13[i,])
temp14[i] <- sum(lam14[i,])
}
twowayintx.sum <- sum(temp12[]) + sum(temp13[]) + sum(temp14[])
twowayintx.sum <- 0
for(j in 1:J){
for(k in 1:K){
temp234.first[j,k] <- sum(lam234[j,k,])
}}
for(j in 1:J)
{
temp234.second[j] <- sum(temp234.first[j,])
}
threewayintx.sum <- sum(temp234.second[])
threewayintx.sum <- 0
mean ~ dnorm(0.0,1.0E-6)
for(i in 1:I)
{
lam1[i] ~ dnorm(0.0,1.0E-6)
for(j in 1:J)
{
lam12[i,j] ~ dnorm(0.0,1.0E-6)
}
for(k in 1:K)
{
lam13[i,k] ~ dnorm(0.0,1.0E-6)
}
for(l in 1:L)
{
lam14[i,l] ~ dnorm(0.0,1.0E-6)
}
}
for(j in 1:J)
{
lam2[j] ~ dnorm(0.0,1.0E-6)
}
for(k in 1:K)
{
lam3[k] ~ dnorm(0.0,1.0E-6)
}
for(l in 1:L)
{
lam4[l] ~ dnorm(0.0,1.0E-6)
}
for(j in 1:J){
for(k in 1:K){
for(l in 1:L){
lam234[j,k,l] ~ dnorm(0.0,1.0E-6)
}}}
}
list(I=5,J=2,K=4,L=2,n=structure(.Data=c(16,3,7,4,3,0,2,13,2,0,3,8
,3,8,13,9,3,0,1,0,9,1,2,7,4,1,7,6,9,1,10,0,2,1,0,0,1,0,0,6,1,0,1,6,1,0,
0,0,2,2,0,1,0,1,0,0,1,0,0,3,0,0,2,1,3,3,5,2,2,0,1,0,4,0,1,5,1,1,2,2),.
Dim=c(5,2,4,2))
-------------------------------------------------------------------
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
|