Visual MCMC

Unpacking a bunch of related statistical concepts through visualization
Data Visualization
Statistical
Simulation
Animation
Published

November 14, 2021

My educational background and training was in Biostatistics. Throughout my career, I’ve served many different roles, from statistician to programmer to epidemiologist to most recently, computational scientist. Over the last bit, I’ve kind of lost touch with my mathematical and statistical roots. Every so often, I will dive back into some concepts to remind myself how it works and learn of any new developments.

Bayesian statistics was an interesting course in my graduate program. Unfortunately, I haven’t used it as much as I would have wished, but I am simply fascinated by the math. At the same time, it can be challenging to wrap your head around what’s going on underneath the hood in the estimation process. This is precisely why I made this post.

I’ll stop here to direct you towards the original (more comprehensive) post I made concerning this topic, which can be found here

In short, this project involved a few key activities that helped refresh my memory and deepen my understanding, all through using R, animation and simulation.

To this end, I prepared three visualizations I’d like to share.

part

This visualization shows the first 100 iterations of a single chain in estimating the parameters of the Bayesian logistic regression analysis. I’ve overlaid a table that shows the current and previous values, and the decision taken by the algorithim.

full

This visualization shows the full 10,000 iterations of the single chain. I’ve removed the table of estimates. Here it’s quite clear that the chain quickly settles into the area of the known parameter estimates.

multi

The last visualization mixes things up a bit, by providing 4 chains, each with different starting or initialization values. In the end, they all converge. Kind of.

Hope you find it useful!