2008-10-08

Runnning R2WinBUGS on Mac

New Mac computers/laptops (I do not know the details) are shipped with Intel processor. This brings the possibility to install a lot of UNIX/Linux software since Mac OS X is essentially a desktop Linux - I am again stating that I do not know the details about this since I can not afford a Mac.

Why is this important? WinBUGS is a great software for running Bayesian analyses. The name WinBUGS comes from two "parts": BUGS means Bayesian analysis Using Gibbs Sampling (though also other samplers are implemented), while Win corresponds to MS Windows. Therefore, one can natively run WinBUGS only on MS Windows. I personaly like the R2WinBUGS package, which allows one to run WinBUGS (and OpenBUGS, a new incarnation of BUGS software) directly from R. This approach is to a large extent promoted by Andrew Gelman in his "ARM book". Another possibilities are BRugs (using BUGS as directly linked with R - I can not find the link to BRugs package, since it is now in CRAN Extra repository) and rbugs (support for Linux systems with OpenBugs is emphasized) and the following two packages for interfacing JAGS (Just Another Gibbs Sampler): rjags and runjags.

It is quite some time since we managed to "tweak" R2WinBUGS so that it works also on Linux like systems that have installed wine emulator. One just needs to install R, wine and WinBUGS to "C:/Program Files/WinBUGS14" and the bugs() function will work out of the box on Linux!

This week as well as before we had a long discussion about running R2WinBUGS on new Macs with Intel processors. Rodney Sparapani found out that the following is needed:
schools.sim <-  bugs(data, inits, parameters, model.file,      n.chains=3, n.iter=5000,      bugs.directory="/Applications/WinBUGS14",      working.directory=".",      WINE="/Applications/Darwine/Wine.bundle/Contents/bin/wine",      WINEPATH="/Applications/Darwine/Wine.bundle/Contents/bin/winepath") 
Some notes are needed:
  • bugs.directory="/Applications/WinBUGS14" - this seems to be a reasonable default for installation of WinBUGS on Mac, however, we will not "hardwire" this into the R2WinBUGS code since this place can vary a lot between different operation systems and locales

  • working.directory="." - this is needed for the moment, since it seems that Mac launches wine emulator as another user, who does not have a permission to write to a temporary folder created by tempdir() by R; update on 2009-03-25, setting working.directory to "." will not be needed anymore in R2WinBUGS version 2.1-13 and later

  • WINE="/Applications/Darwine/Wine.bundle/Contents/bin/wine" and WINEPATH="/Applications/Darwine/Wine.bundle/Contents/bin/winepath" are paths to wine and winepath binaries that we use in R2WinBUGS; unfortunatelly we can not find these programatically from R as it is the case in UNIX/Linux - if one cretaes links to /usr/bin or /usr/local/bin, there is no need to set this two arguments in bugs()

30 comments:

Anonymous said...

I'm working on the same problem with a new Power Mac and R 2.7.2 for the Mac. I get the following error with the "Schools" example. Does this look familiar?

schools.sim <-
bugs(data, inits, parameters, model.file,
n.chains=3, n.iter=5000,
bugs.directory="/Applications/WinBUGS14",
working.directory=".",
WINE="/Applications/Darwine/Wine.bundle/Contents/bin/wine", WINEPATH="/Applications/Darwine/Wine.bundle/Contents/bin/winepath")

