楼主: Lisrelchen
4542 4

[本週專題]R2WinBUGS: Undefined Real Result? [推广有奖]

  • 0关注
  • 62粉丝

VIP

已卖:4194份资源

院士

67%

还不是VIP/贵宾

-

TA的文库  其他...

Bayesian NewOccidental

Spatial Data Analysis

东西方数据挖掘

威望
0
论坛币
50288 个
通用积分
83.6906
学术水平
253 点
热心指数
300 点
信用等级
208 点
经验
41518 点
帖子
3256
精华
14
在线时间
766 小时
注册时间
2006-5-4
最后登录
2022-11-6

楼主
Lisrelchen 发表于 2014-6-26 21:04:13 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币

Dear R users,


Attached please review view my log file. I am using R2WinBUGS to call WinBUGS from R. After loading data, model, and initial values I called the command as follows and got some inf parameter values. I do not understand why this happens as the program was working fine for 5*10^5 iterations. I tried to change the seed values but of no use.

  1. res <- bugs(data = dfile, inits = list(ifile), parameters.to.save = c("beta"), model.file = mfile, working.directory = tdir, n.thin = nthin, n.chains = 1, n.iter = niterations*nthin, n.burnin = 0, DIC = F, debug = T, save.history=F)
复制代码
  1. display(log)
  2. check(C:/Documents and Settings/sbadamakis/Desktop/model_4/model_4.txt)
  3. model is syntactically correct
  4. data(C:/Documents and Settings/sbadamakis/Desktop/model_4/output1/data.txt)
  5. data loaded
  6. compile(1)
  7. model compiled
  8. inits(1,C:/Documents and Settings/sbadamakis/Desktop/model_4/output1/inits1.txt)
  9. model is initialized
  10. gen.inits()
  11. command #Bugs:gen.inits cannot be executed (is greyed out)
  12. thin.updater(1)
  13. update(0)
  14. set(beta)
  15. update(20)
  16. coda(*,C:/Documents and Settings/sbadamakis/Desktop/model_4/output1/coda)
  17. stats(*)
  18. Node statistics
  19. node mean sd MC error 2.5% median 97.5% start sample
  20. beta[1] 1.588 0.009812 0.003936 1.579 1.584 1.607 1 20
  21. beta[2] -0.04272 0.00263 0.001137 -0.04592 -0.0433 -0.03688 1 20
  22. beta[3] -0.07878 8.531E-4 2.829E-4 -0.07962 -0.07833 -0.07699 1 20
  23. beta[4] -0.3035 0.01016 0.004509 -0.3194 -0.3028 -0.2841 1 20
  24. beta[5] 1.241 0.00854 0.002739 1.228 1.242 1.258 1 20
  25. beta[6] -4.155 0.01242 0.005405 -4.174 -4.152 -4.132 1 20
  26. beta[7] 0.08322 0.001485 6.379E-4 0.08201 0.0824 0.08608 1 20
  27. beta[8] -3.001 0.009335 0.003318 -3.013 -3.004 -2.981 1 20
  28. beta[9] 0.07953 7.547E-4 3.198E-4 0.07777 0.07932 0.08035 1 20
  29. save(C:/Documents and Settings/sbadamakis/Desktop/model_4/output1/log.odc)
  30. save(C:/Documents and Settings/sbadamakis/Desktop/model_4/output1/log.txt)
  31. So far so good. After the end of the last line of the log file, WinBUGS should close and the bugs function in R should return the Markov chain values of the "beta" parameters. The problem is that it doesn't and WinBUGS stays infinitely open. This is a big problem as I have written a code in R and I want to call the bugs function several times. Do you know if there's an option in the bugs function in R to FORCE WinBUGS to close?
  32. Furthermore, some other times (the same code!!!) produces the following TRAP message
  33. undefined real result
  34. GraphStack.Node.Value [00000C9AH]
  35. .i INTEGER 6
  36. .j INTEGER 2
  37. .k INTEGER 1
  38. .node GraphStack.Node [0138C5D0H]
  39. .op INTEGER 6
  40. .p GraphNodes.Node [01544D30H]
  41. .top INTEGER 0
  42. .work ARRAY 10 OF REAL
  43.    [0] REAL inf   [1] REAL inf   [2] REAL inf   [3] REAL 1.30212336033939   [4] REAL 4.534462964264759   [5] REAL 1.769649991139459E+167   [6] REAL 1.792592453177908E-307   [7] REAL 9.94060079432588E-321   [8] REAL 5.474495960374562E+67   [9] REAL 5.257527858867595E-308
  44. MonitorsSamples.StdMonitor.Update [0000023DH]
  45. .blocks POINTER NIL
  46. .i INTEGER 1655837286
  47. .index INTEGER 7
  48. .monitor MonitorsSamples.StdMonitor [02155B50H]
  49. .numBlocks INTEGER 0
  50. .value REAL 1.0

  51. SamplesMonitors.Monitor.Update [0000091BH]
  52. .chain INTEGER 0
  53. .i INTEGER 4480
  54. .monitor SamplesMonitors.Monitor [01C0A4E0H]
  55. .size INTEGER 6780

  56. SamplesIndex.Monitor.Update [0000030CH]
  57. .chain INTEGER 0
  58. .cursor SamplesIndex.List [01AB2E30H]
  59. .monitor SamplesIndex.Monitor [01C59510H]
  60. .sampleMonitor SamplesMonitors.Monitor [01C0A4E0H]
  61. UpdaterActions.UpdateMonitors [0000011CH]
  62. .chain INTEGER 0
  63. .monitor UpdaterActions.Monitor [01C59510H]
  64. BugsCmds.Action.Step [00000BCAH]
  65. .a BugsCmds.Action [011D40C0H]
  66. .chain INTEGER 0
  67. .i INTEGER 8
  68. .j INTEGER 1000
  69. .numChains INTEGER 1

  70. BugsCmds.Action.Do [00000C58H]
  71. .a BugsCmds.Action [011D40C0H]
  72. .elapsedTime LONGINT 62EC21F162EB0384H
  73. .profileList ARRAY 2024 OF CHAR "" ...
  74. .res INTEGER 1635734111
  75. .s ARRAY 120 OF CHAR 3X ...

  76. Services.Exec [00000136H]
  77. .a Services.Action [011D40C0H]
  78. .t POINTER [62EB0384H]

  79. Services.IterateOverActions [000002F4H]
  80. .p Services.Action [011D40C0H]
  81. .t POINTER NIL
  82. .time LONGINT 300843187

  83. Services.StdHook.Step [0000034DH]
  84. .h Services.StdHook [0101E380H]
  85. HostWindows.Idle [00004A86H]
  86. .focus BOOLEAN FALSE
  87. .tick Controllers.TickMsg Fields
  88. .w HostWindows.Window NIL
  89. HostMenus.TimerTick [00003422H]
  90. .lParam INTEGER 0
  91. .ops Controllers.PollOpsMsg Fields
  92. .wParam INTEGER 1
  93. .wnd INTEGER 1770006
  94. Kernel.Try [00003A61H]
  95. .a INTEGER 1770006
  96. .b INTEGER 1
  97. .c INTEGER 0
  98. .h PROCEDURE HostMenus.TimerTick
  99. HostMenus.ApplWinHandler [00003841H]
  100. .Proc PROCEDURE NIL
  101. .hit BOOLEAN FALSE
  102. .lParam INTEGER 0
  103. .message INTEGER 275
  104. .res INTEGER 4243644
  105. .s ARRAY 256 OF SHORTCHAR "ˉB", 1X ...
  106. .w INTEGER 2147348480
  107. .wParam INTEGER 1
  108. .wnd INTEGER 1770006
  109. <system>   (pc=7E418733H,  fp=0022FB84H)<system>   (pc=7E418815H,  fp=0022FBECH)<system>   (pc=7E4189CCH,  fp=0022FC4CH)<system>   (pc=7E4196C6H,  fp=0022FC5CH) HostMenus.Loop [00003BDEH]
  110. .done BOOLEAN FALSE
  111. .f SET {0..5}
  112. .n INTEGER 0
  113. .res INTEGER 0
  114. .w HostWindows.Window NIL
  115. Kernel.Start [00002B8CH]
  116. .code PROCEDURE HostMenus.Loop
  117. Is there anyone who can explain what does this mean and how to understand trap messages? For me, it seems that the problem lies here:
  118. .work ARRAY 10 OF REAL
  119.    [0] REAL inf   [1] REAL inf   [2] REAL inf   [3] REAL 1.30212336033939   [4] REAL 4.534462964264759   [5] REAL 1.769649991139459E+167   [6] REAL 1.792592453177908E-307   [7] REAL 9.94060079432588E-321   [8] REAL 5.474495960374562E+67   [9] REAL 5.257527858867595E-308
