I have a syntax error in my R function code, and I can't find it. Before I made it into a function it worked fine. I am new to R, and this is the first meaningful function I made (after making smaller test functions).
#model bzip
{
#Likelihood:
for(i in 1:n)
{
Y1[i] ~ dpois(mu1[i])
Y2[i] ~ dpois(mu2[i])
mu1[i] <- (1-u[i, 1])(1-u[i, 3])
(lambda0 + lambda1)
mu2[i] <- (1-u[i, 1])(1-u[i, 2])
(lambda0+lambda2)
u[i, 1:4] ~ dmulti(p[], 1)
}
for(i in 1:3)
{
log(q[i]) <-alpha[i]
p[i] <- q[i]*p[4]
}
p[4] <- 1/(q[1]+q[2]+q[3]+1)
log(lambda0) <-beta[1]
log(lambda1) <-beta[2]
log(lambda2) <-beta[3]
zdp <- p[1]+p[2]*(exp(-lambda0 -lambda1))
+p[3]*(exp(-lambda0 -lambda2)) +
p[4]*(exp(-lambda0 -lambda1 -lambda2))
#P(Y1=Y2=0)
zdp1 <- p[1]+p[3]+(p[2]+p[4])*(exp(-lambda0
-lambda1)) #P(Y1=0)
zdp2 <- p[1]+p[2]+(p[3]+p[4])*(exp(-lambda0
-lambda2))#P(Y2=0)
e1 <- (p[2] +p[4])*(lambda0 + lambda1) # E(Y1)
e2 <- (p[3] +p[4])*(lambda0 + lambda2) # E(Y2)
#Priors:
for(j in 1:3)
{
beta[j]~ dnorm(0, 0.001)
alpha[j]~dnorm(0, 0.001)
}
}
I just checked your code quickly, is that the complete code you need to run? There are a number of variables (e.g. int, vectors) that are not defined, for example take a look here:
From where the variable n in the loop definition is coming from and what it is its supposed value (how many times the loop is supposed to run?)
Another one: from there the vector u is coming from?
I would check all the names and variables declaration first, or if I am wrong, can you please post all the code for us to run it?