[R] Making R talk to Win/OpenBUGS in Linux (again)
Paul Johnson
pauljohn32 at gmail.com
Sat Apr 29 21:49:32 CEST 2006
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
More information about the R-help
mailing list