Get startedGet started for free

Four good things with Bayes

1. Why use Bayesian data analysis?

So why would you want to use Bayesian data analysis, rather than some other method? So far, it seems like I’ve given you reasons for why not to use it: It mostly requires a lot of work, and you need to set everything up from scratch. But the reason for all this work was so that you would understand what’s going on under the hood. Once you know that, there are many good pre-packaged tools for Bayesian data analysis that just lets you get on with your work, and we’ll look at one of those tools in chapter 5, but for now, we’ll stay under the hood. So the main reason to use Bayes is that it is

2. Bayes is flexible

a very flexible method to model, analyze and learn from data. And in this chapter I’ll give you four examples of this flexibility, we’ll see how you can include information sources in addition to the data into your analysis, for example, expert opinion. How you always can compare any outcomes of Bayesian analyses, like parameters between different groups or datasets. How the result of a Bayesian analysis can be used to do decision analysis, for example, to make it easier to use the result of the model to make an informed business decision. And finally how the flexibility of Bayes allows you to change the underlying statistical model completely with relatively little effort. We’ll start by looking at

3. Including information in addition to data

including information sources in addition to the data. This could be background information, expert opinion or just common knowledge that you have and that you would like to add to the model. To run with the website ad example from last chapter: Let’s say you actually contacted the social media company and asked:

4. Chat 1

“So what are really the range of proportion of clicks you see for ads?” And let’s say they actually answered:

5. Chat 2

“Hi You! Most ads get clicked on 5% of the time, but for some ads it is as low as 2% and for others as high as 8%.”

6. Chat 3

“Ah, but you’ve written 10% on your webpage!?”

7. Chat 4

“That’s marketing, don’t listen to them!” Ok, this seems like it could be a piece of useful information to include in the analysis. But how do we do that?

8. Binomial model from chapter 2

Here is the Bayesian model we used last chapter and a natural place to include background information like this is in the prior probability distribution, as this represents what the model knows before seeing the data.

9. Unif(0, 0.2)

And right now it knows that the underlying proportion of clicks is equally likely to be anything between 0% and 20%. This is already a prior that contains some information: we’re basically telling the model that it is impossible that the proportion of clicks is any higher than 20% and if we really didn’t want to assume anything regarding the proportion of clicks we could make this into a more non-informative prior by saying it’s equally likely that it’s anything from

10. Unif(0, 1.0)

0% to a 100%. But now we want to have a prior distribution that encodes the information that

11. Zoom in on chat message

“Most ads get clicked on 5% of the time, but for some ads it is as low as 2% and for others as high as 8%.” There are many ways we could define such a distribution. You could even draw a distribution on paper, scan it in, and transfer it to R somehow. But a convenient way is to use a pre-defined probability distribution function that you can tweak so that it encodes prior information. In our case, a useful distribution could be

12. The Beta distribution

the Beta distribution. It’s a distribution that is bounded between 0 and 1, which is useful when you want to define a distribution over a proportion, and depending on its two shape parameters alpha and beta it can take on many different shapes. In the next exercises, you will take a look at the Beta distribution and how you can use it to

13. Define an informed prior!

define a prior that is informed by the new info we got from the social media company.