好吧,我只是重写我的代码。 现在的问题是,当我编译它,我得到“节点的多重定义”的错误。 不要任何人知道自己做错了什么在我的代码。 我创建了一个变量,B和C的模式不具有很多常量。
model{
for(i in 1:n){
a <- (k[1] + step(s1[i]-.9)*k[2] + step(s1[i]*.5-.9)*k[3])
b <- (r[1] + step(s2[i]-.9)*r[2] + step(s2[i]*.5-.9)*r[3])
c <- (s[1] + step(s3[i]-.9)*s[2] + step(s3[i]*.5-.9)*s[3])
dummy[i] <- 0
dummy[i] ~ dloglik(logLike[i])
# This is the log transformation of the 3-variate poisson
logLike[i] <- -theta12[i] + a*log(theta12[i]) - logfact(a) -theta13[i] - b*log(theta13[i]) - logfact(b)-theta23[i] - c*log(theta23[i]) - logfact(c)-theta1[i] + (y1[i]-a-b)*log(theta1[i]) + logfact(y1[i]-a-b)-theta2[i] + (y2[i]-a-c)*log(theta2[i]) + logfact(y2[i]-a-c)-theta3[i] + (y3[i]-b-c)*log(theta3[i]) + logfact(y3[i]-b-c)
log(theta1[i]) <- alpha1 + beta1*log(L[i])
log(theta2[i]) <- alpha2 + beta2*log(L[i])
log(theta3[i]) <- alpha3 + beta3*log(L[i])
log(theta12[i]) <- alpha4 + beta4*log(L[i])
log(theta23[i]) <- alpha5 + beta5*log(L[i])
log(theta13[i]) <- alpha6 + beta6*log(L[i])
}
alpha1 ~ dgamma(.001, .001)
alpha2 ~ dgamma(.001, .001)
alpha3 ~ dgamma(.001, .001)
alpha4 ~ dgamma(.001, .001)
alpha5 ~ dgamma(.001, .001)
alpha6 ~ dgamma(.001, .001)
beta1 ~ dgamma(.001, .001)
beta2 ~ dgamma(.001, .001)
beta3 ~ dgamma(.001, .001)
beta4 ~ dgamma(.001, .001)
beta5 ~ dgamma(.001, .001)
beta6 ~ dgamma(.001, .001)
}
data
list(y1 =c(0,1,2,3,2),
y2 = c(1,2,3,0,2),
y3 = c(1,3,2,3,2),
k = c(0,1,2,3,4),
s = c(0,1,2,3,4),
r = c(0,1,2,3,4),
L = c(1,2,3,4,5),
s1= c(0,1,2,0,2),
s2= c(0,0,0,0,0),
s3= c(1,1,0,0,0),n=5)
inits
list(beta1=0,beta2=0,beta3=0,beta4=0,beta5=0,beta6=0,alpha1=0,alpha2=0,alpha3=0,
alpha4=0,alpha5=0,alpha6=0)