sh: /Applications/Darwine/Wine.bundle/Contents/bin/winepath: Not a directory
(Repeated 9 more times)
/bin/sh: /Applications/Darwine/Wine.bundle/Contents/bin/wine: Not a directory
Error in bugs.run(n.burnin, bugs.directory, WINE = WINE, useWINE = useWINE, :
Look at the log file and
try again with 'debug=TRUE' to figure out what went wrong within Bugs.


Do you have any ideas? Thanks!

Gorjanc Gregor said...

Hi JHM,

It seems that you do not have wine and winepath in the specified paths. Can you check this with "file browser"?

Can you also post the result of traceback() issued after the failure of bugs().

Anonymous said...

Thank you for replying. I am still having problems with the schools example in R, but I found an alternate solution to my problem. I used WineHelper in Darwine to run WinBUGS14.exe. Then, within WinBUGS, I ran a script file using commands such as check('g:/Code.txt'), where "g" is the virtual drive that Darwine assigned to my WinBUGS data analysis file folder. This solution will be adequate until I learn more about the Mac and R.

Gorjanc Gregor said...

Hi JHM,

I am glad you solved your problem with a tweak. However, I would really like to get some more info about your setting. Mac support is not ideal, because developers of R2WinBUGS do not use Mac and is therefore hard to solve the problems.

Can you please check if you have the following two files /Applications/Darwine/Wine.bundle/Contents/bin/wine and /Applications/Darwine/Wine.bundle/Contents/bin/winepath

If above is negative, can you find (search for) them on your computer?

Anonymous said...

Thank you for your interest in my problem. Even though I have learned to use WinBUGS, I am still learning about R and about file structures on the Mac, so I appreciate your patience.

I can double-click on the "Macintosh HD" icon on my desktop to open Finder, then double-click on Applications, then Darwine. By default, four icons show up against a black background, representing Darwine (again), Applications, TRiX, and a Readme.txt file. By switching to the list view and opening that second Darwine folder, I can see a ReadMe.html file, a Sample WineLib Applications folder, a Wine.bundle icon (a box), and a WineHelper application. When I double-click on the Wine.bundle icon, I get a message saying that there is no default application specified to open the document Wine.bundle. At that point, I can choose an application or cancel. I don't know which application could be used to open the bundle.

I found another way to search for the bin files we need for R2WinBUGS. Using /Applications/Darwine/Darwine/Sample WineLib Applications/winefile.exe, I opened the winefile.exe application. There, I found the following pathway:
D:\Darwine\Wine.bundle\Contents\bin. At that level, I found the files "wine" (size 778 b) and "winepath" (size 1602 b). Both of those files had icons that resembled text file icons, but I could not open either of those files by double-clicking, and I could not copy them to the Mac Desktop. During the same session, I found the same directory structure with the wine and winepath files at f:\Darwine\Wine.bundle\Contents\bin and at /Volumes/Darwine/Darwine/Wine.bundle/Contents/bin . I tried running the "schools" example for bugs() in R using these path specifications [for example, WINE="d:/Volumes/Darwine/Darwine/Wine.bundle/Contents/bin/wine"], but those did not work either.

There is one simple possibility that we may not have considered. I am not using R for Windows through Wine; instead, I am using R 2.7.2 GUI 1.25 for Mac OS X Cocoa GUI written by Simon Urbanek and Stefano M. Iacus. I don't know if that makes a difference.

Thank you again! Jay

Gorjanc Gregor said...

Hi JHM!

I will start with you second note. Yes, I assume you are using the native R on Mac OS X i.e. Cocoa GUI written by Simon Urbanek and Stefano M. Iacus. Though, you could also run R via wine, but there is no need to do that.

From your description of the "search for wine saga" I think that you should try to use bugs() with the following arguments

WINE="/Applications/Darwine/Darwine/Wine.bundle/Contents/bin/wine"

WINEPATH="/Applications/Darwine/Darwine/Wine.bundle/Contents/bin/winepath"

It seems that the installation step has been "a bit weird". Please report what happens.

Anonymous said...

Gregor,

I tried using the WINE and WINEPATH statements that you suggested, but I got the same error messages about a missing directory.

I will try something new. I have been working with a pre-compiled version of Darwine that I obtained from www.kronenberg.org/darwine. I believe that something in the "secret" Wine.bundle folder may be causing the problem. I have directions from the article "Running WinBUGS on Mac OS X using Wine" by Tom Palmer that tell how to build a Darwine disk image on my computer from source code. I will try that next, but this will take some time. The first step requires the download of Apple's Xcode development environment, which is a 1-GB file. I will try installing it using the newest version of Wine (1.1.6). Hopefully, that will help.

Anonymous said...

Gregor,

Success! I did not have to build a version of Darwine after all. Instead, I found that supplying FEWER options to the bugs() function did the job. This was using R for the Mac and version 1.1.6 of Darwine that I obtained from www.kronenberg.org/darwine.

This command:

schools.sim <- bugs(data, inits, parameters, model.file,n.chains=3, n.iter=5000,bugs.directory="/Applications/WinBUGS14",useWINE=TRUE,working.directory=".")

produced the following error or warning messages:

fixme:keyboard:RegisterHotKey (0x1002a,13,0x00000002,3): stub
fixme:ole:GetHGlobalFromILockBytes cbSize is 13824
err:ole:CoGetClassObject class {0003000a-0000-0000-c000-000000000046} not registered
err:ole:CoGetClassObject class {0003000a-0000-0000-c000-000000000046} not registered
err:ole:CoGetClassObject no class object {0003000a-0000-0000-c000-000000000046} could be created for context 0x3

However, it did make the schools.sim object.

> schools.sim
Inference for Bugs model at "/Library/Frameworks/R.framework/Resources/library/R2WinBUGS/model/schools.txt", fit using WinBUGS,
3 chains, each with 5000 iterations (first 2500 discarded), n.thin = 7
n.sims = 1074 iterations saved
mean sd 2.5% 25% 50% 75% 97.5% Rhat n.eff
theta[1] 11.7 8.8 -1.4 6.4 10.3 15.8 32.4 1 1100
theta[2] 7.8 6.6 -5.0 3.4 7.8 11.9 20.2 1 1100
theta[3] 6.5 7.9 -11.0 1.9 7.0 11.2 21.5 1 1100
theta[4] 8.0 6.7 -4.6 3.7 8.0 12.4 21.9 1 530
theta[5] 5.4 6.5 -8.3 1.5 5.8 9.8 17.3 1 1100
theta[6] 6.3 6.7 -8.2 2.2 6.8 10.7 18.5 1 1100
theta[7] 10.7 7.4 -1.7 5.8 9.9 14.4 27.4 1 1100
theta[8] 8.5 7.7 -6.0 3.9 8.2 12.6 25.3 1 1100
mu.theta 8.0 5.3 -1.9 4.9 8.1 11.2 18.1 1 1100
sigma.theta 6.8 6.2 0.2 2.4 5.2 9.5 23.1 1 610
deviance 60.6 2.2 57.2 59.1 60.2 61.6 65.7 1 540
(more output with DIC deleted)

I don't know if it is important to track down the source of the errors or to try to fix them. For now, I am happy that this works! Thank you again for helping me find a way to do it.

Gorjanc Gregor said...

Hi JHM,

Sorry for late reply - I was out of the office! I am glad you solved your problem. I am surprised that the paths I suggested did not work - that was the "correct" path given your description.

It is also odd that using Darwine from Mike solved the problem completely. I guess that Mike has bundled wine in such a way that "internal unix" is aware of the place of wine and winepath binaries . Why is that? If a user does not set WINE and WINEPATH arguments, the code in bugs() tries hard (using R2WinBUGS:::findUnixBinary function) to find them. It goes like this (returning the result on the first success):

* check if there is x (WINE or WINEPATH) environmental variable

* check if there is /usr/bin/x

* try with which x

* try with locate x

Can you please start a "unix" console/terminal and test the following commands (without initial star character!) - so that we can know what is really going on:

* echo $WINE

* echo $WINEPATH

* ls -l /usr/bin/wine

* ls -l /usr/bin/winepath

* which wine

* which winepath

* locate wine

* locate winepath

Thank you!

Anonymous said...

I'm having the same kind of error message:

fixme:ntdll:server_ioctl_file Unsupported ioctl 24000 (device=2 access=1 func=0 method=0)
fixme:keyboard:RegisterHotKey (0x1002a,13,0x00000002,3): stub
fixme:ole:GetHGlobalFromILockBytes cbSize is 13824
err:ole:CoGetClassObject class {0003000a-0000-0000-c000-000000000046} not registered
err:ole:CoGetClassObject class {0003000a-0000-0000-c000-000000000046} not registered
err:ole:CoGetClassObject no class object {0003000a-0000-0000-c000-000000000046} could be created for context 0x3
fixme:ntdll:server_ioctl_file Unsupported ioctl 24000 (device=2 access=1 func=0 method=0)
fixme:ntdll:server_ioctl_file Unsupported ioctl 24000 (device=2 access=1 func=0 method=0)
fixme:ntdll:server_ioctl_file Unsupported ioctl 24000 (device=2 access=1 func=0 method=0)
fixme:ntdll:server_ioctl_file Unsupported ioctl 24000 (device=2 access=1 func=0 method=0)

I have done the unix commands you suggested, but nothing is returned. ls says there is no such directory, echo says nothing, as which says and locate gives me file locations with 'wine' in the name but unrelated to the wine we are talking about.

I precise I have installed Darwine as a dragged and dropped program from a disk image.

Thanks for your help! And thanks so much for this already very useful post!

Gorjanc Gregor said...

The errors (that JHM reported) i.e.

fixme:keyboard:RegisterHotKey (0x1002a,13,0x00000002,3): stub
fixme:ole:GetHGlobalFromILockBytes cbSize is 13824
err:ole:CoGetClassObject class {0003000a-0000-0000-c000-000000000046} not registered
err:ole:CoGetClassObject class {0003000a-0000-0000-c000-000000000046} not registered
err:ole:CoGetClassObject no class object {0003000a-0000-0000-c000-000000000046} could be created for context 0x3

are harmless, but yours are not. It looks like to me that you have succefully started wine, but that something is wrong.

You get this error after bugs() function? Did the WinBUGS application start?

Which version of Darwine do you have?

What is the output of locate and/or which?

Anonymous said...

I have Darwine 1.1.6 put into Applications folder (I downloaded the disk image, and dragged the program, nothing else)

When I launch R, I have the following command / output:

> schools.sim <-
+ bugs(data, inits, parameters, model.file,
+ n.chains=3, n.iter=5000,
+ bugs.directory="/Applications/WinBUGS14",
+ working.directory=".",
+ WINE="/Applications/Darwine/Wine.bundle/Contents/bin/wine",
+ WINEPATH="/Applications/Darwine/Wine.bundle/Contents/bin/winepath")
fixme:ntdll:server_ioctl_file Unsupported ioctl 24000 (device=2 access=1 func=0 method=0)
fixme:keyboard:RegisterHotKey (0x1002a,13,0x00000002,3): stub
fixme:ole:GetHGlobalFromILockBytes cbSize is 13824
err:ole:CoGetClassObject class {0003000a-0000-0000-c000-000000000046} not registered
err:ole:CoGetClassObject class {0003000a-0000-0000-c000-000000000046} not registered
err:ole:CoGetClassObject no class object {0003000a-0000-0000-c000-000000000046} could be created for context 0x3
fixme:ntdll:server_ioctl_file Unsupported ioctl 24000 (device=2 access=1 func=0 method=0)
fixme:ntdll:server_ioctl_file Unsupported ioctl 24000 (device=2 access=1 func=0 method=0)
fixme:ntdll:server_ioctl_file Unsupported ioctl 24000 (device=2 access=1 func=0 method=0)
fixme:ntdll:server_ioctl_file Unsupported ioctl 24000 (device=2 access=1 func=0 method=0)
fixme:ntdll:server_ioctl_file Unsupported ioctl 24000 (device=2 access=1 func=0 method=0)
fixme:ntdll:server_ioctl_file Unsupported ioctl 24000 (device=2 access=1 func=0 method=0)
fixme:ntdll:server_ioctl_file Unsupported ioctl 24000 (device=2 access=1 func=0 method=0)
fixme:ntdll:server_ioctl_file Unsupported ioctl 24000 (device=2 access=1 func=0 method=0)
fixme:ntdll:server_ioctl_file Unsupported ioctl 24000 (device=2 access=1 func=0 method=0)
fixme:ntdll:server_ioctl_file Unsupported ioctl 24000 (device=2 access=1 func=0 method=0)
fixme:ntdll:server_ioctl_file Unsupported ioctl 24000 (device=2 access=1 func=0 method=0)
fixme:ntdll:server_ioctl_file Unsupported ioctl 24000 (device=2 access=1 func=0 method=0)
>

WinBUGS starts fine. The log file contains this, so I assume this works:

display(log)
check(Z:/Library/Frameworks/R.framework/Resources/library/R2WinBUGS/model/schools.txt)
model is syntactically correct
data(Z:/Users/Guillaume/Downloads/data.txt)
data loaded
compile(3)
model compiled
inits(1,Z:/Users/Guillaume/Downloads/inits1.txt)
chain initialized but other chain(s) contain uninitialized variables
inits(2,Z:/Users/Guillaume/Downloads/inits2.txt)
chain initialized but other chain(s) contain uninitialized variables
inits(3,Z:/Users/Guillaume/Downloads/inits3.txt)
model is initialized
gen.inits()
command #Bugs:gen.inits cannot be executed (is greyed out)
thin.updater(7)
update(358)
set(theta)
set(mu.theta)
set(sigma.theta)
set(deviance)
dic.set()
update(358)
coda(*,Z:/Users/Guillaume/Downloads/coda)
stats(*)

Node statistics
node mean sd MC error 2.5% median 97.5% start sample
deviance 60.39 2.07 0.07053 57.1 60.08 65.58 359 1074
mu.theta 8.244 5.094 0.2604 -1.01 8.119 19.05 359 1074
sigma.theta 5.847 5.586 0.3184 0.03221 4.503 19.7 359 1074
theta[1] 11.31 8.099 0.3754 -1.533 10.54 30.37 359 1074
theta[2] 7.802 6.002 0.2811 -3.959 7.508 20.52 359 1074
theta[3] 6.41 7.535 0.3389 -10.45 6.611 20.63 359 1074
theta[4] 7.753 6.266 0.2999 -4.65 7.62 21.23 359 1074
theta[5] 5.441 6.346 0.2874 -8.275 5.793 16.58 359 1074
theta[6] 6.64 6.597 0.2526 -8.091 6.668 19.35 359 1074
theta[7] 10.34 6.706 0.3092 -0.2109 9.573 26.92 359 1074
theta[8] 8.591 7.546 0.3323 -5.319 8.277 26.22 359 1074
dic.stats()

DIC
Dbar = post.mean of -2logL; Dhat = -2LogL at post.mean of stochastic nodes
Dbar Dhat pD DIC
y 60.387 57.816 2.570 62.957
total 60.387 57.816 2.570 62.957
history(*,Z:/Users/Guillaume/Downloads/history.odc)

History

save(Z:/Users/Guillaume/Downloads/log.odc)
save(Z:/Users/Guillaume/Downloads/log.txt)


locate wine output is:
/Developer/Documentation/wxWidgets/docs/wine
/Developer/Documentation/wxWidgets/docs/wine/COPYING.LIB
/Developer/Documentation/wxWidgets/docs/wine/changes.txt
/Developer/Documentation/wxWidgets/docs/wine/install.txt
/Developer/Documentation/wxWidgets/docs/wine/licence.txt
/Developer/Documentation/wxWidgets/docs/wine/readme.txt
/Developer/Documentation/wxWidgets/docs/wine/todo.txt
/Library/Dictionaries/New Oxford American Dictionary.dictionary/Contents/Images/bottle (wine bottles).png
/Volumes/Mac Pro HD/Documents/Macintosh/Machines/MacBookPro/Library/Dictionaries/New Oxford American Dictionary.dict/Contents/Images/bottle (wine bottles).png
/Volumes/Mac Pro HD/Documents/Site/SITE/images/news/tiger_wine.jpg
/Volumes/Mac Pro HD/Documents/eBooks/Bibliotheque/References/Computer/php/Scripts and Programs/Unsorted/bookcode/ch12/booksourceUI/Images/winexchange.jpg
/Volumes/Mac Pro HD/Documents/eBooks/Bibliotheque/References/Computer/php/Scripts and Programs/Unsorted/ezShop/zaks/wineries.php3
/Volumes/Mac Pro HD/Documents/eBooks/Bibliotheque/References/Computer/php/Scripts and Programs/Unsorted/ezShop/zaks/wines.php3
/usr/local/texlive/2007/texmf-dist/doc/latex/newlfm/wine.eps
/usr/local/texlive/2007/texmf-dist/doc/latex/newlfm/wine.pdf
/usr/local/texlive/2007/texmf-doc/doc/english/catalogue/entries/winedt.html
/usr/local/texlive/2007/texmf-doc/doc/english/catalogue/entries/winemtex.html

which wine gives nothing.

Thanks for your help on this!

Gorjanc Gregor said...

Hi Anonymous (Guillaume?),

OK, it is good to know that the WinBUGS did start. Given the output you have shown I would conclude that the errors/warnings shown in R are harmless - they are produced by wine, but it seems that the results from your WinBUGS run agree with mine on Windows and Linux - accounting for the "simulation deviations".

The key point on Mac OS X is to specify the location of wine and winepath binaries and it seems that by default (based on two reports!) this shoule be

WINE="/Applications/Darwine/Wine.bundle/Contents/bin/wine",

WINEPATH="/Applications/Darwine/Wine.bundle/Content/bin/winepath"

Anonymous said...

Thanks for your reply. So the results seem to be correct, but we have not removed the error messages. I will keep looking and will let you know if I find something!

Guillaume

Gorjanc Gregor said...

Errors come from running WinBUGS via wine. When I start WinBUGS on Linux (using wine /usr/local/.../WinBUGS14/WinBUGS14.exe) directly from the terminal I also get this kind of errors. This errors are therefore from wine and not from bugs() function!

Anonymous said...

I asked Mike Kronenberg (Darwine provider) about the error we get when launching WinBUGS in Darwine. He says:

(dar)wine still has function calls, that are not/only partially implemented. These throw a "fixme" in the console. But this does not necessarily mean it does not work.If the rest is working OK, just ignore the messages. If not, a future Darwine build might implement the missing/partly implemented feature calls.

So we can consider that R / WinBUGS on the Mac is reasonably working well.

Gorjanc Gregor said...

Thank you for this follow up. I have been using R2WinBUGS on Linux (via wine) for more than a year and occasionally I tested the results on Windows. The results always matched. Therefore I did not care about the errors wine produced. Darwine is just a Mac OS X port of wine so my observations should hold also for Macs.

Anonymous said...

Also, there is something to know when working with R2Winbugs through WINE, is that it seems to dislike spaces in the R working directory.

Gorjanc Gregor said...

It is always good to avoid spaces in pathnames. However, my memory is that wine and WinBUGS work fine with spaces in pathnames, e.g. the default setting bugs.directory="c:/Program Files/WinBUGS14/" works out fo the box on Linux, of course if WinBUGS is installed in the appropriate directory.

gg

Unknown said...

Jarret wrote:

"Some background: I had been running CrossOver, but I deleted it because I had no success with remote X sessions. I installed Darwine (1.0.1 from http://www.kronenberg.org/darwine/) hoping for more success with remote X sessions. Anyway, recently, I was trying R2WinBUGS, and I encountered some behavior that I thought might interest you. In the first attempt below, my locate database was not up-to-date, and it still had many entries related to the recently deleted CrossOver. Evidently, R2WinBUGS was using this database. Why would R2WinBUGS use the locate database when I had supplied the appropriate paths? This was mysterious and frustrating until I found your discussion of this matter. After reading your comments at the link above, I updated the locate database and tried again. Results: much better, though I still get some strange, but apparently harmless messages. The school.sim object seems fine. Finally, I can run WinBUGS in R on my Mac! One question: do you know how to prevent the windows from popping up? I sometimes call winbugs from a loop, and the window overhead seems to slow things down quite a bit."

I replied:

You should specify the path of wine binary directly, i.e., via WINE argument.

Yes, the messages you got in second round are harmless.

Nope, the window always pops up, because WinBUGS is started. To avoid this one should use BRugs (works only wfor MS indows) and/or rjags (never tried it).

Anonymous said...

Thanks for your work! This is great!!! =)

