[R] Making R talk to Win/OpenBUGS in Linux (again)

Paul Johnson pauljohn32 at gmail.com
Mon May 1 20:38:39 CEST 2006


Dear Jun:

How about telling us which version of Linux you use and how you make
linbugs run?  As far as I can tell, the OpenBUGS people have
intentionally removed linbugs from their version 2.2.  That leaves us
with various scripts that people have posted & tried, none work for
me.  Fedora Core 5, I cannot get any of the linbugs scripts that are
floating around to work.

I tried re-building the program thus:


# gcc -o cbugs CBugs.c  -ldl

That creates an executable cbugs, but there is no joy for me.

$ ./cbugs
failed to install signal
32
failed to install signal
33

****
* BlackBox
* illegal memory read [ad = 00000000]
- HostFiles.NewFileRef  (pc=00000D9B, fp=BFC73BE4)
- HostFiles.OpenFile  (pc=00000E0E, fp=BFC73BFC)
- HostFiles.Directory.Old  (pc=000029B2, fp=BFC73EA4)
- StdLoader.ThisObjFile  (pc=0000031D, fp=BFC744C0)
- StdLoader.ReadHeader  (pc=0000075F, fp=BFC746E0)
- StdLoader.LoadMod  (pc=0000107B, fp=BFC747F8)
- StdLoader.LoadMod  (pc=000011E0, fp=BFC74910)
- StdLoader.LoadMod  (pc=000011E0, fp=BFC74A28)
- StdLoader.Hook.ThisMod  (pc=00001355, fp=BFC74A3C)
- Kernel.ThisMod  (pc=00001224, fp=BFC74B58)
- Init.Init  (pc=0000004B, fp=BFC74B70)
- Init.$$  (pc=0000000A, fp=BFC74B80)
****



# export LD_ASSUME_KERNEL=2.4.1


# ./cbugs
./cbugs: error while loading shared libraries: libdl.so.2: cannot open
shared object file: No such file or directory

$ ldd ./cbugs
        linux-gate.so.1 =>  (0x00a2b000)
        libdl.so.2 => /lib/libdl.so.2 (0x00ba9000)
        libc.so.6 => /lib/libc.so.6 (0x00a4d000)
        /lib/ld-linux.so.2 (0x00a2c000)

And after doing that LD_ASSUME_KERNEL thingie, nothing in the shell
works anymore...

$ which cbugs
/usr/bin/which: error while loading shared libraries: libc.so.6:
cannot open shared object file: No such file or directory

