Preparation for the PhD course in Bayesian Econometrics

How to download, install and getting started with R and BUGS

It is expected that every participant brings his/ her own laptop with R and BUGS installed. Instead of R it will be possible to use Gauss or Matlab, but since the lecturer’s book has several examples with code from R we will use this program. Conveniently, both R and BUGS are free, and can be downloaded from the internet. Below you find instructions for downloading, installing and how to get started with the software.

R

The home page of the R-language is the http://www.r-project.org. However, for downloading the program go directly to http://mirrors.dotsrc.org/cran/ and if you use Windows95 or later versions of Windows select ‘Windows (95 or later)’. Next select ‘base’ and finally right-click on ‘R-2.2.1-win32.exe’ and select ‘Save as’. When you have downloaded the file you double click on the file and select ‘Run’ and select the appropriate installing language and keep on selecting ‘Next’.

When successfully installed you may want to run a simple R code. You can find simple code to perform OLS from on the course home page www.econ.ku.dk/metrics/bayes/phdcourse.htm. If you save this code in the directory ‘C:/bayes/’, you type

source("C:/bayes/OLS.R")

in the command window and press enter to run the program. If you want to see any of the variables or vectors generated by the provided code you simply write the name of the variables or vectors and pres enter. The R-language is well documented and to new users the introductory manual http://cran.r-project.org/doc/manuals/R-intro.pdf is very useful. Furthermore, the help function is very nice; if you want information on the plot commando just type ?plot in the command window and press enter. The book authored by the lecturer also provides several examples of R code.

BUGS

The BUGS (Bayesian inference Using Gibbs Sampling) can be downloaded from http://www.mrc-bsu.cam.ac.uk/bugs/winbugs/contents.shtml#install. Right-click on the blue text that says that you can download a ‘zipped version of the whole file structure’ and select ‘Save as’. The unzipped folder Winbugs14 should be put where you usually have your programs, e.g. ‘C:/Program files/’. Next, click on the WinBUGS14 icon in the WinBUGS14 folder and BUGS will start. On the same website as before you left-click on the blue text for the ‘registration form’, which you have to fill in to get a full version of BUGS (it is free!). When you receive the mail you copy the text, in to a new file in BUGS. You do this by selecting ‘File’ and ‘New’. From the ‘Tools’ menu select the ‘Decode’. A dialog box will appear and you should click on the ‘Decode All’ button to install the key. Next, find the file ‘…\WinBUGS14\Bugs\Code\Keys.ocf’ in the windows explorer and check whether it shows the current date and time. If that is the case you have successfully installed BUGS. However, for the course we need version 1.4.1. Therefore, you need to go to http://www.mrc-bsu.cam.ac.uk/bugs/winbugs/patches.shtml to update BUGS. Left-click on the blue text that ‘Get the file by clicking this link’. Once again you copy this file into a new BUGS file and select ‘Decode’ from the ‘Tools’ menu. You also select ‘Decode all’ this time. After you have done this press ‘F1’. If it says ‘version 1.4.1’ in the WinBUGS User Manual the update was successful.

If you experience any problems when downloading and installing the software please do not hesitate to contact Daniel le Maire at Christian.Daniel.le.Maire (at) econ.ku.dk.