Monica said...

Hi,
I have a similar problem, except "schools.sim" is never created.

I first installed wine via fink, making the path WINE="/sw/bin/wine" and WINEPATH="/sw/bin/winepath"

I thought this might be the problem as fink installs wine v. 1.1.24-100.

I then installed DarWine version 1.0.1. My path is now WINE="/Applications/Darwine/Wine.bundle/Contents/bin/wine" and WINEPATH="/Applications/Darwine/Wine.bundle/Contents/bin/winepath".

When I run bugs() in R, here is the result I get:

schools.sim <- bugs(data, inits, model.file = "/users/mwolfson/Documents/schools.txt", parameters = c("theta", "mu.theta", "sigma.theta"),n.chains = 3, n.iter = 1000,debug=TRUE,bugs.directory = "/Applications/WinBUGS14/",WINE="/Applications/Darwine/Wine.bundle/Contents/bin/wine",WINEPATH="/Applications/Darwine/Wine.bundle/Contents/bin/winepath")

fixme:keyboard:RegisterHotKey (0x10032,13,0x00000002,3): stub
err:ole:CoGetClassObject class {0003000a-0000-0000-c000-000000000046} not registered
err:ole:CoGetClassObject class {0003000a-0000-0000-c000-000000000046} not registered
err:ole:CoGetClassObject no class object {0003000a-0000-0000-c000-000000000046} could be created for context 0x3


