This is video two of a three part introduction to Bayesian data analysis aimed at you who isn’t necessarily that wellversed in probability theory but that do know a little bit of programming. If you haven’t watched part one yet, I really recommend you do that first, here it is. This second video covers the why? of Bayesian data analysis: Why (and when) use it instead of some other method of analyzing data?
Video Introduction to Bayesian Data Analysis, Part 1: What is Bayes?
This is video one of a three part introduction to Bayesian data analysis aimed at you who isn’t necessarily that wellversed in probability theory but that do know a little bit of programming. I gave a version of this tutorial at the UseR 2015 conference, but I didn’t get around doing a screencast of it. Until now, that is! I should warn you that this tutorial is quite handwavey (but it’s also pretty short), and if you want a more rigorous video tutorial I can really recommend Richard McElreath’s YouTube lectures.
This first video covers the what? of Bayesian data analysis with part two and three covering the why? and the how?. I expect to be able to record part two and three over the next couple of weeks but, for now, here is part one:
Beginners Exercise: Bayesian Computation with Stan and Farmer Jöns
Over the last two years I’ve occasionally been giving a very basic tutorial to Bayesian statistics using R and Stan. At the end of the tutorial I hand out an exercise for those that want to flex their newly acquired skills. I call this exercise Bayesian computation with Stan and Farmer Jöns and it’s pretty cool! Now, it’s not cool because of me, but because the expressiveness of Stan allowed me to write a small number of data analytic questions that quickly takes you from running a simple binomial model up to running a linear regression. Throughout the exercise you work with the same model code and each question just requires you to make a minimal change to this code, yet you will cover most models taught in a basic statistics course! Well, briefly at least… :) If you want to try out this exercise yourself, or use it for some other purpose, you can find it here:
Beginners Exercise: Bayesian computation with Stan and Farmer Jöns (Rmarkdown source)
Solutions to Bayesian computation with Stan and Farmer Jöns (Rmarkdown source)
My friend and colleague Christophe Carvenius also helped me translate this exercise into Python:
Python Beginners Exercise: Bayesian computation with Stan and Farmer Jöns
Python Solutions to Bayesian computation with Stan and Farmer Jöns
Now, this exercise would surely have been better if I’d used real data, but unfortunately I couldn’t find enough datasets related to cows… Finally, here is a depiction of farmer Jöns and his two lazy siblings by the great master Hokusai.
A Fun Gastronomical Dataset: What’s on the Menu?
I just found a fun food themed dataset that I’d never heard about and that I thought I’d share. It’s from a project called What’s on the menu where the New York Public Library has crowdsourced a digitization of their collection of historical restaurant menus. The collection stretches all the way back to the 19th century and well into the 1990’s, and on the home page it is stated that there are “1,332,271 dishes transcribed from 17,545 menus”. Here is one of those menus, from a turn of the (old) century ChineseAmerican restaurant:
The data is freely available in csv format (yay!) and here I ‘ll just show how to the get the data into R and I’ll use it to plot the popularity of some foods over time.
How I made some Pokémon Business Cards
As I’m in the industry now I figured I needed some business cards and as it seems the 90s never left us and Japanese monsters are hip again, I decided to make them Pokémon themed.
I think they turned out pretty well, and here I’m just going to give some pointers on how I did them.
Bayesian Bootstrap: The Movie + Some Highlights from UseR! 2016
Not surprisingly, this year’s UseR! conference was a great event with heaps of talented researchers and Rdevelopers showing off the latest and greatest R packages. (A surprise visit from Donald Knuth didn’t hurt either.) What was extra great this year was that all talks were recorded, including mine. So if you want to know more about how the nonparametric Bootstrap is really a Bayesian procedure, and how you can run the Bayesian bootstrap in R using my bayesboot package, just press play. :)
How to Cut Your Planks with R
Today I’m extraordinarily pleased because today I solved an actuall real world problem using R. Sure, I’ve solved many esoteric statistical problems with R, but I’m not sure if any of those solutions have escaped the digital world and made some impact ex silico.
It is now summer and in Sweden that means that many people tend to overhaul and rebuild their wooden decks as you need somewhere to sit during those precious few weeks of +20°C (70° F) weather. And so, we also decided to rebuild our algae ridden, halfrotten deck and everything went well until we got to the point where we had to construct the last steps leading into the house. As we had been slightly sloppy when buying planks we only had five left, and when naïvely measuring out the lengths we needed it seemed that the planks were not long enough. Now the problem was this: Was there some way we could saw the planks into the lengths we needed or did we have to go all the way to the lumber yard to get more planks?
These were the planks we had (in centimeters):
1


bayesboot: An R package for doing the Bayesian bootstrap
I recently wrapped up a version of my R function for easy Bayesian bootstrappin’ into the package bayesboot
. This package implements a function, also named bayesboot
, which performs the Bayesian bootstrap introduced by Rubin in 1981. The Bayesian bootstrap can be seen as a smoother version of the classical nonparametric bootstrap, but I prefer seeing the classical bootstrap as an approximation to the Bayesian bootstrap :)
The implementation in bayesboot
can handle both summary statistics that works on a weighted version of the data (such as weighted.mean
) and that works on a resampled data set (like median
). As bayesboot
just got accepted on CRAN you can install it in the usual way:
1


Posterior Update of Bayes@Lund 2016
For the third year round I and Ullrika Sahlin arranged Bayes@Lund, a miniconference bringing together researchers interested in or working with Bayesian methods in and around Sweden. This year we were thrilled to have over 70 attendees, both from near and far, perhaps due to our interesting invited speakers EricJan Wagenmakers and Robert Grant, or perhaps due to the promise of fika (a Swedish word referring to a break involving coffee and/or tea with cake and/or cookies and/or pastries, the more and the better). Perhaps it was a combination…
bayes.js: A Small Library for Doing MCMC in the Browser
Bayesian data analysis is cool, Markov chain Monte Carlo is the cool technique that makes Bayesian data analysis possible, and wouldn’t it be coolness if you could do all of this in the browser? That was what I thought, at least, and I’ve now made bayes.js: A small JavaScript library that implements an adaptive MCMC sampler and a couple of probability distributions, and that makes it relatively easy to implement simple Bayesian models in JavaScript.
Here is a motivating example: Say that you have the heights of the last ten American presidents…
1 2 

… and that you would like to fit a Bayesian model assuming a Normal distribution to this data. Well, you can do that right now by clicking “Start sampling” below! This will run an MCMC sampler in your browser implemented in JavaScript.
If this doesn’t seem to work in your browser, for some reason, then try this version of the demo.