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. -- Paul E. Johnson Professor, Political Science 1541 Lilac Lane, Room 504 University of Kansas
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. ----------------------------------------------------------------------
Gregor GORJANC wrote:> Hello Jun, > > 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. > > > It would be very nice, if you would consider to port new funcionality in > rbugs to R2WinBUGS. I thought that this was your intention, when > wine part was added to R2WinBUGS. I do appreciate your package, > but find it weird to have two packages i.e. R2WinBUGS and rbugs for > exactly the same task. The issue with all this packages is really getting > very comples, now that BRugs is also availabe.>> Please take this only as a humble suggestion.Yes, you got the point. The way to go is BRugs, obviously, because it *includes* BUGS in R rather than having a very cryptic interface like R2WinBUGS that makes real interaction impossible. Unfortunately, it is still impossible (for BRugs/R) to link against the bugs.so under Linux, AFAIK. Hence we have to stay with R2WinBUGS/rbugs there for some time. Under Windows, I do not use R2WinBUGS anymore, but some people are still really keen on it, hence we have not withdrawn the support so far. Uwe Ligges> Looking forward to hear from you. > > -- > 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. > ---------------------------------------------------------------------------------------------------- >
Hello Paul,> Wow! That was quick. > > One more thing would make my R2WinBUGS experience more perfect. I > wish the "bugs" function explained how the user can write out the > model.txt file from within the R code itself, rather than taking the > current advice of creating it separately. The process now escribed in > "bugs" is: > > 1. Write a WinBUGS model in a ASCII file. > 2. Go into R. > > I don't know what the best way to create model.txt might be, but this > does work, and maybe you have even better examples to show: > > myTextExample <- c(" model { > for (j in 1:J){ > y[j] ~ dnorm (theta[j], tau.y[j]) > theta[j] ~ dnorm (mu.theta, tau.theta) > tau.y[j] <- pow(sigma.y[j], -2) > } > mu.theta ~ dnorm (0.0, 1.0E-6) > tau.theta <- pow(sigma.theta, -2) > sigma.theta ~ dunif (0, 1000) > } > ") > > zz <- file("model.txt","w") > writeLines(myTextExample,con=zz) > close(zz) > > The only dicey part here is that the user might save the model in the > wrong directory, but I don't see what prevents that with the current > advice in "bugs" > > I suggest this because it allows the creation of one file working > examples in R2WinBUGS. For the teaching objective, this simplifies > things a lot!Perhaps you might try my function, which does this exactly as you proposed. I added also a print function so you can print model nicely also in R. You can find documentation here http://www.bfro.uni-lj.si/MR/ggorjan/software/R/ggmisc/ggmiscHtml/bugsModel.html and the function itself lives in my offCRAN package ggmisc, which you can grab at http://www.bfro.uni-lj.si/MR/ggorjan/software/R/ggmisc.tar.gz I already proposed this to Uwe, but he did not find it enough "interesting" to include it into the R2WinBUGS. Anyway, Jouni Kerman, has written even better function - fitbugs(). Look at link bellow for more. I hope fitbugs() will make it into one of next releases of R2WinBUGS. http://www.stat.columbia.edu/~kerman/Software/index.html> > > On 5/4/06, Uwe Ligges <ligges at statistik.uni-dortmund.de> wrote: > >>> Paul Johnson wrote: >>> >> >>>> > Hello, and thanks for the many very rapid responses to my requests for >>>> > R/WinBUGS conversation. >>>> > >>>> > I do not know how to build OpenBUGS in linux, but will snoop around >>>> > and see if I can't figure out what's wrong with linking R to BRugs.so. >>>> > >>>> > In the meanwhile... >>>> > >>>> > While we are on the linux/bugs topic, can I please ask for a fix in >>>> > R2WinBUGS? On my system, the script.txt file is written into the >>>> > WinBUGS directory,where the user does not ordinarily have write >>>> > permissions. If script.txt could be written with the other temporary >>>> > files, this would be solved. >> >>> >>> Will be fixed for the next release. >>> We should also add some option to disable running bugs.update.settings() >>> which really requires write access in the WinBUGS directory.-- 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.