It just sits on this and doesn't do anything. WinBUGS opens up alright but I get an X11 "blackbox" pop-up window with the same error messages in it. If I leave this box open, WinBUGS stays open. If I click OKAY, WinBUGS closes. I have waited up to 45 minutes with R seemingly cranking away, but nothing happens and no "schools.sim" ever is created.

If I close out WinBUGS I get a an error message in R:

"Error in bugs.run(n.burnin, bugs.directory, WINE = WINE, useWINE = useWINE, :
Look at the log file and
try again with 'debug=TRUE' to figure out what went wrong within Bugs."

I also tried adding working path ="." and it made no difference.
Also, if I try to click on anything in WinBUGS while it is open (for example, clicking on View -> Log), I get the following error messages in R:

fixme:ole:snapshot_QueryGetData (0x1691d0, 0x1158b54 {cf 000d ptd 0x0 aspect 1 lindex -1 tymed 1})

**repeated several times

and

fixme:ntdll:server_ioctl_file Unsupported ioctl 24000 (device=2 access=1 func=0 method=0)

**also repeated several times

Any help would be much appreciated. Right now my work around is to use R on the Windows side via VMWare, but I actually much prefer the MAC user interface of R.

Gorjanc Gregor said...

Monica,

My current experience with wine on GNU/Linux is that "fixme:..." error/warning messages are harmless. However, it seems that you are facing some problems. All I can say is that the problems you are facing are not due to R, WinBUGS, or R2WinBUGS - you are able to start WinBUGS via wine and it seems that the later is causing problems. You can try this:

