【问题标题】:Openbugs too many constants errorOpenbugs 常量太多错误
【发布时间】:2015-06-12 07:55:20
【问题描述】:

我正在尝试运行下面的代码,其中我对我的对数似然表达式使用了零技巧(phi 是我的对数似然):

 model{
for (l in 1:k) {
d.1[l] ~ dbern(p.1)
d.2[l] ~ dbern(p.2)
d.3[l] ~ dbern(p.3)
d.4[l] ~ dbern(p.4)
}
for (l in 1:k) {
zeros[l] <- 0
zeros[l] ~ dpois(phi[l])
u.1[l] <- pow((1 - p.1), (1 - d.1[l]))
u.2[l] <- pow((1 - p.2), (1 - d.2[l]))
u.3[l] <- pow((1 - p.3), (1 - d.3[l]))
u.4[l] <- pow((1 - p.4), (1 - d.4[l]))
f.1[l] <- pow(p.1, d.1[l]) * pow((1 - p.1), (1 - d.1[l]))
f.2[l] <- pow(p.2, d.2[l]) * pow((1 - p.2), (1 - d.2[l]))
f.3[l] <- pow(p.3, d.3[l]) * pow((1 - p.3), (1 - d.3[l]))
f.4[l] <- pow(p.4, d.4[l]) * pow((1 - p.4), (1 - d.4[l]))
a[l] <- pow((pow(u.3[l], -theta.1) + pow(u.4[l], -theta.1) - 
    1), (theta.0/theta.1 - 2)) * (-1) * ((theta.0/theta.1) * 
    (-1) + pow((theta.0/theta.1), 2))
b[l] <- pow((pow(u.1[l], -theta.2) + pow(u.2[l], -theta.2) - 
    1), (theta.0/theta.2 - 2)) * (-1) * ((theta.0/theta.2) * 
    (-1) + pow((theta.0/theta.2), 2))
c[l] <- pow(pow((pow(u.3[l], -theta.1) + pow(u.4[l], 
    -theta.1) - 1), -(1/theta.1)), -theta.0) + pow(pow((pow(u.2[l], 
    -theta.2) + pow(u.1[l], -theta.2) - 1), -(1/theta.2)), 
    -theta.0) - 1
d[l] <- pow((pow(u.3[l], -theta.1) + pow(u.4[l], -theta.1) - 
    1), (theta.0/theta.1 * 2 - 2)) * pow(theta.0/theta.1, 
    2)
e[l] <- pow((pow(u.1[l], -theta.2) + pow(u.2[l], -theta.2) - 
    1), (theta.0/theta.2 * 2 - 2)) * pow(theta.0/theta.2, 
    2)
phi[l] <- log((a[l] * b[l]) * (1 + theta.0)/pow(c[l], 
    -(2 + 1/theta.0)) + (d[l] * b[l] + a[l] * e[l]) * 
    ((1 + theta.0) * (1 + 2 * theta.0))/pow(theta.0, 
    3) * pow(c[l], -(3 + 1/theta.0)) + (d[l] * e[l]) * 
    ((1 + theta.0) * (1 + 2 * theta.0) * (1 + 3 * theta.0))/pow(theta.0, 
    4) * pow(c[l], -(4 + 1/theta.0))) + log(pow(theta.1, 
    2) * pow((u.3[l] * u.4[l]), -(1 + theta.1)) * pow(theta.2, 
    2) * pow((u.1[l] * u.2[l]), -(1 + theta.2)))
 }
 p.1 ~ dunif(0 , 1)
 p.2 ~ dunif(0 , 1)
p.3 ~ dunif(0 , 1)
p.4 ~ dunif(0 , 1)
theta.0 ~ dunif(0 , 2)
theta.1 ~ dunif(0 , 2)
theta.2 ~ dunif(0 , 2)
 }

有数据:

 k <- 16
 d.1 <- c(0 , 0, 0 , 0 , 1 , 0 , 1 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , 1 , 0)
 d.2 <- c(0 , 1, 0 , 0 , 0 , 0 , 1 , 0 , 1 , 1 , 0 , 1 , 0 , 0 , 1 , 0)
 d.3 <- c(1 , 0, 0 , 0 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0)
 d.4 <- c(0 , 1, 0 , 0 , 0 , 0 , 1 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , 0 , 0)

模型在语法上是正确的,并且数据已加载,但出现以下错误:

logical expression contains too many constants

谁能帮我解决这个问题?

【问题讨论】:

    标签: winbugs openbugs


    【解决方案1】:

    BUGS 不喜欢有太多常量的表达式。您需要引入一个子步骤来分解它们。请参阅本页“一些错误消息”下的 (c) 点: http://mathstat.helsinki.fi/openbugs/Manuals/TipsTroubleshooting.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-07-21
      • 2014-04-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-08
      • 2010-09-19
      • 1970-01-01
      相关资源
      最近更新 更多