Introduction to Bayesian Inference (and Stan)

Today

  • Conceptual Framework of BDA
  • MCMC
  • Stan Example
  • Stan at AdRoll
  • Contrast with Null Hypothesis Significance Testing
  • Socks!

Big Data

Tiny Data

reallocation of credibility across possibilities

possibilities as parameter values in descriptive models

Descriptive Models

  • guess about what the generative process is for the observed data

  • parameter values control shape of the distributions in the descriptive model

Steps in BDA

  1. Exploratory data analysis
  2. Define descriptive model
  3. Specify priors
  4. Create model & analyze results
  5. Posterior predictive check

Bayes' Rule:

Relation between prior credibility and posterior reallocation of credibility conditional on data

Bayes' Rule:

Why can't we use puppies Bayes' Rule for everything?

  • Can't be solved analytically for complex models

  • ...so instead we will approximate the posterior with Markov Chain Monte Carlo (MCMC) methods

Markov Chain Monte Carlo (MCMC)

  • Metropolis

  • Gibbs

  • Hamiltonian Monte Carlo

Review
  • Reallocation of credibility across possibilities
  • Possibilities as parameter values

  • MCMC to generate representative approximation of posterior
  • DSL for full bayesian inference written in C++

  • Interfaces for R, Python, Julia, Matlab & command line (plus MCMC analysis and visual summaries with shinyStan)

Stan Code Blocks

Linear Regression Code Example

LDA Code Example

Extended Example: Fairness of a coin

Steps in BDA 1

  • Exploratory data analysis

Steps in BDA 2

  • Define descriptive model

Steps in BDA 3

  • Specify Prior

Steps in BDA 4 + 5

  • Create model & analyze results & posterior predictive check

CPA estimator: bayesian ordered logit

Heatshield: bayesian test of proportions