楼主: scure
3278 3

Common error messages in BUGS and their possible solutions [推广有奖]

  • 2关注
  • 2粉丝

讲师

19%

还不是VIP/贵宾

-

威望
0
论坛币
255 个
通用积分
0.0101
学术水平
19 点
热心指数
6 点
信用等级
11 点
经验
1240 点
帖子
40
精华
1
在线时间
730 小时
注册时间
2008-5-2
最后登录
2018-2-16

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币

Admit it! BUGS (including WinBUGSand OpenBUGS  is a powerful tool to do Bayesian estimation but it usually would not run without a fight (error messages).


Most BUGS books focus on teaching you how to build a Bayesian model and run BUGS in your computer but few books teach you how to debug and find the solution to your problems. In this article, I try to bring common error message showing in BUGS and give possible solutions.


Whole article will be divided into three parts: Check Model, Load Data, and Compile. These parts are the 3-step procedure when running BUGS. If you don't know these, I suggest you read the chapter 3 and 4 in the book "Bayesian Modeling Using WinBUGS". [size=13.333333015441895px]"[size=13.333333015441895px]Data analysis using regression and multilevel/hierarchical models[size=13.333333015441895px]" (section 16.8, p.366) also gives excellent [size=13.600000381469727px]explanations about the BUGS code structure. [size=13.333333015441895px]


1. Check Model


You need basic skill for BUGS language syntax and you could refer to Appendix in the book [size=13.600000381469727px]"[size=13.600000381469727px]The BUGS Book[size=13.600000381469727px]".


  • "unknown type of distribution"

This simply means that BUGS cannot recognize the distribution you write. For WinBUGS users, you should check your spelling or update the distribution by following the instruction. For OpenBUGS users, some distribution (for example truncated normal could be used by following the procedure above), should be modified following this instruction.


  • "unknown type of logical function"

Remember, in BUGS, ~ means "is distributed as" and < - means "is to be replaced by" Therefore, this error message just warn you probably put < - in front of the distribution code.


  • "invalid or unexpected token scanned"

These are the common mistakes will show in your BUGS because you did not add another half codes like } and ]. I suggest you use code writing software like RStudiosince the BUGS use similar codes with R. The beauty of RStudio is that it will automatically help you add another half codes.


2. Load Data

One of the difficulties to use BUGS is that its data format is quite different from we usually use. I find it is hard to import your data especially when your data format is excel. If your data is not large, it will be ok just to copy and paste. If it is not, you better consider to use R (its package "R2WinBUGS and "R2OpenBUGS" to call BUGS to work for you.


  • "expected key word structure error pos 1534"

Check whether there are matrix type (like data[i,j])of data in the Model code but you use vector type (like data) in the Data (including the initial values) code. It's the same the other way round. You should make sure that model and data have a consistent type. See examples in stackoverflow.


3. Compile


"model is syntactically correct" Ya! After lot of works, you finally let BUGS compile the model and data and it starts to run! However, you still could get the error messages and BUGS just does not give any results.



  • "number of items not equal to size of node error"

Sometimes, even if this error shows up, BUGS will still give you the final results.

You need to check whether a initial value vector is the same size as parameter vector in OpenBUGS.


  • "Sorry something went wrong in procedure Sqrt in module Math"

Check whether the setup of your sigma for data dependent variable (y) is beyond the range of data y. For example, your data y is from 0~100, and you should set your sigma at least to 1000 (when it is uniform distribution). See examples in Bayesian Data Analysis (ed 2, p.593).


  • "Sorry something went wrong in procedure Writer.SetPos in module HostFiles"

Honestly, I don't know what it mean, but I overcome this by reducing the number of iterations and burnin. However, it does not guarantee you will get the right results. In fact, sometimes you could get unstable estimated parameters especially when you lower down the number of iterations greatly. It's better to recheck your codes. You could see more debug techniques in the book, [size=13.333333015441895px]"[size=13.333333015441895px]Data analysis using regression and multilevel/hierarchical models[size=13.333333015441895px]" (chapter 19, p.415).

[size=13.333333015441895px]

  • "Sorry something went wrong in procedure ..."

This problem is more general and ... means any problems including the above problem. If you want to know more what is wrong in your BUGS, see this blog for further info. After you follow the procedure of above blog, you could see trap window writing the errors below instead of "Sorry something went wrong in procedure ..."



  • “undefined real result  (B9A1, 37E) Pre: argument of Sqrt must not be negative”

Check whether your BUGS code variance for your data (y) is larger than your data (y). You should also check your priors.



Other Error messages could be found in the BUGS manual and  stackoverflow.

[size=13.333333015441895px]"[size=13.333333015441895px]Data analysis using regression and multilevel/hierarchical models[size=13.333333015441895px]" (chapter 19, p.415) also provides a great source to debug your codes.

二维码

扫码加我 拉你入群

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

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

关键词:solutions Solution possible messages Message bugs BUGS openbugs软件 openbugs winbugs

已有 1 人评分经验 论坛币 学术水平 收起 理由
Nicolle + 60 + 60 + 5 鼓励积极发帖讨论

总评分: 经验 + 60  论坛币 + 60  学术水平 + 5   查看全部评分

沙发
敏维 发表于 2015-3-23 22:01:44 |只看作者 |坛友微信交流群
感谢!!!!{:3_62:}

使用道具

藤椅
soccy 发表于 2015-3-24 04:35:18 |只看作者 |坛友微信交流群
不错。不多BUGS已经过气了

使用道具

板凳
yangshucai 发表于 2017-5-24 09:14:01 |只看作者 |坛友微信交流群
您好,blog那个链接打开不了,可以给个能打开的链接吗

使用道具

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

本版微信群
加好友,备注jltj
拉您入交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-4-27 08:23