我在winbugs中的这段代码有一些问题。 y []是原始数据和未知参数的函数,因此我计算y,但是在编译时,软件输出是“节点y [1,1]的多个定义”。我不知道如何解决这个问题。
model
{
for(i in 1:n){
y[i,1] <- 1/3*sum(x1[i,1:9])/(sqrt(0.01*v1)*u1)-3*sqrt(v1*0.01)
y[i,2] <- 1/3*sum(x2[i,1:9])/(sqrt(0.01*v2)*u2)-3*sqrt(v2*0.01)
#y[i,1:2] ~ dmnorm(mu[],tau[,])
}
gv1 <- 0.01*v1
gv2 <- 0.01*v2
mu[1] <- 0
mu[2] <- 0
tau[1,1] <- 1
tau[1,2] <- rho
tau[2,1] <- rho
tau[2,2] <- 1
for(i in 1:n){
for(j in 1:m){
x1[i,j] ~ dgamma(gv1,u1)
x2[i,j] ~ dgamma(gv2,u2)
}
y[i,1:2] ~ dmnorm(mu[],tau[,])
}
v1~dflat()T(0,)
u1~dflat()T(0,)
v2~dflat()T(0,)
u2~dflat()T(0,)
rho~dunif(0,1)
}
data
list(n=10,m=9,
x1=structure(
.Data=c(0.05,0.05,0.05,0.07,0.07,0.08,0.08,0.13,0.16,
0.04,0.04,0.05,0.05,0.06,0.07,0.07,0.09,0.1,
0.04,0.04,0.05,0.05,0.05,0.06,0.07,0.09,0.11,
0.04,0.04,0.05,0.04,0.05,0.07,0.06,0.09,0.09,
0.04,0.04,0.05,0.04,0.05,0.07,0.05,0.1,0.09,
0.04,0.04,0.05,0.04,0.05,0.06,0.05,0.1,0.08,
0.04,0.04,0.04,0.05,0.04,0.06,0.06,0.09,0.09,
0.03,0.04,0.03,0.06,0.05,0.06,0.06,0.07,0.09,
0.02,0.05,0.04,0.04,0.04,0.06,0.06,0.07,0.08,
0.02,0.04,0.04,0.04,0.04,0.05,0.06,0.07,0.08),
.Dim=c(10,9)),
x2=structure(
.Data=c(0,0.06,0.04,0.04,0.04,0.05,0.05,0.06,0.07,
0.03,0.04,0.03,0.03,0.04,0.03,0.06,0.06,0.07,
0.02,0.05,0.02,0.04,0.03,0.04,0.04,0.06,0.06,
0.03,0.03,0.04,0.03,0.04,0.05,0.04,0.04,0.06,
0.02,0.04,0.03,0.04,0.03,0.04,0.06,0.05,0.06,
0.02,0.03,0.02,0.03,0.03,0.04,0.04,0.05,0.06,
0.03,0.03,0.01,0.03,0.05,0.03,0.03,0.05,0.04,
0.02,0.02,0.03,0.04,0.03,0.03,0.02,0.05,0.05,
0.02,0.02,0.03,0.02,0.03,0.03,0.03,0.04,0.04,
0.02,0.02,0.03,0.02,0.03,0.03,0.03,0.04,0.04),
.Dim=c(10,9)))
list(v1=100,u1=1,v2=100,u2=1,rho=0.5)