Welcome, this is a new blog set up to discuss the use of Stata for conducting Bayesian statistical analyses. I have started it to coincide with the publication of my book entitled ‘Bayesian Analysis with Stata’, which will appear shortly.
This project started many years ago when I needed to integrate Stata with WinBUGS, a free program for fitting Bayesian models. My aim was to explore my data in Stata, fit models using WinBUGS and then return to Stata to summarize the results. To help with this, I wrote some ado files that enable the two programs to talk to one another and these were described in a Stata journal article (http://www.stata-journal.com/article.html?article=st0115). Subsequently, I developed and extended those ado files and the updated versions form the basis for the book.
WinBUGS has had an enormous impact on the use of Bayesian methods by providing a black-box tool that frees the user from the complexities of the MCMC algorithms that are the basis for modern Bayesian model fitting. The result is that WinBUGS has had both a beneficial and a harmful effect. Beneficial in that it has greatly increased the use of Bayesian methods by non-specialists, and harmful because there are now people who think that ‘I am going to run a Bayesian analysis’ and ‘I am going to use WinBUGS’ are two ways of saying the same thing. When WinBUGS crashes or takes days to run, I have known people try different ad hoc changes to the model or the priors until they can get an answer.
WinBUGS is a fantastic program, but because it is not the only option, I decided to add some chapters to the book to show that Bayesian analysis is possible in Stata without WinBUGS, provided that you have a basic grasp of MCMC algorithms. Such an understanding not only frees us from reliance on WinBUGS, but it helps us to understand what is going on inside the black-box and so enables us to make better use of WinBUGS.
When I wrote the book I had in mind a reader who is not a specialist in Bayesian methods but who has some real data that they need to analyse and a desire to discover whether Bayesian methods could help. Consequently, I have tried to explain the basis of the MCMC algorithms in a simple way.
I do not plan to use this blog to go over topics that are already dealt with in the book, but I hope, over the coming months, to discuss some of the issues and applications that space did not allow me to cover in the book. Since the aim of the book is to describe practical Bayesian data analysis in Stata for non-specialists, I will keep to the same approach in the blog and discuss the new issues by analysing real data and developing further applications.
The “Bayesian Analysis with Stata” book cover is used with the permission of StataCorp. Visit http://www.stata-press.com/books/bayesian-analysis-with-stata/ for information on the book.
A copy of your new book, “Bayesian Analysis with Stata”, arrived earlier this morning, and I haven’t been able to put it down. Congratulations on a fine book. I recommend it to any Stata user having an interest in Bayesian modeling. Thanks for writing it.
Joseph Hilbe
Thank you for your kind words – I am still at the stage when I keep thinking of things that I could have said better, but no doubt that will pass
Last week the book arrived to me (Colombia). I´m a new Stata user with interest in bayesian methods (I am in the early phases of reading, reading…). I only have read chapter one, really helpful.
Best regars
I am pleased that you are finding the book helpful – I hope to visit Columbia for the first time later this year and am very much looking forward to it
I just got a copy of your fantastic book, ‘Bayesian Analysis with Stata’ here in university of ibadan, Nigeria. I have been looking forward to it as a new convert to Bayesian approach. I thank you for the good work.
Thank you and I hope that you enjoy this blog as well – there are many topics that I had to leave out of the book because of lack of space and in the coming months I will discuss these on the blog
Your hungarian study data supplied does not bother to label the variables. What are the correct variable labels? Could you supply a corrected data set and put it on the stata books website? Please send me an email when you make the fix.
One of the lessons that I learnt from writing this book is that things happen that are out of your control. I had not intended releasing the hungarian data because they were only used to generate a prior but I had to send a copy of the data to Stata Press so that they could check the code for figure 2.2 and Stata Press then released the data. The columns that you want are labelled v1_3 and v2_3. If you want to know what all of the columns mean, you can get the information by following the web link given in the book. I will ask Stata Press to release a cut down version of the data set that only contains the two columns that are needed for the plot.
you provide code for chapter 8 from your book. What is the pre-existing directory structure required to run this code without modification? Same question for all your chapter code.
The programs described in Chapter 8 are very flexible and will run with pretty much any directory structure provided that you tell them what structure you are using. The way that I work is to set up a file called executables.txt that contains the name of the folder than contains the WinBUGS or OpenBUGS executable in the manner described in the book. If you do that then you should not have any further problems although by default the working text files of data, WinBUGS model etc. will go into the current working directory, which may not be what you want so you might choose to set the ‘path’ option.
I had the executables.txt file setup as you describe before I emailed you earlier. Contents are
WINBUGS,”C:\Program Files (x86)\WinBUGS14\WinBUGS14.exe”
OPENBUGS,”C:\Program Files (x86)\OpenBUGS\OpenBUGS322\OpenBUGS.exe”
I am using openbugs. I have checked and openbugs is in the correct directory.
To run the chapter8 code, I pwd’d the working directory to c:\bas . Running the code gets me without comment to the
type temp\log.txt which is not found.
The c.\bas directory contains all of your do files, the readme.txt, the executables.txt and subdirectories data and temp
The data file contains your datafiles and a temp subdirectory. The bas file temp subdirectory contains a data, init, model, and script file.
A log.txt file is nowhere to be found.
I am trying to use your book and discussion to learn and use winbugs. I am not a student and I am not working with colleagues that are familiar with openbugs. I can specialize from a constrained piece of code that works. Again, can you describe a file location and directory structure that will run your openbugs code without change? I am not learing what I need from the models and statistics when I am spending time figuring out your bookkeeping. Thanks in advance.