1. Use bugs() with argument clearWD=FALSE

2. Start WinBUGS via wine as a standalone application, i.e., forget about R

3. In WinBUGS use the files produced by bugs() in step 1. and try to find out what is the problem

Anonymous said...

For what it's worth, I am in the same situation as Monica. Gregor: I tried your steps 1-3 but could not get any of the .txt files produced by R2WinBUGS to run properly in WinBUGS (via wine). If you have a sec (by the way, thanks for this wonderful post), kindly provide a little more guidance for debugging this latest problem.

thanks,
- eric

Gorjanc Gregor said...

Eric,

Did you set working.directory and clearWD=FALSE? The files (model, data, and inits) should be in the place you defined in working.directory.

Poor Yorick said...

For those who experienced the ole errors, the solution is to install DCOM98.

http://www.ynform.org/w/Pub/WinbugsUnderWine

Anonymous said...

Hello Gregor,

I'm new using MAC and when programming in R appears the following message:
----------------------------------------
WARNING: The locate database (/var/db/locate.database) does not exist.
To create the database, run the following command:

sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist

Please be aware that the database can take some time to generate; once
the database has been created, this message will no longer appear.
----------------------------------------

I run the recommended command and appears another error:
----------------------------------------
Error: unexpected symbol in "sudo launchctl"
----------------------------------------

