楼主: ReneeBK
1719 1

R2WinBUGS: Error in bugs [推广有奖]

  • 1关注
  • 62粉丝

VIP

已卖:4896份资源

学术权威

14%

还不是VIP/贵宾

-

TA的文库  其他...

R资源总汇

Panel Data Analysis

Experimental Design

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

楼主
ReneeBK 发表于 2014-6-26 09:44:45 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
Dear lister

I get an error when I call bugs(..., program="OpenBUGS", bugs.directory="c:/Program files/OpenBUGS/OpenBUGS312"), expecting, as suggested in help(bugs), that it would fit the model with openbugs() via BRugs.
  1. > help(bugs)
  2. ... either winbugs/WinBUGS or openbugs/OpenBUGS, the latter makes use of function openbugs and requires the CRAN package
  3. BRugs. ...
复制代码
However, it works fine when I directly call openbugs().  All other things are exactly the same.  It seems that (in my
settings) bugs(program="OpenBUGS") works differently than openbugs().  Am I doing something wrong with bugs()?   Or there is something wrong with my OpenBUGS installation?

I am using R-2.12.0, R2WinBUGS 2.1-16 (2009-11-06), OpenBUGS 3.1.2 rev 668 (2010-09-28), and BRugs 0.5-3 (2009-11-06)  on a Windows XP machine.

Thanks
  1. ------- R file ---------
  2. require(R2WinBUGS)
  3. require(BRugs)
  4. # Example in Albert (2007).  Bayesian Computation with R.  Springer.
  5. # pp. 237-238.  Prior = beta(0.5, 0.5), observe Binom(n, p)
  6. # y=7 successes out of a sample of n=50.  Estimate p.
  7. y <- 7
  8. n <- 50
  9. alpha <- 1.0
  10. beta <- 1.0
  11. data <- list("y", "n", "alpha", "beta")
  12. inits <- function() { list(p = runif(1)) }
  13. param <- "p"
  14. # this works
  15. Albert.bugs <- openbugs(data=data, inits=inits, parameters.to.save=param, model.file = "C:/tryR/WinBUGS/Albert11.txt", n.chains=3, n.iter=500)
  16. print(Albert.bugs, digits.summary = 4)
  17. # this fails
  18. Albert.bugs <- bugs(data=data, inits=inits, parameters.to.save=param, model.file="C:/tryR/WinBUGS/Albert11.txt", n.chains=3, n.iter=500, program="OpenBUGS")

  19. ------- BUGS file: Albert11.txt ------
  20. model
  21. {
  22. y ~ dbin(p, n)
  23. p ~ dbeta( alpha, beta )
  24. }
复制代码


二维码

扫码加我 拉你入群

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

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

关键词:R2WinBUGS winbugs WINBUG Error BUGS function directly exactly package either

沙发
scure 发表于 2014-6-30 15:04:05
Hello~
I suggest you use package "R2OpenBUGS" to call BUGS. Add the following codes to the first few lines of your R codes.

  1. install.packages("R2OpenBUGS")
  2. library(R2OpenBUGS)
复制代码


Then, modify function openbugs() into the following codes:
  1. bugs(data=data, inits=inits, parameters.to.save=param, model.file="C:/tryR/WinBUGS/Albert11.txt", n.chains=3, n.iter=500)
复制代码


Hope this help~good luck

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

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2025-12-9 16:53