Skip to content

widdowquinn/Teaching-Stan-Hierarchical-Modelling

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

README.md Teaching-Stan-Hierarchical-Modelling

Introduction

This set of notebooks works through an example of hierarchical (also known as multilevel) Bayesian modelling using the pystan Python module. It is derived from Chris Fonnesbeck's introduction to Bayesian multilevel modelling using Stan:

Radon Problem Description Plot of Radon by Floor and County Plot of Radon by County

Reading/Using the Notebooks

These notebooks can be read through online as webpages (follow the links below in Notebooks), or downloaded and used interactively as Jupyter notebooks, where you can explore and experiment with the models in your web browser, using Python.

# License Information

Chris Fonnesbeck's material is licensed under the following licenses:

Both licences grant permission to reproduce and prepare derivative works, and these licenses should be considered also to apply to the work in this repository.

Reporting Issues

I will have made mistakes. If you spot any, or would otherwise like to make improvements, I would be grateful if you could please take one of the following actions:

  • Raise the issue at the GitHub issues page for this repository.
  • Fork the repository, make the required changes, and then issue a pull request.
# Notebooks
  1. Introduction
  2. Data Import
  3. Bias/Variance Tradeoff
  4. A Pooled Model
  5. An Unpooled Model
  6. Pooled vs Unpooled Models
  7. Partial Pooling - An Introduction
  8. Partial Pooling - Varying Intercept
  9. Partial Pooling - Varying Slope
  10. Partial Pooling - Varying Intercept and Slope
  11. Group-level Predictors
  12. Contextual Effects
  13. Prediction

Getting Started with Interactive Notebooks

## 1. Get the notebooks

Clone the notebooks from GitHub with:

git clone git@github.com:widdowquinn/Teaching-Stan-Hierarchical-Modelling.git

Then change into the repository directory:

cd Teaching-Stan-Hierarchical-Modelling/

2. Create a virtualenv to run the notebooks

Using virtualenv we create a standalone Python virtual environment with the appropriate libraries installed. This will not interfere with system Python or any other Python instances available on your machine.

First, create the virtual environment:

virtualenv -p python3.6 venv-stan

Next, activate the virtual environment:

source venv-stan/bin/activate

Then, install the required packages:

pip install -r requirements.txt

Finally, install Jupyter:

pip install jupyter

## 3. Starting the notebooks

To start Jupyter, issue the following at the command line:

jupyter notebook

This should bring up a view on the current directory in your browser. Click on any of the .ipynb notebook files to start them running in your browser - the index.ipynb page is a good place to start.

About

Jupyter notebooks for teaching hierarchical Bayesian modelling with Stan

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published