【问题标题】:openBugs error with simple car.normal() model. My mistake or bug?简单 car.normal() 模型的 openBugs 错误。我的错误或错误?
【发布时间】:2015-04-09 11:13:07
【问题描述】:

我尝试通过 car.normal() 分布在 openBugs 中实现空间固有高斯马尔可夫随机场模型(阶数 = 1)。对于常规的 3x3 网格,它可以正常工作。但是如果我增加样本大小(比如 4x4),我会得到一个错误。为什么?我很感激提示......

这是一个最小的例子,它不适用于 4x4(但适用于 3x3):

文件“model.txt”:

model{
   # likelihoood
   for(i in 1:No){ Y[i] ~ dnorm(Z[i], tau) } 

   Z[1:No] ~ car.normal(adj[], weights[], num[], kappa)
   for(k in 1:Nw) { weights[k] <- 1 }      

   # prior
   kappa ~ dgamma(1, 1) 
   tau ~ dgamma(1, 1) 
}

以及 4x4 网格的“data.txt”:

list(No = 16,
Y = c(0.67,0.88,0.38,0.1,0.78,0.67,0.25,0.55,0.11,0.85,0.46,0.5,0.47,0.38,0.21,0.97), 
adj = c( 
5,2,
6,1,3,
7,2,4,
8,3,
1,9,6,
2,10,5,7,
6,14,9,11,
4,12,7,
5,13,10,
3,11,6,8,
7,15,10,12,
8,16,11,
9,14,
10,13,15,
11,14,16,
12,15),
num = c(2,3,3,2,3,4,4,3,3,4,4,3,2,3,3,2),
Nw = 48)

我在 R 中运行它(其他选项是可能的):

require(R2OpenBUGS)
bugs(data="data.txt",
     inits=function(){list(tau=10, kappa=100, Z = rep(c(-.5,.5),8))},
     parameters=c("Z","tau","kappa"),
     model.file="model.txt",
     n.chains=1, n.iter=150, n.burnin=1)

错误是:

OpenBUGS version 3.2.2 rev 1063
model is syntactically correct
data loaded
model compiled
error for node Z[1] of type SpatialCARNormal.Node first argument Graph18 error pos 260 (error on line 1)
error for node Z[1] of type SpatialCARNormal.Node first argument Graph18
model must be initialized before updating
model must be initialized before monitors used
model must be initialized before monitors used
model must be initialized before monitors used
model must be initialized before monitors used
model must be initialized before monitors used
model must be initialized before monitors used
model must be initialized before monitors used
model must be initialized before monitors used
model must be initialized before DIC can be monitored
model must be initialized before updating
model must be initialized before monitors used
model must be initialized before monitors used
DIC monitor not set

【问题讨论】:

    标签: winbugs


    【解决方案1】:

    你的“ajd”对象是错误的, 例如:第 3 个参数有 3 个邻居:7、2、4。但是当您查看第 7 个参数时,它没有第 3 个作为其邻居 (6,14,9,11)

    那一定是问题,我建议你仔细看看

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-14
      • 1970-01-01
      • 2014-04-25
      相关资源
      最近更新 更多