1

I'm using following program for MCMC simulation. While compiling this code, I am getting error message which is multiple definition of node s[1]. I am not able to understand what is wrong with the codes. Can someone help me to solve this coding issue.

model 
{
for(i in 1:N)
{
fa[i] <- ((beta/alpha)*pow((x[i]/alpha),beta)*sin(3.14/beta))
fb[i] <-  (pow((1+pow((x[i]/alpha) ,beta)),2))*(3.14/beta)
#pdf
f[i] <- fa[i]/fb[i]
for(j in 1:M)
{
s[j]<-pow((1-h[j]),r[j])
#likelihood
L[i,j] <- prod(f[i])*prod(s[j])
logL[i,j] <- log(abs(L[i,j]))
zeros[i,j] <- 0
zeros[i,j] ~ dloglik(logL[i,j])
}
}
#priors
alpha~dpar(2,1)
beta~dgamma(2,4)
}
#initial values
list(alpha=1.5,beta=4)
#data
list(N=20,M=15, x=c(0.5180348, 0.6660715, 0.8319573, 0.9048986, 0.9054750, 0.9833324, 1.0993628, 1.1271269, 1.1283080, 1.1962719, 1.2341214, 1.2961108, 1.2967491, 1.3251945, 1.4044869, 1.4245856, 1.4282459, 1.4415493, 1.4541208, 1.5729781),
h=c(0.007150087, 0.019656494, 0.046214896, 0.062851171, 0.062995134, 0.084229261, 0.122115926, 0.132184605, 0.132620744, 0.158709897, 0.174001000, 0.256533617, 0.258176306, 0.264155107, 0.269815309),
r=c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))

1 Answers1

1

I see that the second for loop is nested in the first for loop and therefore you define s[j] N times. Particularly, you define s[1] N times. One solution is to use a separate for loop to define s[j].

TrungDung
  • 749
  • 4
  • 13