On 5/1/06, jun yan <jyan at stat.uiowa.edu> wrote:
> I have used linbugs with the rbugs package for a recent work. It might be
> worthwhile trying.
>
>  Jun
>
>
>
> On 5/1/06, Uwe Ligges <ligges at statistik.uni-dortmund.de>
> wrote:
> > Paul Johnson wrote:
> >
> > > Thank you very much.  With the insertion of WINEPATH declaration, then
> > > the following example program does run.  And really fast, too!
> > >
> > >
> > >
> > >
> > >
> > > library(R2WinBUGS)
> > >
> > > WINEPATH <- "/usr/bin/winepath"
> >
> >
> > Will be fixed in the package real soon now.
> > Gregor, many thanks for the patches.
> >
> > Best,
> > Uwe Ligges
> >
> >
> > >                                         # An example
> model file is given in:
> > > model.file <- system.file(package = "R2WinBUGS", "model", "schools.txt")
> > > # Let's take a look:
> > > file.show(model.file)
> > >
> > > # Some example data (see ?schools for details):
> > > data(schools)
> > > schools
> > >
> > > J <- nrow(schools)
> > > y <- schools$estimate
> > > sigma.y <- schools$sd
> > > data <- list ("J", "y", " sigma.y")
> > > inits <- function(){
> > >     list(theta = rnorm(J, 0, 100), mu.theta = rnorm(1, 0, 100),
> > >         sigma.theta = runif(1, 0, 100))
> > > }
> > > parameters <- c("theta", " mu.theta", "sigma.theta")
> > >
> > >
> > > schools.sim <- bugs(data, inits, parameters, model.file, n.chains = 3,
> > > n.iter = 1000,bugs.directory = "/usr/local/share/WinBUGS14/",
> > > working.directory = "/tmp", clearWD = FALSE, useWINE=T, newWINE=T,
> > > WINE="/usr/bin/wine",WINEPATH=WINEPATH)
> > >
> > >
> > >
> > >
> > > On 4/30/06, Gregor Gorjanc < gregor.gorjanc at gmail.com> wrote:
> > >
> > >>Hello Paul,
> > >>
> > >>thank you very much for this report. You caught a bug in R2WinBUGS that
> > >>was introduced by me. I added support for winepath in 1.1-1 version.
> > >>Since I switch between Windows and Linux I always set WINEPATH and then
> > >>use it in bugs(). That's why I forgot to add it in further calls in
> > >>bugs(). How silly :( This actually means that nobody else beside you
> > >>tried to run R2WinBUGS under Linux. To bad. Please report summary to
> > >>BUGS list as you have also asked there for help and I did not had time
> > >>to answer you. I have been successfully running R2WinBUGS under Linux
> > >>for quite some time now.
> > >>
> > >>Now you have the following options:
> > >>
> > >>A Set WINEPATH before you call bugs()
> > >>
> > >>i.e.
> > >>
> > >>WINEPATH <- "/usr/bin/winepath"
> > >>
> > >>bugs(..., WINEPATH=WINEPATH)
> > >>
> > >>This is the fastest approach for you.
> > >>
> > >>B Apply the following diffs, build and install R2WinBUGS by yourself
> > >>
> > >>I am also sendind them to maintainer of the package. So this should be
> > >>fixed soon also on CRAN. Uwe?
> > >>
> > >>--- R2WinBUGSOrig/R/bugs.R      2006-04-29
> 21:44:59.000000000 +0200
> > >>+++ R2WinBUGS/R/bugs.R  2006-04-30 12:52: 36.000000000 +0200
> > >>@@ -44,7 +44,7 @@
> > >>   } else new.model.file <- model.file
> > >>   bugs.script(parameters.to.save, n.chains, n.iter, n.burnin, n.thin,
> > >>     bugs.directory, new.model.file , debug=debug,
> is.inits=!is.null(inits),
> > >>-    bin = bin, DIC = DIC, useWINE = useWINE, newWINE = newWINE)
> > >>+    bin = bin, DIC = DIC, useWINE = useWINE, newWINE = newWINE,
> > >>WINEPATH=WINEPATH)
> > >>   #if (useWINE && missing(bugs.directory))
> > >>   #  bugs.directory <- winedriveTr(bugs.directory)
> > >>   bugs.run(n.burnin, bugs.directory, WINE = WINE)
> > >>
> > >>--- R2WinBUGSOrig/R/bugs.script.R       2006-04-29
> 21:44: 59.000000000 +0200
> > >>+++ R2WinBUGS/R/bugs.script.R   2006-04-30 12:52:12.000000000 +0200
> > >>@@ -1,7 +1,7 @@
> > >> "bugs.script" <-
> > >> function (parameters.to.save, n.chains, n.iter , n.burnin,
> > >>     n.thin, bugs.directory, model.file, debug=FALSE, is.inits, bin,
> > >>-    DIC = FALSE, useWINE = FALSE, newWINE = FALSE){
> > >>+    DIC = FALSE, useWINE = FALSE, newWINE = FALSE, WINEPATH=NULL){
> > >>
> > >>
> > >>>I'm back!
> > >>>
> > >>>I've just learned that, on a fully updated Fedora Core Linux5 sytem,
> > >>>the working solution to access Winbugs under wine via the R package
> > >>>"rbugs" no longer works.  Here was my last post on this topic (with
> > >>>the formerly working solution) from January.
> > >>>
> > >>>
> http://finzi.psych.upenn.edu/R/Rhelp02a/archive/68497.html
> > >>>
> > >>>Currently, what happens is that WinBUGS starts up, but just sits there
> > >>>doing nothing.  I do not know if the problem is due to a change in
> > >>>wine or rbugs, and since both of them are updated, it is hard to say.
> > >>>I'm thinking it is a wine or perhaps even a kernel related problem.
> > >>>Inside WinBUGS running under wine, it does not even work to manually
> > >>>open the bugs.script file and then choose "Model/Script".  it just
> > >>>returns a screen full of errors saying the commands fail.  I don't
> > >>>think rbugs gets even that far, however, since the WinBUGS window does
> > >>>pop up, but nothing happens.
> > >>>
> > >>>rbugs has been retooled to emphasize use of linbugs, the
> > >>>OpenBUGS-based thing for linux, but I can't get linbugs to run at all
> > >>>on my system, and the linbugs program itself appears to have been
> > >>>removed from OpenBUGS distribution altogether. (I'm following that
> > >>>with separate email to the OpenBUGS group).
> > >>>
> > >>>I think JAGS is the right long term solution, but currently I'm in the
> > >>>middle of a semester trying to teach about Bayesian stats and the
> > >>>students have some familiarity with WinBUGS and I'm interested in
> > >>>making it work. So while I'm learning more about JAGS and the bayesmix
> > >>>package that supports access to it from R, I still would like a way to
> > >>>interact with Winbugs through Wine.
> > >>>
> > >>>If anybody has rbugs working in current Linux, please tell me
> > >>>how--give me a working example?
> > >>>
> > >>>In the meanwhile, I've noticed that nightly updates have successfully
> > >>>installed R2WinBUGS on linux systems and I've got a small test case
> > >>>that I'd like to ask about.  Since rbugs is a linux adaptation of
> > >>>R2WinBUGS, and R2WinBUGS is now buildable on Linux, it looks like
> > >>>R2WinBUGS may be the way to go.  But it fails.  The error centers
> > >>>around the "WINEPATH" setting.  I've learned that wine has a function
> > >>>"winepath" that returns information that programs can use, and I've
> > >>>fiddled this lots of ways, but it fails, saying
> > >>>
> > >>>
> > >>>Error in paste(WINEPATH, "-w", x) : object "WINEPATH" not found
> > >>>library(R2WinBUGS)
> > >>>
> > >>>I hope that by giving you this small not-yet-working example, you can
> > >>>spot where I'm going wrong.
> > >>>
> > >>>##Paul Johnson 2006-04-29
> > >>>
> > >>>
> > >>>library(R2WinBUGS)
> > >>># Copied from Prof Andrew Gelman's example
> > >>>model.file <- system.file(package = "R2WinBUGS", "model",
> "schools.txt")
> > >>>#
> > >>>file.show(model.file)
> > >>>data(schools)
> > >>>schools
> > >>>
> > >>>J <- nrow(schools)
> > >>>y <- schools$estimate
> > >>>sigma.y <- schools$sd
> > >>>data <- list ("J", "y", "sigma.y")
> > >>>inits <- function(){
> > >>>    list(theta = rnorm(J, 0, 100), mu.theta = rnorm(1, 0, 100),
> > >>>        sigma.theta = runif(1, 0, 100))
> > >>>}
> > >>>parameters <- c("theta", "mu.theta", "sigma.theta")
> > >>>
> > >>>
> > >>>schools.sim <- bugs(data, inits, parameters, model.file, n.chains = 3,
> > >>>n.iter = 1000,bugs.directory = "/usr/local/share/WinBUGS14/",
> > >>>working.directory = "/tmp", clearWD = FALSE, useWINE=T, newWINE=T,
> > >>>WINE="/usr/bin/wine",WINEPATH="/usr/bin/winepath")
> > >>>
> > >>>
> > >>>
> > >>>I do have the binary "/usr/bin/winepath", but can't tell how to give
> > >>>R2WinBUGS what it wants.  Many failed efforts below:
> > >>>
> > >>>
> > >>>
> > >>>
> > >>>>>schools.sim <- bugs(data, inits, parameters, model.file, n.chains =
> 3, n.iter = 1000,bugs.directory = "/usr/local/share/WinBUGS14/",
> working.directory = "/tmp", clearWD = FALSE, useWINE=T, newWINE=T,
> WINE="/usr/bin/wine",WINEPATH="/usr/bin/")
> > >>>
> > >>>Error in paste(WINEPATH, "-w", x) : object "WINEPATH" not found
> > >>>
> > >>>
> > >>>>> schools.sim <- bugs(data, inits, parameters, model.file, n.chains =
> 3, n.iter = 1000,bugs.directory = "/usr/local/share/WinBUGS14/",
> working.directory = "/tmp", clearWD = FALSE, useWINE=T, newWINE=T,
> WINE="/usr/bin/wine")
> > >>>
> > >>>Error in if (!nchar(WINEPATH)) { : argument is of length zero
> > >>>
> > >>>
> > >>>>> schools.sim <- bugs(data, inits, parameters, model.file, n.chains =
> 3, n.iter = 1000,bugs.directory = "/usr/local/share/WinBUGS14/",
> working.directory = "/tmp", clearWD = FALSE, useWINE=T, newWINE=T,
> WINE="/usr/bin/wine",WINEPATH="/usr/bin")
> > >>>
> > >>>Error in paste(WINEPATH, "-w", x) : object "WINEPATH" not found
> > >>>
> > >>>
> > >>>
> > >>>I know there are many unknowns here, but hope somebody has at least
> > >>>one working example that we can build on.
> > >>
> > >>
> > >>--
> > >>Lep pozdrav / With regards,
> > >>    Gregor Gorjanc
> > >>
> >
> >>----------------------------------------------------------------------
> > >>University of Ljubljana     PhD student
> > >>Biotechnical Faculty
> > >>Zootechnical Department     URI:
> http://www.bfro.uni-lj.si/MR/ggorjan
> > >>Groblje 3                   mail: gregor.gorjanc <at> bfro.uni-lj.si
> > >>
> > >>SI-1230 Domzale             tel: +386 (0)1 72 17 861
> > >>Slovenia, Europe            fax: +386 (0)1 72 17 888
> > >>
> >
> >>----------------------------------------------------------------------
> > >>"One must learn by doing the thing; for though you think you know it,
> > >> you have no certainty until you try." Sophocles ~ 450 B.C.
> >
> >>----------------------------------------------------------------------
> > >>
> > >>
> > >>
> > >
> > >
> > >
> > > --
> > > Paul E. Johnson
> > > Professor, Political Science
> > > 1541 Lilac Lane, Room 504
> > > University of Kansas
> > >
> > > ______________________________________________
> > > R-help at stat.math.ethz.ch mailing list
> > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
> >
> > ______________________________________________
> > R-help at stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
> >
>
>


--
Paul E. Johnson
Professor, Political Science
1541 Lilac Lane, Room 504
University of Kansas




More information about the R-help mailing list