The graphics are working ok, but I have no outputs.

What can I do?

I appreciate your support.

Alonso.

Gorjanc Gregor said...

Alonso, this seems to be a Mac issue and not R issue! Have you typed some weird character in the terminal - double check character by character.

佳泓 said...

I also have problems with WinBUGS. After downloading WinBUGS and Darwine, I run the schools.R and got the following error message:

> schools.sim <- bugs(data, inits, parameters, model.file='/Applications/WinBUGS14/schools.txt',n.chains=3, n.iter=5000, bugs.directory="/Applications/WinBUGS14",
+ working.directory=".",
+ WINE="/Applications/Darwine/Wine.bundle/Contents/bin/wine",
+ WINEPATH="/Applications/Darwine/Wine.bundle/Contents/bin/winepath",debug=TRUE)
dyld: lazy symbol binding failed: lazy pointer not found at address 0xad058 in image /Applications/Darwine/Wine.bundle/Contents/bin/wine
dyld: lazy pointer not found at address 0xad058 in image /Applications/Darwine/Wine.bundle/Contents/bin/wine
(repeated many times)

I am using MacBook Pro with MacOS 10.6. Any tips or suggestions are very appreciated.

Gorjanc Gregor said...

I can not test as I do not own a Mac, but it seems that path is different. Double check the typing and make sure that winepath binary really exists.