Friday, April 17, 2009

Installing WinBUGS under Mac

I'm reviewing a book on Bayesian models, and the very first thing the book says to do is install WinBUGS. I always coded by hand my Bayesian models, and maybe that's why I've only published one paper using them. So install WinBUGS on my Mac.

There's a lot out there. Three versions of BUGS: WinBUGS, OpenBUGS, and JAGS. And several windows emulators: wine, Crossover, etc.

All options require installing Xcode tools which has the following steps:
1. Put original OS X CD in, and install Xcode.
2. Go to apple developer connection website, register, download updated version of Xcode (so maybe first step wasn't necessary?) which is 1 G and took 3 hours to download, and install everything including X11 and X11SDK

Here's what I've tried so far.

1. Darwine: Theoretically easy because it comes precompiled. People claim that this works and a statistics class at Duke even had all their students do this, but I couldn't get it to work.

Nothing happens. Just get an error in the console:
err:module:DelayLoadFailureHook failed to delay load setupapi.dll.InstallHinfSectionW
wine: Call from 0x7b831fd5 to unimplemented function setupapi.dll.InstallHinfSectionW, aborting
wine: Unimplemented function setupapi.dll.InstallHinfSectionW called at address 0x7b831fd5 (thread 000b), starting debugger...
couldn't load main module (2)
Unhandled exception: unimplemented function setupapi.dll.InstallHinfSectionW called in 32-bit code (0x7b832077).
Register dump:
err:module:attach_process_dlls "gdi32.dll" failed to initialize, aborting
err:module:LdrInitializeThunk Main exe initialization for L"Z:\\Applications\\WinBUGS14\\WinBUGS14.exe" failed, status c0000005

2. Wine installed under fink. Something that looks Windows-like launches, but it's just an error box. I didn't save the message.

3. Wine installed under MacPorts had 56 dependencies and required a lot of hand intervention. I did many of the dependencies in parallel or else it would have taken even longer.

And whoo, WinBUGS actually launches, but as soon as I clicked on new to input the license key, it crashed with this error:

[Macintosh:~] janet% wine /Applications/WinBUGS14/WinBUGS14.exe
fixme:keyboard:RegisterHotKey (0x10026,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
X Error of failed request: BadMatch (invalid parameter attributes)
Major opcode of failed request: 152 (RENDER)
Minor opcode of failed request: 4 (RenderCreatePicture)
Serial number of failed request: 7133
Current serial number in output stream: 8517

3b. Then within the MacPort wine I tried running OpenBUGS rather than WinBUGS, and the same thing happened.

[Macintosh:~] janet% wine /Applications/OpenBUGS/winbugs.exe
X Error of failed request: BadMatch (invalid parameter attributes)
Major opcode of failed request: 152 (RENDER)
Minor opcode of failed request: 4 (RenderCreatePicture)
Serial number of failed request: 1812
Current serial number in output stream: 2302

5. JAGS (Just Another Gibbs Sampler) installs perfectly in less than 5 minutes and even has a manual. But it says that it doesn't do everything that WinBUGS does, though it really wishes it did.

6. Crossover allows downloads of trial copies that work for 30 days but cost $50 to educational users after that. As with Darwine and Wine, people claim to have gotten it working with BUGS, but the company itself doesn't guarantee that it will work. And so far it does after I followed this hint.

The remaining problem is how to integrate WinBUGS with R now that the famous BRugs package has disappeared.


Anonymous said...

Thanks for the mention of CrossOver; glad that it *seems* to be working for you re: WinBugs.


-jon parshall-
"Your Mac/Windows Solution"

Christopher said...

I have gotten WinBUGS and OpenBUGS to work. See here ...

Christopher said...

I am not sure if my last comment went through but I got this to successful work. See here ..

Matt said...

Thanks for these tips. I posted a short and easy how-to on my website ( for using Wineskins (based on WINE) to run OpenBUGS (or WinBUGS) in Mac OS X. So far, no problems, and Wineskin is a great open-source app.