复制代码

Notes:

  • I am running multilevel models for small area estimation and the above problems seem to appear only with the spatial random effects model. The spatial and non-spatial random effects model seems to behave properly without any problems.
  • The program was working fine for more than 500000 iterations withoud trap messages.
二维码

扫码加我 拉你入群

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

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

关键词:Undefined R2WinBUGS Defined winbugs WINBUG understand command loading initial change

沙发
Lisrelchen 发表于 2014-6-26 21:22:01
Without having your model file etc,  I can guess that you have some division by almost zero from sampling from some distribution that may return some extremely small values close to zero.

藤椅
Lisrelchen 发表于 2014-6-26 21:24:33
Do you know if there's an option in the bugs function in R to FORCE WinBUGS to close?
You can close WinBUGS and everything should be fine - or just set debug = FALSE rather than debug = TRUE in your bugs() call.

板凳
scure 发表于 2014-6-28 10:27:25
Most of this type problems come from the prior. Check whether your prior range is larger than your data.
已有 1 人评分论坛币 收起 理由
Nicolle + 24 鼓励积极发帖讨论

总评分: 论坛币 + 24   查看全部评分

报纸
scure 发表于 2014-6-28 11:01:28
scure 发表于 2014-6-28 10:27
Most of this type problems come from the prior. Check whether your prior range is larger than your d ...
The BUGS mannual also provides other explanations for this problem. You can check it yourself.
http://mathstat.helsinki.fi/open ... g.html#TrapMessages

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

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