[R] R2WinBUGS: Error in bugs(program="openbugs") but not openbugs()

Uwe Ligges ligges at statistik.tu-dortmund.de
Sat Nov 13 18:05:54 CET 2010


I found the problem which is a scoping issue in BRugs::bugsData() and 
will fix it for the next release.

For now, you can workaround by calling your parameters (in this case 
particularly beta) with a names that are different from R function names 
(e.g. call it beta1).

Best wishes,
Uwe






On 11.11.2010 17:48, Yuelin Li wrote:
> 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.
>
>   >  help(bugs)
>   ... either winbugs/WinBUGS or openbugs/OpenBUGS, the latter
>   makes use of function openbugs and requires the CRAN package
>   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.
>
> Yuelin.
>
> ------- R file ---------
> require(R2WinBUGS)
> require(BRugs)
> # Example in Albert (2007).  Bayesian Computation with R.  Springer.
> # pp. 237-238.  Prior = beta(0.5, 0.5), observe Binom(n, p)
> # y=7 successes out of a sample of n=50.  Estimate p.
> y<- 7
> n<- 50
> alpha<- 1.0
> beta<- 1.0
> data<- list("y", "n", "alpha", "beta")
> inits<- function() { list(p = runif(1)) }
> param<- "p"
> # this works
> Albert.bugs<- openbugs(data=data, inits=inits, parameters.to.save=param, model.file = "C:/tryR/WinBUGS/Albert11.txt", n.chains=3, n.iter=500)
> print(Albert.bugs, digits.summary = 4)
> # this fails
> 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")
>
> ------- BUGS file: Albert11.txt ------
> model
> {
> y ~ dbin(p, n)
> p ~ dbeta( alpha, beta )
> }
>
>
>
>       =====================================================================
>
>       Please note that this e-mail and any files transmitted with it may be
>       privileged, confidential, and protected from disclosure under
>       applicable law. If the reader of this message is not the intended
>       recipient, or an employee or agent responsible for delivering this
>       message to the intended recipient, you are hereby notified that any
>       reading, dissemination, distribution, copying, or other use of this
>       communication or any of its attachments is strictly prohibited.  If
>       you have received this communication in error, please notify the
>       sender immediately by replying to this message and deleting this
>       message, any attachments, and all copies and backups from your
>       computer.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list