I'm trying to run the code below in which I used a zero trick for my log-likelihood expression(phi is my log-likelihood):
model{
for (l in 1:k) {
d.1[l] ~ dbern(p.1)
d.2[l] ~ dbern(p.2)
d.3[l] ~ dbern(p.3)
d.4[l] ~ dbern(p.4)
}
for (l in 1:k) {
zeros[l] <- 0
zeros[l] ~ dpois(phi[l])
u.1[l] <- pow((1 - p.1), (1 - d.1[l]))
u.2[l] <- pow((1 - p.2), (1 - d.2[l]))
u.3[l] <- pow((1 - p.3), (1 - d.3[l]))
u.4[l] <- pow((1 - p.4), (1 - d.4[l]))
f.1[l] <- pow(p.1, d.1[l]) * pow((1 - p.1), (1 - d.1[l]))
f.2[l] <- pow(p.2, d.2[l]) * pow((1 - p.2), (1 - d.2[l]))
f.3[l] <- pow(p.3, d.3[l]) * pow((1 - p.3), (1 - d.3[l]))
f.4[l] <- pow(p.4, d.4[l]) * pow((1 - p.4), (1 - d.4[l]))
a[l] <- pow((pow(u.3[l], -theta.1) + pow(u.4[l], -theta.1) -
1), (theta.0/theta.1 - 2)) * (-1) * ((theta.0/theta.1) *
(-1) + pow((theta.0/theta.1), 2))
b[l] <- pow((pow(u.1[l], -theta.2) + pow(u.2[l], -theta.2) -
1), (theta.0/theta.2 - 2)) * (-1) * ((theta.0/theta.2) *
(-1) + pow((theta.0/theta.2), 2))
c[l] <- pow(pow((pow(u.3[l], -theta.1) + pow(u.4[l],
-theta.1) - 1), -(1/theta.1)), -theta.0) + pow(pow((pow(u.2[l],
-theta.2) + pow(u.1[l], -theta.2) - 1), -(1/theta.2)),
-theta.0) - 1
d[l] <- pow((pow(u.3[l], -theta.1) + pow(u.4[l], -theta.1) -
1), (theta.0/theta.1 * 2 - 2)) * pow(theta.0/theta.1,
2)
e[l] <- pow((pow(u.1[l], -theta.2) + pow(u.2[l], -theta.2) -
1), (theta.0/theta.2 * 2 - 2)) * pow(theta.0/theta.2,
2)
phi[l] <- log((a[l] * b[l]) * (1 + theta.0)/pow(c[l],
-(2 + 1/theta.0)) + (d[l] * b[l] + a[l] * e[l]) *
((1 + theta.0) * (1 + 2 * theta.0))/pow(theta.0,
3) * pow(c[l], -(3 + 1/theta.0)) + (d[l] * e[l]) *
((1 + theta.0) * (1 + 2 * theta.0) * (1 + 3 * theta.0))/pow(theta.0,
4) * pow(c[l], -(4 + 1/theta.0))) + log(pow(theta.1,
2) * pow((u.3[l] * u.4[l]), -(1 + theta.1)) * pow(theta.2,
2) * pow((u.1[l] * u.2[l]), -(1 + theta.2)))
}
p.1 ~ dunif(0 , 1)
p.2 ~ dunif(0 , 1)
p.3 ~ dunif(0 , 1)
p.4 ~ dunif(0 , 1)
theta.0 ~ dunif(0 , 2)
theta.1 ~ dunif(0 , 2)
theta.2 ~ dunif(0 , 2)
}
with data:
k <- 16
d.1 <- c(0 , 0, 0 , 0 , 1 , 0 , 1 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , 1 , 0)
d.2 <- c(0 , 1, 0 , 0 , 0 , 0 , 1 , 0 , 1 , 1 , 0 , 1 , 0 , 0 , 1 , 0)
d.3 <- c(1 , 0, 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0)
d.4 <- c(0 , 1, 0 , 0 , 0 , 0 , 1 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0)
The model is syntactically correct and the data is loaded but I got the following error:
logical expression contains too many constants
Can anyone please help me solve that problem?
BUGS does not like expressions with too many constants. You need to introduce a sub-step to break them up. See point (c) under 'Some Error Messages' in this page: http://mathstat.helsinki.fi/openbugs/Manuals/TipsTroubleshooting.html