Bayesian data analysis on a Mac

From enfascination

Jump to: navigation, search
Line 8: Line 8:
  
 
====Instructions for using BRugs on a Mac====
 
====Instructions for using BRugs on a Mac====
* Be a Mac user of R (if you aren't then you don't have a problem)
+
* Be a Mac user of R (if you are on Windows then you don't have a problem).
 
* Download [http://hri.cogs.indiana.edu/~jackh/WindowsR.app.tar.bz2 this].   
 
* Download [http://hri.cogs.indiana.edu/~jackh/WindowsR.app.tar.bz2 this].   
 
* Extract the tarball or (if you don't know what that means) hope that your computer magically turns the file into one that ends with ''.app'' .   
 
* Extract the tarball or (if you don't know what that means) hope that your computer magically turns the file into one that ends with ''.app'' .   
 
* Open the app, wait a bit.  There will be a benign error, just hit OK.
 
* Open the app, wait a bit.  There will be a benign error, just hit OK.
 
* After R loads, type  
 
* After R loads, type  
  install.packages("Brugs")
+
  install.packages("BRugs")
 
* Download [http://www.indiana.edu/~jkkteach/BayesTutorial/TutorialBRugsTest.R this test file] and type
 
* Download [http://www.indiana.edu/~jkkteach/BayesTutorial/TutorialBRugsTest.R this test file] and type
 
  setwd("~/whereeverthefilewent")
 
  setwd("~/whereeverthefilewent")
Line 19: Line 19:
  
 
You should get pretty graphs.  That means it worked.  If you want more,  the samples from [http://www.indiana.edu/~kruschke/DoingBayesianDataAnalysis Kruschke's book] are [http://www.indiana.edu/~kruschke/DoingBayesianDataAnalysis/Programs/ here].  The samples should all run fine if you download everything to one spot.  The book has puppies on the cover to signal its friendliness to the 'fraid-of-math.
 
You should get pretty graphs.  That means it worked.  If you want more,  the samples from [http://www.indiana.edu/~kruschke/DoingBayesianDataAnalysis Kruschke's book] are [http://www.indiana.edu/~kruschke/DoingBayesianDataAnalysis/Programs/ here].  The samples should all run fine if you download everything to one spot.  The book has puppies on the cover to signal its friendliness to the 'fraid-of-math.
 +
 +
There are other workarounds to get BUGS in R on a Mac.  This one is the easiest to get going and I've been told that it has some other advantages (thanks Drew):
 +
*In this wine environment copy/paste/save work (but with the control key instead of the command key on my Mac keyboard). 
 +
*Control-R actually runs highlighted text.
 +
*Downside: shift-arrows does not highlight, instead it overwrites text in this version.

Revision as of 02:04, 10 March 2011

specifically: Bayesian Data Analysis on a Mac with R and OpenBUGS via BRugs

Bayesian data analysis is a way of figuring out what you believe given what you just saw, but in math. R is a free computer language for calculating statistics. OpenBUGS is a flexible program for doing Bayesian data analysis. BRugs is a bridge between R and BUGS. Macs are why Steve Jobs wears black turtlenecks.

This post is solving a very narrow problem. R is cross-platform, but OpenBUGS only works on Windows. The same holds either for the cousins of OpenBUGS or for their bridges with R. So it is hard for Mac users to do Bayesian data analysis in R with the flexibility offered by BUGS.

My colleague Jack Harris has a fix that doesn't take any fiddling. Its great. If you know what you are doing, instructions are below. If you wish you knew what you were doing, read a book.

Instructions for using BRugs on a Mac

  • Be a Mac user of R (if you are on Windows then you don't have a problem).
  • Download this.
  • Extract the tarball or (if you don't know what that means) hope that your computer magically turns the file into one that ends with .app .
  • Open the app, wait a bit. There will be a benign error, just hit OK.
  • After R loads, type
install.packages("BRugs")
setwd("~/whereeverthefilewent")
source("TutorialBRugsTest.R")

You should get pretty graphs. That means it worked. If you want more, the samples from Kruschke's book are here. The samples should all run fine if you download everything to one spot. The book has puppies on the cover to signal its friendliness to the 'fraid-of-math.

There are other workarounds to get BUGS in R on a Mac. This one is the easiest to get going and I've been told that it has some other advantages (thanks Drew):

  • In this wine environment copy/paste/save work (but with the control key instead of the command key on my Mac keyboard).
  • Control-R actually runs highlighted text.
  • Downside: shift-arrows does not highlight, instead it overwrites text in this version.