Bayesian Inference Fundamentals
Transcript
Welcome to this talk about Bayesian inference. It's about the fundamentals of how we find out stuff from data. So this is sort of a very high level or low level talk. However you orientate yourself, it's basically about the mathematics of logical reasoning about uncertain quantities, which we do when we analyze neuroimaging data. So I will share my slides here. And we will first look at the kinds of questions that we want to answer using data, not just in neuroimaging but in
science in general. So a few years ago, there was this article with a question, does chocolate make you clever? Eating montant chocolate improves the nation's chances of producing Nobel Prize winners, or at least that's what the recent study appears to suggest. How much chocolate do Nobel laureates eat and how could any such link be explained? Well, that's certainly an interesting finding, isn't it? But it would take a lot of evidence to convince us of something like that. Well,
let's see what the evidence is. The study that the article references was published in the New England Journal of Medicine, which is one of the most prestigious journals in all of medicine. And that already indicates a strong and interesting finding. And here are the data graphically. On the horizontal axis, you have chocolate consumption in kilograms per year per capita for different nations. So the further on the right, the nation's flag is the more the people in that nation eat
chocolate. And then on the vertical axis, we have Nobel laureates per 10 million population. And we see a very strong correlation. So the actual correlation is 0.791, about 0.8. And the p-value associated with that correlation is impressively low, 0.0001. And you can see various interesting phenomena. But then the main thing that you can see is the more chocolate is eaten in a nation, the more Nobel Prize winners they have per 10 million population. Now, how could we reason
about such a relationship and investigate possible connections between these two variables, which are both uncertain? We need a mathematical tool to do that, and the mathematical tool will be Bayesian inference and we'll return to this example. The first thing we want to understand is what question are we actually trying to answer? So I wrote here, so will I win the Nobel Prize if I eat lots of
chocolate? That's not very well defined yet. We have to refine this a bit and perhaps a sensible question to ask would be, how does the amount of chocolate I eat affect the probability that I will win a Nobel Prize? And that is now a so-called conditional probability. So in mathematical notation, that would be the probability of winning a Nobel Prize given, here I say lots of chocolate or given just a certain amount of chocolate. So I want to know the probability of winning a Nobel Prize if I eat 10 grams a day, if I eat 20 grams a day, if I eat a kilo a day and so on. So this is a conditional probability. We need to know how we operate on these conditional probabilities, how we calculate them, how we manipulate them mathematically. And for that we need Bayesian inference. So how do we calculate with probabilities? One way to introduce this, it's
not the only way, but it's, yeah, one way to do it is to look at different sets. So we have a set of possible observations and we're going to call that omega. And within that probability space omega, we have a subset A and we have a subset B and they overlap to a certain degree. Now to understand the rules of probability, unfortunately there are only three rules of probability, we need to understand
three kinds of probability. And those are marginal probabilities, like the probability of A. That is just the probability that an event in omega as a whole is also in A. And the two probabilities, the probability that an event, an observation in omega is at the same time in A and in B. And we use the notation p(A, B) for that. So what are the probabilities? That means given that we already know that an observation is in A, is an observation of kind A, what is the probability
now that it is also an observation, an event of kind B? When we look at marginal probabilities, that is basically everything covered by A. Are we in A or are we not in A? That is the only question here. Joint probabilities, we need to look at the overlap of A and B. So are we in A and in B at the same time? Now what is marginal about marginal probabilities? We can illustrate this with an example. So let A be the statement the sun is shining and B be the statement it is raining.
Not A with a little bar above, A bar negates A, B bar negates B. Now let's consider the following table of joint probabilities. And if you ever get confused about probabilities, go back to these slides and meditate a little over this table here. Basically, all or much about probabilities can be understood from staring at tables like this one long enough. So we have a table for A and not A
on the vertical dimension and B and not B on the horizontal dimension. And then we have all the possible combinations of A and not A and B and not B in these fields in the table. We assign probabilities to all of the possible combinations. So here we have the probability for A and B, the joint probability of A and B. That's 0.1. And here we have another joint probability. That's the joint probability of A and not B. That's 0.5. And let's see if this makes sense.
So A is the sun is shining and B is it's raining. And there's a pretty low probability, not zero, but a pretty low probability of that happening at the same time. So it makes sense to have 0.1 here. And then the sun is shining and it is not raining. That's about half. That also makes sense. Then we have not A and B, 0.2 and not A and not B, 0.2. And one thing we notice is that, of course, one of them has to be true. So they need to sum up to one. So the sum of all probabilities is
one. All of them in the table here together have to be one. And now we can do different sums across the rows and across the columns here. So if we want to know the probability of A, only the probability that the sun is shining, we have to add up the probability that the sun is shining while it's raining and while it's not raining. So we take the sun across this row. We want to know the total probability for the sun is not shining. We also have to sum up over it's raining and it's
not raining. And these probabilities stand at the margin of the table, and that's why they're called marginal probabilities. And again, if we sum up first across the rows and then down the column at the margin, we need to sum up to one. So 0.6 plus 0.4 is one. Now, the same for the marginal probabilities down here. I think you understood how this game goes. So the marginal probabilities get their name from being at the margin of the table such as this
one. There's nothing more mysterious about that. Now, conditional probability. In the example, what is the probability that the sun is shining given that it is not raining? So now we're saying we know it's not raining. But how does that affect the probability that the sun is shining? So we have to do a bit more thinking on that. So this can be written as the conditional probability of A given not B. So you can find the answer to the question by asking yourself out of all
times where it is not raining, which proportion of times will the sun be shining? And now it's over to you. What's the answer? I'll give you a minute or a little more than a minute. And then if any of you have the guts to venture an answer, I'll be listening. I see in the chat there are two questions. Let me see. There's one person saying I think there is a problem with the cursor position.
I'm sorry about that. Oops. I've revealed the answer. Let me go back here. Now, can you see my mouse like this? No. I can see it. You can see it. So I'm here on the margin of P of not A is 0.4. Is that does that work for you? OK. Is that cool? OK. Good. I couldn't understand everything that was said. But we have one answer in the chat. Is it just 0.5? And then probably the cursor position
is only a problem for some of you. No, the answer is it's not 0.5. So anyone want to? The cursor position is shifted. I'm sorry about that. Good. Other answers? Otherwise, we'll go straight to the reveal. We have to divide the joint probability of the sun shining, not raining, by the sum of all joint probabilities where it is not raining. So that is the conditional probability. The sun is shining, given that it is not raining. So the one thing we're interested in sun shining,
but not raining, has to be divided through all the probabilities where it's not raining. So what is the proportion of times that the sun is shining while it's not raining? Compared to all the cases in which the sun, where it's not raining. And that turns out to be, you can look at the table there, that turns out to be 0.5 divided by 0.7. So 0.71. Now, here we went and actually thought about this and then started the table and so on. But we want to have this kind of question
answered in an almost automatic way. So we want an equation for this, or a set of equations. Now, those are the rules of probability. So we need probabilities to add up to one. We saw that in the table there. Then we saw marginalization. So if we want the probability of B alone, we have to sum up the joint probabilities of B over all the possible values of A. And then conditioning, we have the
product rule. And this, you can also find this by thinking a little about the previous slide. But it turns out to be that the joint probability of A and B is the conditional probability of A given B times the marginal probability of B, or the other way around. The joint probability of A and B is also the conditional probability of B given A times the marginal probability of A. So these are axioms. They're assumed to be true. They make sense. They work. Therefore,
we cannot test them the way we would test the theory. However, we can see if they turn out to be useful. They've been around for almost 100 years and as axioms, and they've been in use for at least 200 years. So they have proven themselves useful. Another way to the rules of probability is to show that they make sense in being derivable from three basic desiderata. So there are three things that if you admit them, you also have to admit the rules of probability. I'll just
quickly mention these without going into this much further. It's an interesting intellectual exercise here. So if you admit that you can represent the degrees of plausibility of a statement by a real number, and if you admit that there should be a qualitative correspondence with common sense in a mathematically well defined sense, and if you want consistency. So if there are two ways to calculate the same thing, they have to give you the same result. So if you insist on these three conditions being fulfilled, then you also bind yourselves to the rules of probability. So there is no way to violate the rules of probability if you admit these three desiderata. Now, going back to conditional probabilities, the definition of the joint probability via conditional probabilities. We can take this equation of doing it two ways around conditional probability of A
given B times marginal of B equals conditional probability of B given A times marginal of A. And divide by the probability of B. And there we go. We have Bayes rule. And this equation is the reason why we call this Bayesian inference. So the conditional probability of A and B can be written in the way you see on the screen. And then in the second equality, we unpack the marginal probability of B by summing up over the possible values of A again. So we use marginalization here
and the product rule at the same time. And this is explained down here. So this is Bayes rule. And now why is Bayes rule so extremely useful? It allows us to invert conditional probabilities. So if we know the conditional probability of B given A, we can go by Bayes rule to the other, the inverted conditional probability of A given B. So here we have the two conditional probability of B given A. But what we're really interested in is conditional probability of A given B. In
other words, this allows us to update our belief about A in light of observation B. So if we have a certain belief about A and the mathematically rigorous way to define belief is a probability distribution. So our belief about A is represented by this probability distribution over A. And now we make an observation B and we want to know how does this observation B affect our belief about A. And the mathematical way to formulate this is that we now have a probability distribution
of A given our observation B. So what is the probability of A given B? Well, Bayes theorem tells us that. Bayes theorem tells us that we need to take our old belief about A before we knew the observation B and multiply this by the conditional probability of the observation B given A divided by the marginal probability of B. And this is all very abstract, but it will become very concrete immediately by looking at our Nobel Prize in chocolate. Example. So it's immediately
clear that the probability of winning a Nobel Prize given that we eat a certain amount of chocolate is very different from the probability of eating a certain amount of chocolate given that we have a Nobel Prize. But this is sometimes a pitfall. People often don't distinguish these two different conditional probabilities, but here I think it's immediately obvious. Now, the crucial thing here is the first one is the one we're interested in. We want to find out how does it,
how is the probability of winning a Nobel Prize is affected by eating different amounts of chocolate. But we cannot determine this directly. Imagine doing a study investigating this. You would have to take a huge number of people, perhaps even hundreds of millions of people and assign them to different chocolate eating conditions. You would have to say, okay, you are in a group that eats one gram of chocolate a day. You are in a group that eats five grams of chocolate a
hundred grams and so on. And then you would have to observe these people over decades and see in which category, how many people win Nobel Prizes and that would be an extremely rare occurrence. You would have to run this experiment for decades, perhaps centuries, perhaps a millennium, until you would have a good idea of what the conditional probability of winning a Nobel Prize given eating a certain amount of chocolate is. The other conditional probability, conditional probability
of eating a certain amount of chocolate given that a person has a Nobel Prize is much easier to determine. You can go into a survey of Nobel Prize winners and ask them how much chocolate do you eat? Then you get an idea of how much, what the distribution of chocolate eating is among Nobel Prize winners. So that you can determine. And now the magic of Bayes theorem allows you to determine the conditional probability that you have no way of getting at directly, indirectly. So
what you can do is you can determine what we call the likelihood by doing a survey of Nobel Prize winners. You can determine the prior probability of winning or having a Nobel Prize. If you just randomly grab a person off the street, what's the probability of there being a Nobel laureate? Well, you can determine that by looking at how many Nobel laureates there are still living and dividing that by the number of people on Earth. So that gives you the prior probability
of randomly finding a Nobel laureate. That's easy to determine. And then the third thing you need to determine that is the general distribution of chocolate eating in the population. And I'm certain the chocolate industry has numbers on that. They know how many people eat how much in the general population. So it would be some work to find that out, but it's not impossible. So that means all the quantities on the right hand side of this equation can be determined. The quantity
on the left hand side, which cannot be determined directly, but which unfortunately is our quantity of interest. Can be calculated now by using the quantities on the right hand side. That is the power of Bayesian inference. And that is why it's ubiquitous, often in an explicit sense, but sometimes also in an implicit sense in all of science, because every measurement we make is uncertain. All the quantities we reason about are uncertain. So the correct way to characterize our
knowledge is always in terms of probabilities and the way to manipulate probabilities, the way to get at the probabilities we're interested in is to use Bayesian inference. So Bayesian inference is just common sense reduced to mathematics or I have to get the quote right. Let me go back. Pierre Simon, Laplace. Probability theory is nothing but common sense reduced to calculation. So that's probability theory and Bayesian inference are basically the same thing. One is an immediate
consequence of the other. Good. So how does this work in neuroimaging, which we're interested in today. So we have a so-called forward problem. And that is not much of it is a problem. But basically we have a model of how brain states are reflected in measurements. So these can be MRI measurements, they can be electrophysiological measurements, whatever. Basically, we have a measurement Y given a certain state of the system that we're investigating here, the brain. So the state of
the brain theta leads to a certain probabilistic distribution of observations that we expect under our so-called forward model. But of course, when we do an experiment, the observation Y is all we have. So what we're really interested in is the state of the brain given our observation Y. So we're interested in the probability of theta given Y. And that is where Bayesian inference comes in. So Bayesian inference tells us how we get from our forward model and our observation Y
to the quantity of interest, which is the current state of the brain. So we have a generative model that goes from brain to measurement. We turn this around using Bayes' theorem and we get back from the measurement to the brain state. So turning from the brain again to Bayesian inference in general, let's look at a practical example. And let's also contrast the way things are done in classical statistics and the way things are done in Bayesian inference. And let's see some of the
pitfalls that Bayesian inference avoids that can appear when you blindly do apply, when you blindly do classical statistics and apply the rules that are taught there. So let's say you work for a company and the boss says we have to decide whether to buy certain parts from manufacturer A or B. And of course, the parts from manufacturer B are a bit more expensive than the ones from manufacturer A, but perhaps if they live longer, it turns out to be cheaper to buy from B in the
long run. So we buy some parts from A and some parts from B and we observe their lifetimes. So on the left you have the lifetimes of the parts from A and the lifetimes of the parts from B on the right. From which manufacturer would you guys buy? Anyone? Answer in the chat. Oh, I can see now that I turned to the chat, someone had the right answer to the conditional probability question for them.
That's great, Flavia. So all the answers that I get are B. Good. Let's work with that. Let's see whether that makes sense. How do we compare such samples? That's usually my next question. And since this is an online presentation, I'll just give you the most common answer myself by comparing their arithmetic means. So we just sum them up and divide them by the number of numbers. And then we get the mean and then we say, oh, this sample has a higher mean than the other sample and
so on. So why do we take means? It seems like a lazy thing to do at first perhaps, but there are actually deep reasons why it's a good thing to do. So if we take the mean as our estimate, the error in our estimate is the mean of the errors in the individual measurement. So that means the errors are going to cancel out at some point. So that is a good thing to do. And taking the mean as a maximum likelihood estimate implies a Gaussian error distribution. So that is how the Gaussian distribution was found originally by Gauss, because he wanted to understand what are we actually doing when we're taking a mean? What is the implied probability distribution of the errors in taking the mean? Turns out it is the Gaussian distribution. And that's why because he found out it was named after him. So a Gaussian error distribution appropriately reflects our prior knowledge about the errors whenever we know nothing about them except perhaps their variance.
So if we know, oh, our quantity is going to have a certain location and the errors are going to have a certain variance, then making a Gaussian assumption about the errors is the appropriate thing to do. It's sort of the most conservative thing to do. We are making the fewest assumptions in assuming Gaussian errors. So we're not introducing any knowledge we actually don't have. And this, as I already mentioned, is what is implied in taking the mean. So taking the mean is
a good idea. Except if you have more information that tells you, you should do something else. So if you know nothing more than your quantity has some kind of location and some kind of variance, then that is the thing to do. So let's pretend we're classical statisticians. How do we compare the means of two samples? Well, we'll do a t-test, right? That's what we all learned in our statistics undergraduate courses. But first, we have to consider that there are different kinds
of t-tests. There are equal variance t-tests and unequal variance t-tests. So we have to find out which t-test to do. So we compare the variances doing an f-test. So we compare these variances and we see that the p-value is 0.33 about. So the variances are not significantly different. So we may not assume that they are different. So we do an equal variance t-test. The means are not significantly different. So from this classical procedure here, I could accuse those who opted
for manufacturer B of being unscientific. So this scientific procedure here showed us that there is no difference between the means. So we may not pretend that the parts from manufacturer B live longer than the parts from manufacturer A, even though your common sense told you so. But now if you go back to your boss with this and say, oh, we can't say anything on the basis of these samples,
then your boss is going to throw that result back at your face and say this is useless because I can look at these numbers and I know manufacturer B is better. So this is not really satisfactory. Actually, we can apply probability theory to this problem and say what is the probability that the parts from manufacturer B live so and so much longer than the parts from manufacturer A on the basis of the data that we have. So let's try and do that. So this is a procedure that
is always the same and goes through a few steps that I'll mention the first time here and then a second time later. You first determine your question of interest. What is the probability that you want to determine? Then you specify your model. And that's a likelihood and a prior, as we saw before. You calculate the posterior using Bayes theorem. You ask your question of interest of the posterior, for instance, what is the probability that the parts from B live longer
than parts from A and so on. And all you need to do is the rules of probability theory. You will, of course, face technical difficulties. It's not always simple to apply the rules of probability theory. There are sometimes integrals that you cannot solve analytically. But in these days, we have software that solves all of these problems. Mostly, as long as you have enough information in your data, you will be able to answer these probabilistic questions. So let's do the first
step. Let's formulate our question properly. What is the probability that the components from manufacturer B have a longer lifetime than those from manufacturer A? Now, we can be even more specific. We can define a decision rule. We can say, given how much more expensive they are, how much longer do I require the components from B to live? And the decision rule that we will use here as an example is if the components from B live three hours longer than those from A with a probability of at least 80 percent, I will choose from B. The reason that I require them to live longer is because they are slightly more expensive. So but if they live three hours longer with a probability of at least 80 percent, I will go with the more expensive parts from B. Now, let's apply probability theory to find out whether this is the case. So the model, we choose a Gaussian likelihood. Never mind the equation here. It's yeah. You don't have to understand
the details here. I'm just informing you. We are choosing a Gaussian likelihood and we are choosing a Gaussian gamma prior. And the fortunate thing here is you don't have to do these calculations. They have been done before. You can basically look up the results. And the software does this for you. You can also solve this problem using your favorite sampler, something like Stan or Turing
if you're using Julia, PyMC3 and many solutions. So the joint posterior distributions of lifetimes, mu A for the parts from manufacturer A and mu B from the parts from manufacturer B respectively, can be calculated here. And now we can use these posterior distributions to answer our question. What is the probability that parts from B live at least three hours longer than the parts from A? So. Formulated probabilistically, this is what is the probability that the mean lifetime of B
minus the mean lifetime of A is greater than three? You can do this integral. And again, if you have determined these posterior probability using sampler, it's very easy to manipulate these samples in a way to give you the answer. It turns out that there is 0.9501 probability that the parts from B live three hours longer than the parts from A. Now let me emphasize that this 0.95 has nothing to do with a classical p-value threshold of 0.05 or anything,
because our decision rule said 0.8. So we would go with the parts from manufacturer B if this number is 0.8 or greater and turns out to be 0.95. And it also turns out that your common sense did not mislead you. Your common sense was actually right. All of those who answered, I would go with the parts from B. So here mathematics backs you up. The important thing to note here is that the t-test told us there was no significant difference between two means and two samples,
even though according to our Bayesian calculation, there is a greater than 95% probability that the parts from B will last at least three hours longer than those from A. So this is where dichotomizing your paths in the decision tree, where you first make a decision, shall I do this kind of t-test, shall I do that kind of t-test, and then you have a second dichotomy between significant difference
of the means and not significant difference of the means. If you have a succession of such forks in your decision path, you can get to a very wrong place. So a superior way of doing this is to keep the uncertainty at each step. So in the end, we ended up with two posterior probability distributions for the two lifetimes from the two manufacturers. So we kept all the uncertainty until the very end. And then on the basis of all the uncertainty that we propagated through to the
end, we made a decision. So we used probability theory to quantify our knowledge, and on the basis of that whole knowledge, we were able to make a rational decision. That is also what we want to do when we analyze neural imaging data. So again, the procedure in brief, determine your question of interest, specify your model, ask your question of interest of the posterior after propagating all the uncertainty down to the end. And all you need is the rules of probability theory. So one slide quickly juxtaposing these two approaches that I've mentioned, the classical approach is to formulate a null hypothesis, and then look at how far your observation is from the expected outcome under the null hypothesis. And if it's sufficiently unlikely, then you reject the null hypothesis. But of course, there is not a unique null hypothesis that you can test. So you have,
you often have some latitude in choosing what your null hypothesis is going to be. And you can influence the probability that will be rejected just by choosing it in one way or another. So, in the Bayesian approach, by contrast, builds a model of the situation you're investigating and looks at the posterior distribution of your quantity of interest. And then you, if you have to take a binary decision in the end, then you take you can take that decision on the basis of the probability mass exceeding a certain threshold or how much of the probability mass exceeds a certain threshold in the end. So in our case, our threshold was at three hours, and 95% of the
probability mass was above that threshold. So we took the decision in one way or another. So it's a it's a basically a very different approach. Now, having said all this and having emphasized the sort of theoretical superiority of probabilistic approach on the right. Then, I have to say that if you do classical inference the right way. So if you think enough about each of the steps along
the way that you do, you can also solve all the problems that Bayesian inference solves for you in classical ways. So, classical statistics done right. Can be a good tool and can give you the probabilistically correct answer in the end which is going to be the same way. The same answer as Bayesian statistics will give you, given you. But there are more ways to get it wrong. And in doing classical statistics, you need to know sort of more tricks and more procedures and so on. It's
not a framework from first principles. It is, to a large extent, a bag of tricks and you have to know the right tricks in order to get it right. So there are far more pitfalls on the classical statistics side. And classical statistics is in some ways also misleading name because it's younger than Bayesian statistics. Bayesian statistics was, even though it's called Bayesian and that's from the 1760s, I think. Was really introduced by Laplace around 1800,
whereas classical statistics came in vogue in the 1920s and 1930s. So, in some sense, the inference was done right before the sort of dangerous procedures from classical statistics came in vogue. And now the pendulum has swung back a little. And there's also been a great reconciliation of the approaches. And even 30 years ago there was still a kind of war going on in statistics between classical and Bayesian approaches. And because people have realized that
you can answer questions both ways correctly. This is much less acrimonious today. So, let us talk a little bit about model evidence and odds. So the Bayes rule in the formulation for odds looks like this. Now the odds is a probability ratio. So probability of A relates to the odds of A in that the odds of A are the probability of A divided by the probability of not A. So the odds of it raining is the probability that it rains divided by the probability that it doesn't rain.
So let's say if the probability is one half, then we would end up with one half divided by one half. So the odds when the probability is one half are one, and so on. And of course the transformation can be done the other way around. From odds to probability. The bookmakers offer odds against events. For example, odds of three to one on a horse imply a probability of 0.75. So it's the probability for the horse not to win. And that's just important to remember if you go
to the bookmakes. So in terms of odds, you can reformulate Bayes rule in this manner. Again, never mind the algebra. The important thing to understand is simply that you can go from prior odds to posterior odds by multiplying by the likelihood ratio. The likelihood ratio is the probability of observing, of making the observation Y, given that your hypothesis H is true, divided by making the observation Y, given that your hypothesis is not true. And this
likelihood ratio is sometimes called the Bayes factor. And this is because multiplying the prior odds with this factor gives you the posterior odds. And the powerful thing here is that my prior odds can be different from your prior odds. You may be biased towards or against hypothesis H in a different way than I am. And so we have different prior odds and therefore we also have different posterior odds. But the factor by which we multiply our prior odds to get our posterior
odds is the same for you and for me, regardless of whether one of us is more biased in one direction or the other. So the Bayes factor is a measure for how much making observation Y favors hypothesis H over hypothesis H bar. And this is used in model comparison. The fact that the Bayes factor is a measure of strength of evidence can be used for model comparison. So if we consider hypothesis, hypotheses H0 and H1, then Bayes rule for the odds of H1 over H0 is this. The probability
of H1 given our observations Y divided by the probability of H0 given observation Y. And here we have the likelihood ratio again and here the prior odds. So the likelihood ratio is the ratio of marginal likelihoods, also called the model evidence. And in terms of log model evidence, the log Bayes factor is simply the difference. So if we take the log of the Bayes factor here, then
this fraction can be written as a difference. And then we have the log model evidence of hypothesis 1 minus the log model evidence of hypothesis 0. And you will see that a lot in comparing models, DCM models and SPM and so on. So here is just for your reference, if you ever wonder about how all of this works, the algebra that gives you this. I'll just put this up on this slide. You can go back to this if you ever wonder about the algebra behind it all. An important point to
note is that you can decompose the negative variational free energy, often loosely just referred to as free energy. So people are saying, oh, free energy, free energy here and there and so on. And the precise meaning of that quantity is often the negative variational free energy. So the negative variational free energy can be decomposed into accuracy minus complexity. So it has an accuracy term and a complexity term. So a few remarks on model comparison and
its practical application. There's a range of scores that help in choosing a well performing model. So, and many of you will have heard of the AIC, the Akaike information criterion, the BIC, Bayesian information criterion. There are Bayes factors, there's log model evidence, there's free energy and so on. So, in these approaches, each model gets a particular score, which on its own is uninterpretable. So the number itself doesn't tell you anything. It's always only the difference
in score between different models that which counts, which tells you something. So, even with these tools with AIC, BIC and so on, model selection is not straightforward. AIC and BIC are approximations to the log model evidence, and they penalize complexity based on simple heuristics. And that may not reflect complexity as accurately as log model evidence or the negative variational free energy that we saw on the previous slide. Log model evidence is better on that count,
but it is also very sensitive to the modelers choice of priors. So if you go and play around with your priors, you will get different log model evidences, and that gives you an opportunity to gain the outcome of your model comparison. So, if you want to, if you attach lots of importance to the outcome of a model comparison, I would recommend looking in detail at the assumptions going into the model comparison there. The three decisive considerations when comparing models are
number one. That's the most basic one. Does the model allow me to answer my question of interest? It seems strange to state this explicitly, but you will in practice encounter situations where someone says, oh why didn't you apply model X to the data, because it fits the data much better than the model you've used. But, of course, that doesn't help you if model X that fits the data much better doesn't answer your scientific question. So you have a model because you
have a scientific question, and you shouldn't lose sight of that. Now, how do you find a good prior distribution that is a question that you get a lot that we get all the time in applying Bayesian inference. So how do we find a good prior distribution to use. And the answer to that is, you simulate from your model, you run it forward before fitting the data, and that gives you the prior predictive distribution. And you want that prior predictive distribution to cover all
plausible observations, all observations that from your background knowledge of the field that you have, makes sense. And you do not want your prior predictive distribution to be wider than that you do not want it to include absurd behaviors, absurd measurements, impossible values. So, people often have misgivings about choosing priors that are sufficiently tight because they're afraid of biasing their results. But actually the conservative choice is often a tighter prior,
because that restricts your prior predictive distribution to values that make sense. Number three, does the posterior predictive distribution of observations make sense. So after fitting your data, you repeat the exercise of simulating from your model. So now you take the posterior distributions of the parameters in your model that you have from the data. And you go back and you simulate data, artificial data, on the basis of the fits that you have from your actual data.
And then you should find the same patterns as in the actual data. And that is an indication that you've got a good model. So, rather than knocking yourself out on formal model comparison criteria like AIC and BIC and so on. If you can say yes to all three questions down there. Does the model allow me to answer my scientific question of interest? Does the prior predictive distribution make sense? Does the posterior predictive distribution make sense and reproduce the pattern
seen in the actual data? If you can say yes to that, you can be satisfied that you have a good model. A few notes on uninformative priors. I've basically already said this. General advice is choose your priors tightly enough for your prior predictive simulations only to cover outcomes that make sense. So, uninformative priors or too loose priors, too flat priors, often give you a prior predictive that is too wide that includes impossible observations. And that makes you
vulnerable to overfitting as you fit your model. And then just a quick run through applications of Bayesian inference in neuroimaging. So, we use this for statistical inference, posterior probability maps, our Bayesian posteriors. Segmentation and normalization wouldn't work without the regularization offered by Bayesian priors. So, this depends crucially on Bayesian inference. Dynamic causal modeling depends on Bayesian inference for model comparison

Ask anything
We've read this whole study set, so questions about it get the best answers.