Skip to content
fonnesbeck edited this page Apr 14, 2011 · 31 revisions

Examples

Basic examples

DisasterModel: A changepoint example, with several variations.

StraightLineFit: A two-parameter linear regression.

WeibullFit: Fitting the parameters of a Weibull distribution.

NormalFit: Fitting the parameters of a normal distribution.

VonMisesFit: Fitting the parameters of a Von Mises distribution.

GelmanBioassay: From section 3.7 of Bayesian Data Analysis by Gelman et al., 2nd ed.

CustomStep: An example of a custom step method.

Intermediate and advanced models

LatentOccupancy Simple occupancy model using latent states

Recovery Waterfowl band recovery model

Price Simple pricing model

Pump Hierarchical Poisson failure rates

Surplus Fisheries surplus production model

Salamanders Salamander occupancy estimation model

Probit Simple probit regression model

ExponentialSurvival Exponential model for melanoma survival data

Sir Hierarchical disease dynamics model (from Zipkin et al. 2010)

Zero-inflated poisson model

For users familiar with BUGS, here are a few examples that are translated directly from BUGS models; the original code is included in each file as a docstring:

Koala Koala sighting model (from Link & Barker 2009)

Mt Conditional multinomial mark-recapture model (from Link & Barker 2009)

Mt2 Unconditional multinomial mark-recapture model (apparently not possible in BUGS)

BayesFactor Simple example of Bayes factor calculation

Gaussian process examples

Mean: Creates a mean function.

Covariance: Creates a covariance function.

Realizations: Draws several realizations.

Observations: Observes a mean and covariance, then draws several realizations.

BasisCov: Creates a covariance from a basis with normally-distributed coefficients.

GPMCMC: Creates a PyMC model containing a Gaussian process, and fits it with MCMC.

Links to external examples

Examples of use of John Salvatier's multichain_mcmc package: https://github.com/jsalvatier/multichain_mcmc/tree/master/multichain_mcmc/examples

Examples for John's gradient_samplers package: https://github.com/jsalvatier/gradient_samplers/tree/master/gradient_samplers/examples

Abraham Flaxman's blog contains numerous PyMC examples, both for standard statistics and unusual applications, with code snippets: http://healthyalgorithms.wordpress.com/tag/pymc/

Whit Armstrong's comparison of PyMC with other packages for Gelman et al.'s radon dataset: https://github.com/armstrtw/pymc_radon

Estimation of Bayes Factors using PyMC: http://stronginference.com/weblog/2010/12/16/estimating-bayes-factors-using-pymc.html

Example-bearing threads on mailing list:

http://groups.google.com/group/pymc/browse_thread/thread/9dd4620a4a496c8a http://groups.google.com/group/pymc/browse_thread/thread/7c2f42d223be9efa http://groups.google.com/group/pymc/browse_thread/thread/0af5f316a6f3ad25 http://groups.google.com/group/pymc/browse_thread/thread/7a7eae82b64ea041 http://groups.google.com/group/pymc/browse_thread/thread/538f933f3c08809e http://groups.google.com/group/pymc/browse_thread/thread/17c5262b4618c7b5 http://groups.google.com/group/pymc/browse_thread/thread/d754ba79f95b9f78 http://groups.google.com/group/pymc/browse_thread/thread/e2b9c5369569d417 http://groups.google.com/group/pymc/browse_thread/thread/844a1c2de52d72c2 http://groups.google.com/group/pymc/browse_thread/thread/afe91c4d9440d6da http://groups.google.com/group/pymc/browse_thread/thread/a311facec455ef99 http://groups.google.com/group/pymc/browse_thread/thread/3ed5f11b93dc8ddb http://groups.google.com/group/pymc/browse_thread/thread/cc36569d9d002843 http://groups.google.com/group/pymc/browse_thread/thread/e84b6cd07b94b3ef http://groups.google.com/group/pymc/browse_thread/thread/0ba6ca01dbb82a46 http://groups.google.com/group/pymc/browse_thread/thread/2047306d8ea31715 http://groups.google.com/group/pymc/browse_thread/thread/81aa849deae8a1b8 http://groups.google.com/group/pymc/browse_thread/thread/c97ca688bda4ad1b http://groups.google.com/group/pymc/browse_thread/thread/1e9e582113cd6b4b http://groups.google.com/group/pymc/browse_thread/thread/53918b41f8eb4744 http://groups.google.com/group/pymc/browse_thread/thread/4eb664a913ad9011 http://groups.google.com/group/pymc/browse_thread/thread/c23045038a32fb12 http://groups.google.com/group/pymc/browse_thread/thread/4cd684bb4f11ea01 http://groups.google.com/group/pymc/browse_thread/thread/02f1ff5e29343627 http://groups.google.com/group/pymc/browse_thread/thread/e49455c860add294 http://groups.google.com/group/pymc/browse_thread/thread/c6ce37a80edf7f85 http://groups.google.com/group/pymc/browse_thread/thread/87a7d33086f6b4c0 http://groups.google.com/group/pymc/browse_thread/thread/9c1f54daa966c148 http://groups.google.com/group/pymc/browse_thread/thread/f988ce1685951393 http://groups.google.com/group/pymc/browse_thread/thread/41b64c126b62080c http://groups.google.com/group/pymc/browse_thread/thread/fef4582f1ff73077 http://groups.google.com/group/pymc/browse_thread/thread/ec828c63f09a08ae http://groups.google.com/group/pymc/browse_thread/thread/423c06187a482b64 http://groups.google.com/group/pymc/browse_thread/thread/a6092613089e0e70 http://groups.google.com/group/pymc/browse_thread/thread/0001396a059ac969