Horizons in Probabilistic Programming and Bayesian Analysis
- Hierarchical models
- Hidden Markov models
- Graphical models
- Non-parametric Bayes (distributions over functions)
|from pymc import *|
|import numpy as np|
|import pandas as pd|
|from numpy.ma import masked_values|
|# Import data, filling missing values with sentinels (-999)|
|test_scores = pd.read_csv('data/test_scores.csv')|
|# Extract variables: test score, gender, number of siblings, previous disability, age,|
|# mother with HS education or better, hearing loss identified by 3 months of age|
In the first chapter, we learned that while Bayes' formula is simple and its derivation is straightforward, using it to estimate model parameters is hampered by the fact that its calculation typically involves multidimensional integration that is rarely computable in closed form. Most useful Bayesian models, therefore, require computational methods in order to obtain reasonable estimates. Now that we have some Python at our disposal, we will make use of them by stepping through a selection of numerical methods for calculating Bayesian models.
As a motivating example, we will use some real data to build and estimate a simple parametric model. Specifically, we are looking at some measurements taken from subjects in a medical research study, and trying to fit a normal distribution to the weight of the group of patients.
>>> import numpy as np >>> import pandas as pd