Tutorial of Bayesian Models
This project is maintained by RafaelSdeSouza
Tutorial presented during the 8th Astronomical Data Analysis Summer School.
This repository holds the scripts used to illustrate the theoretical concepts of Bayesian Modeling using synthetic and real data.
If you use any of the resources presented here, please include the appropriate citation. Each folder holds scripts for a different probability distribution, references and the corresponding bibtex entry.
Most of the material presented here will be presented with deeper discussions and further examples in our book to be released in late 2016:
Bayesian Models for Astrophysical Data: using R/JAGS and Python/Stan
Hilbe, de Souza and Ishida, in prep, Cambridge University Press
The tutorial is composed of theoretical and practical modules.
The examples will be demonstrated in R but familiarity with the language is not a requirement.
In order to optimize the time spent in the examples and practical applications, I advise the participants to get the following software up and running in advance.
For Linux users
If you are using Linux, make sure to add the appropriate repository before installing.
Open the file /etc/apt/sources.list
with your favorite text editor and add the following line:
deb http://cran.cnr.berkeley.edu/bin/linux/ubuntu trusty/
For deeper instructions and other Linux flavours see this page.
Then, in the command line do:
sudo apt-get update
Do not worry if you got a couple of error messages. This is not significant for our purpouses. The other steps should work as planned despite of them.
To install R and JAGS go to the command line and type:
sudo apt-get install r-base
sudo apt-get install jags
In order to get Rstudio choose the appropriate version from this page.
After download is completed double click in the .deb
file. This will automatically open Ubuntu Software Center. Click on Install.
R packages
Once Rstudio is installed you will need a few R packages.
These can be done in 2 ways:
Using Rstudio toolbar:
-Tools -> Install packages
A window will pop-up where you can select:
Choose from:
Repository (CRAN)
Packages (separate multiple with space or comma):
R2jags, MASS, Scales, mcmcplots, ggplot2, plot3D
Alternatively, you can simply type in the Rstudio console window
pac <-c("R2jags","MASS","scales","mcmcplots","ggplot2","plot3D");
install.packages(pac,dependencies=T)
Getting the scripts
In order to avoid problems with file paths it is advisable to clone this repository and work within it.
To do so choose go to the command line and navigate to a location where you would like to work. Then type:
git clone https://github.com/RafaelSdeSouza/ADA8.git
This should be enough to get you ready for the examples we will be working on.
If you do not have git installed you can get it typing:
sudo apt-get install git
Staying up to date
This is a work in progress and it will be continuously updated so erros can be fixed and complementary material can be added.
It is advisable to make sure you have the latest version before start working in you local directory. To do so, in the command line navigate to your copy of this repository and type:
git pull
Then you are certain to get all the bug fixes and improvements available.
Have fun!
The slides used in this tutorial are available here.
de Souza et al, 2016, Is the cluster environment quenching the Seyfert activity in elliptical and spiral galaxies?, arxiv:astro-ph/1603.06256, BibTex
de Souza et al, 2015, The overlooked potential of generalized linear models in astronomy - III. Bayesian negative binomial regression and globular cluster populations, MNRAS, 453, p.1928-1940, BibTex
Elliot et al, 2015, The overlooked potential of Generalized Linear Models in astronomy-II: Gamma regression and photometric redshifts, Astronomy & Computing, 10, p. 61-72, BibTex
de Souza et al, 2015, The overlooked potential of Generalized Linear Models in astronomy, I: Binomial regression, Astronomy & Computing, 12, p. 21-32, BibTex
Hilbe, 2014, Modeling Count Data, Cambridge University Press, BibTex
Hilbe, 2011, Negative Binomial Regression, Cambridge University Press, BibTex
Rafael da Silva de Souza, PhD
Researcher - ELTE, Hungary
Head and founder - The COsmostatistics INitiative (COIN)
Vice-president for development - The International Astrostatistics Association (IAA)