This is video one of a three part introduction to Bayesian data analysis aimed at you who isn’t necessarily that well-versed 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:

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:

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.

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 Chinese-American 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.

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.

Not surprisingly,
this year’s UseR! conference was a great event with heaps of talented researchers and R-developers 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 non-parametric Bootstrap is really a Bayesian procedure, and how you can run the Bayesian bootstrap in R using my
bayesboot package, just press play. :)

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, half-rotten 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?

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 non-parametric 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:

For the third year round I and
Ullrika Sahlin arranged
Bayes@Lund, a mini-conference 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
Eric-Jan 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…

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…

// The heights of the last ten American presidents in cm, from Kennedy to Obama
var heights = [183, 192, 182, 183, 177, 185, 188, 188, 182, 185];

… 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.

Christmas is soon upon us and here are some gift ideas for your statistically inclined friends (or perhaps for you to put on your own wish list). If you have other suggestions please leave a comment! :)

1. Games of probability

A recently released game where probability takes the main role is
Pairs, an easy going press-your-luck game that can be played in 10 minutes. It uses a custom “triangular” deck of cards (1x1, 2x2, 3x3, …, 10x10) and is a lot of fun to play, highly recommended!