Bayesian ANOVA

Bayesian model building for an analysis of variance assuming equal varainces.

In this post I apply Bayesian model building techniques to a traditional Analysis of Variance (ANOVA) on a dataset. I'm interested in building a Bayesian model here because as opposed to the frequentist ANOVA, the Bayesian approach provides a probability distribution over the parameter estimates .

I start with a hierarchical model assuming constant variance, then heterogeneous variance, and then robust estimation with heterogeneous variance.

The dataset consists of the response of viscosity to 5 levels of treatment (4 treatments + 1 control). Here's a box plot of the data illustrating there's probably a difference between treatments. Bayesian methods will let me estimate the means and provide probability distributions about them.


The model for this process is as follows (robust estimation with heterogeneous variances):


Checking the priors for the estimated means is below, and reasonable for the problem (although with negatives - I've specified a mean of 0).


Sampling from the distribution is straight forward in PyMC and the trace plot for the parameter estimates is below. There weren't many divergences so I don't intend to re-parameterize the model.


You can see the entire notebook and graphs here.