Description

WinBUGS is a tool for MCMC simulations. Here is a self-writen bash program for installing WinBUGS in Ubuntu based linux distributions (tested on Ubuntu, Lubuntu and Linux Mint). winbugs_install.sh. NOTE: it should be run with sudo permissions

So, let’s dissect this simple bash program.

Wine installation

This part has been done using UbuntuHandbook tutorial.

First step is to enable 32bit architecture.

sudo dpkg --add-architecture i386

Second step is add CPG key and the repository of Winehq. Note that this is for Ubuntu 20 (focal), so you should replace focal by the proper distribution name.

wget -nc https://dl.winehq.org/wine-builds/winehq.key
sudo apt-key add winehq.key
rm winehq.key
#Para ubuntu 20.04
sudo add-apt-repository 'deb https://dl.winehq.org/wine-builds/ubuntu/ focal main'`

Finally, install wine:

sudo apt install winehq-stable

Download and install WinBUGS

The download is done from the official website from the Cambridge University. As other non-standart packages, we are going to locate WinBUGS installation in the /opt/ directory.

wget https://www.mrc-bsu.cam.ac.uk/wp-content/uploads/2018/11/winbugs143_unrestricted.zip
unzip winbugs143_unrestricted.zip
sudo cp -r -d winbugs14_full_patched/WinBUGS14/ /opt/
rm -r -d winbugs14*
sudo chown -R $(echo $USER) /opt/WinBUGS14

Optional: create a desktop launcher

########OPCIONAL PARA TENER IMAGEN EN EL LANZADOR ##########
wget https://bookdown.org/steve_midway/BHME/bugs.jpg   ###
cp bugs.jpg /opt/WinBUGS14/                            ###
rm bugs.jpg                                            ###
############################################################
echo "[Desktop Entry]
Type=Application
Name=WinBUGS14
Exec=wine /opt/WinBUGS14/WinBUGS14.exe
Icon=/opt/WinBUGS14/bugs.jpg" > winbugs.desktop
sudo mv winbugs.desktop /usr/share/applications/
sudo update-desktop-database

Making WinBUGS callable from R

It is possible to execute WinBUGS directly from R, using R2Winbugs package. For this, it is necessary to create some folders and add an argument to the bugs function in R.

#Folder creations
mkdir ~/.wine/drive_c/temp
mkdir ~/.wine/drive_c/temp/Rtmp
cp -r /opt/WinBUGS14/ ~/.wine/drive_c/Program\ Files/

Then, it is necessary to add the argument working.directory="~/.wine/drive_c/temp/Rtmp" to bugs function. As an example:

R2WinBUGS::bugs(data, model, inits,parameters.to.save, working.directory ="~/.wine/drive_c/temp/Rtmp" )