楼主: ReneeBK
1858 0

[精彩WinBUGS答问]Multiple definitions of node error in winbugs [推广有奖]

  • 1关注
  • 62粉丝

VIP

已卖:4897份资源

学术权威

14%

还不是VIP/贵宾

-

TA的文库  其他...

R资源总汇

Panel Data Analysis

Experimental Design

威望
1
论坛币
49635 个
通用积分
55.7537
学术水平
370 点
热心指数
273 点
信用等级
335 点
经验
57805 点
帖子
4005
精华
21
在线时间
582 小时
注册时间
2005-5-8
最后登录
2023-11-26

楼主
ReneeBK 发表于 2014-6-16 01:43:43 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
I try to use WinBUGS from R via BRugs and R2WinBUGS, the code is followinig:

require(R2WinBUGS)
require(BRugs)
model<-function(){
  for(i in 1:N){
    y <- x + w
    w ~ dnorm(0, sigma.y)
    x <- a - b*5 + v
    v ~ dnorm(0, sigma.x)
  }
a ~ dunif(0, 1)
b ~ dunif(-1, 1)
sigma.y ~ dgamma(0.1, 0.1)
sigma.x ~ dgamma(0.1, 0.1)
}

write.model(model, con = "model.bug")
modelCheck("model.bug")
# model is syntactically correct

N = 10
y = rnorm(100)
data = list(N = N, y = y)
inits = function(){
  list(a = runif(1, 0, 1), b = runif(1, -1, 1), sigma.x= rgamma(1, 0.1, 0.1),
       sigma.y = rgamma(1, 0.1, 0.1))
}
parameters = c("a", "b", "sigma.x", "sigma.y")

result.sim <- bugs(data, inits, parameters, "model.bug",
                n.chains = 1, n.iter = 1000,
                program= "winbugs",
                working.directory = NULL,
                debug = T)
The result didn't come out, and I find out part of the log.txt of WinBUGS:

display(log)
check(C:/Users/ADMINI~1.PC-/AppData/Local/Temp/RtmpkrnOoc/model.bug.txt)
model is syntactically correct
data(C:/Users/ADMINI~1.PC-/AppData/Local/Temp/RtmpkrnOoc/data.txt)
data loaded
compile(1)
multiple definitions of node y[1]
inits(1,C:/Users/ADMINI~1.PC-/AppData/Local/Temp/RtmpkrnOoc/inits1.txt)
command #Bugs:inits cannot be executed (is greyed out)
gen.inits()
command #Bugs:gen.inits cannot be executed (is greyed out)
thin.updater(1)
update(500)
command #Bugs:update cannot be executed (is greyed out)
set(a)
it is obvious that the error is multiple definitions of node y[1], but what does it mean? I don't think y[1] has multiple definitions since I use y but not y in the loop.
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:DEFINITIONS definition Multiple winbugs WINBUG require error

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2026-1-1 14:08