JAGS中可能的定向循环错误

时间:2017-04-15 16:08:59

标签: r jags

我正在尝试使用poisson技巧拟合单形模型,可能性为Likelihood Simplex。代码在

之下
model{
  for (i in 1:n){
    y[i] ~ dpois(lambda[i])
    lambda[i] <- 0.5*log(phi[i]*(y[i]*(1-y[i]))^3) + 0.5*(1/phi[i])*d[i]
    d[i] <- ((y[i]-mu[i])^2)/(y[i]*(1-y[i])*mu[i]^2*(1-mu[i])^2)
    mu[i] <- beta0+beta1*income[i] + beta2*person[i]
    log(phi[i]) <- -delta0
  }
  beta0 ~ dnorm(0,.001)
  beta1 ~ dnorm(0,.001)
  beta2 ~ dnorm(0,.001)
  delta0 ~ dnorm(0,.001)
}"

当我尝试在R中使用JAGS运行代码时,出现以下错误

 RUNTIME ERROR:
Possible directed cycle involving some or all
of the following nodes:

然后它会显示所有d[]y[]lambda[]

我发现某人有类似的问题JAGS error,但看起来我没有犯同样的错误。

任何帮助?

修改

第二次尝试

regmodel = "
data{
  for(i in 1:n) {
    zeros[i] <- 0
  }
}
model{
  C <- 1000
  for (i in 1:n){
    zeros[i] ~ dpois(lambda[i])
    lambda[i] <- -l[i] + C
    l[i] <- 
      0.5*log(phi[i]*(y[i]*(1-y[i]))^3) + 
      0.5*(1/phi[i])*((y[i]-mu[i])^2)/(y[i]*(1-y[i])*mu[i]^2*(1-mu[i])^2)
    mu[i]<- beta0 + beta1*income[i] + beta2*person[i]
    log(phi[i]) <- -delta0
  }
  beta0 ~ dnorm(0,.001)
  beta1 ~ dnorm(0,.001)
  beta2 ~ dnorm(0,.001)
  delta0 ~ dnorm(0,.001)
}"

但现在的错误是

Error in jags.model(file = "ModeloSimplex.txt", data = reg.dat, n.chains = 3,  : 
  Error in node (a(a0.5*(a1/phi[1])*(a(ay[1]-mu[1])^2))/(ay[1]*(a1-y[1])*(amu[1]^2)*(a(a1-mu[1])^2)))
Invalid parent values

0 个答案:

没有答案