我正在尝试在rjags中运行多项模型并且我一直收到此错误
Error in jags.model(model.file, data = data, inits = init.values,
n.chains = n.chains, :
Error in node dmulti(b,639)
Length mismatch in Node::setValue
以下是创建错误的代码:
n = c(294, 307,38)
m= c(288, 332,19)
x=1
y=1
z=1
model_string <-"model {
for(j in 1:3) {
n[j] ~ dmulti( a[1:3], 639)
m[j] ~ dmulti(b[1:3], 639)
}
a[1:3] ~ ddirich(c(x,y,z))
b[1:3]~ ddirich(c(x,y,z))
prob = step(b[1]-a[1])
RD = b[1]-a[1]
}"
jags.param <- c("a[1]","b[1]", "prob", "RD")
jags.data <- list(n=n,m=m, x=x, y=y,z=z)
jagsfit4 <- jags(data=jags.data, n.chains = 4, inits=NULL, parameters.to.save = jags.param,
model.file=textConnection(model_string), n.thin = 1 ,n.iter=5000,
n.burnin=1500, DIC=TRUE)
谢谢!