 This is a statistics course or sometimes I joke. It's an anti statistics course It's a statistics course for people like all of you who'd rather just not take a statistics course What you'd rather do is some science or some research You're interested in natural things or birds or plants or people or the physical forces that move them and That leads you into research and then when you get into research your goal is to connect data you might collect about these entities to Scientific models that explain regularities in their lives and these scientific models Often but not always are expressed mathematically So how do we make this connection and that connection is made Through a branch of applied mathematics called statistics that the interest in this course is in the science And how the science motivates the statistical reasoning and how it connects to the data There's a book that I wrote a few years ago. It's in its second edition and in this series of lectures I'm revising this book quite actively to eventually become a third edition So if you've taken this course before Welcome back. There will be some new things and I hope it'll be worth your time What am I doing that's different? There's not a complete overhaul. It's basically the same course with the same major components There's a Bayesian core to it and that will stay What's different? I think there have become too many examples over the years And I want to trim them back to a few core examples that I can develop in complexity Over a series of lectures and do each in more depth. I want to focus much more on the workflow of doing scientific research And in testing the code we develop as we go More examples of computing the things that were really after a scientist that is hypothetical interventions And one version of that is this post stratification that those of us who also do descriptive research often need And I felt guilty over the years that very important topics like measurement error And missing data appear at the end of the course making them seem like they're optional and a lot of people Let's face it never make it that far So I want to foreground these issues because they're present in most Research projects and they deserve to be taken seriously and become a core piece of our kit and finally I'd like to do a few examples of sensitivity analysis, which is something lots of people have asked for and Something that I found very useful in my own research So if you're enrolled in the course, you'll have access to the draft as I develop it And you'll know you're working on the third edition draft because there'll be these peach boxes rather than blue boxes This revised version of the course is going to focus on three Components in all of the examples. The first is daggs. I'll explain what that is in a moment And the second is golems if you're returning to the course You know what golems are and they're still here and then the third is owls Let me explain each of these in turn for the remainder of this lecture our introductory lecture so Often in statistics, especially in Bayesian statistics courses There's lots of discussion of the differences between Bayesian inference and frequentism, which is the other Major paradigm by which Statistics is done. We're not going to talk about that at all in this course The statistics wars are over for the most part They're just a thing that boomers statisticians talk about We're much more interested in how we justify our statistical procedures whether they're Bayesian or not And that leads us to focus more on a field called causal inference, which is a very diverse field with lots of tools It's a field that puts science before statistics or rather Works really hard to make statistics serve scientific goals explicit scientific goals Often statistics is taught in the absence of scientific models, but we're not going to do that here So first and we're not going to do that because in order for statistical models Which are devices that process data to produce estimates for them to produce scientific insight They require some firm logical connection to a scientific model And so we're going to draw scientific models sometimes called causal models And in causal models scientific models Changing a variable will change only some other variables and those are what we call causes The truth is that for any given sample Um, a statistical analysis can find any cause it wants in the absence of a causal model That is people sometimes say the reasons for statistical analysis are not found in the data themselves We cannot troll through the numbers and come up with the theory or at least we really shouldn't Rather we have to put causes in in order to design the right statistical model that will give us an estimate that we're after So the causes of the data cannot be extracted from the data alone We need an additional external model a causal model of some kind There's a philosopher of science, Nancy Cartwright, who has this great slogan. No causes in no causes out So what is causal inference? There'll be lots of examples as we go through the course and there are whole books on this topic Just want to give you an intuition to start here. So often the first thing you hear about causal inference is that Correlation does not imply causation And it doesn't of course, but Causation doesn't even imply correlation. It turns out I'll have an example later on This is a deep and interesting topic to explore over many weeks The associations between variables run in both directions is the basic problem And this is what we mean when when someone says correlation does not imply causation We should swap the word correlation for association This correlation is a is a very limited measure of association. All right Variables can be associated but have no correlation. So we're going to think more about associations between variables rather than correlations But associations are are bi-directional There's no causation in them. They're just statistical measures Causal inference is about what happens when We take some Action there's some intervention that's done and then there's directionality Let me give you some examples In under two basic categories The first is that causal inference can be thought of as the prediction of the consequences of an intervention It's not just the prediction Of what happens in the absence of your intervention. It's not just Prediction of associations in the future. It's prediction of the consequences of changing one variable on other variables Or it can be thought of As the imputation Of missing observations. I'll explain both of these in turn so If you look outside and there's any wind and there are any trees Then the trees will be swaying in the wind Now you know that the wind is causing the trees to sway But those variables the the movement of the trees and the presence of the wind are merely statistically associated And there's nothing about that statistical association which tells you the causal information. It's something else you know as a person If you and this has implications for hypothetical interventions When you know the cause of say the swaying of the trees That means you're able to predict the consequences of a particular intervention. That is adding wind to make them sway Uh climbing up in the tree and swaying the branches does not create wind Well, it doesn't create very much wind to create a very small amount of local wind And so the causal inference is the what if I do this kind of question? This is the consequences of an intervention. This is very different than than pure or raw prediction Because if all you know is the statistical association between wind and the swaying of branches You can predict the presence of wind when you see the trees sway and that's a purely statistical prediction And that can be very useful. There's nothing wrong with that But causal prediction is distinct. It's the consequences of an intervention of a particular kind The other type that I mentioned was causal imputation And this would mean you know the cause When you know a cause you're able to construct or reconstruct unobserved counterfactual outcomes What if something else had happened and if you understand a scientific system And you understand the causes that drive it you'll be able to do this as well Right. So what if another country had been the first to land on the moon? What would have been different in history now? No one can answer that question That's the kind of causal imputation That we cannot do But there are more Simple systems in which we understand and we can do this kind of imputation Causal inference is one kind of research goal But it's intimately related to at least two others description and research the description of populations and the design of research projects And the thing that binds these three together is that they all depend upon some scientific model to be conducted effectively So causal inference can only be done if we have a causal model At some level of abstraction Description as well descriptive studies also depend upon causal knowledge because as i'll explain There are causes of the sample that we use to to conduct the description And research design I hope it's obvious Depends upon some causal knowledge of the system we're we're designing to study So i want to pause for a moment on this particular issue about description because i've i've found with various audiences It's not always intuitive sometimes causal inference and description are presented as opposite kinds of scientific goals And people will talk about descriptive studies and they're not going to make any causal claims That's fine. I do a lot of descriptive work. I'm an anthropologist I think probably most anthropological research is descriptive Nevertheless, this is no way out of causal modeling And the causal inference literature you still have to study it And the reason is because the sample is caused by things And those things need to be drawn with a causal logic to help you understand whether you can design around them Or calculate around them. That is that the sample differs from the population And if you can or if your goal is to describe that population that requires modeling The causes of the sample and why it differs from the population So There are going to be lots of causal diagrams in this course And these causal diagrams are called DAGs DAGs stands for directed acyclic graph. There's a picture of one in the upper right of this slide And we'll talk a lot about these in more detail in later lectures What I want you to understand now is that these are highly abstract causal models. I use the word heuristic here But you can think of them as being abstract in that the only information in it in a DAG Is uh the names of variables, which are the letters And they're causal relationships, which are the arrows And an arrow indicates that if you Change a variable at the start of the arrow It will also induce a change in the variable at the end of the arrow But not in the reverse So for example On this slide if you look at x and y there's an arrow going from x to y So if you change x Y would change according to this diagram But if you change y x would not change and those are interventions So what a DAG tells you is the consequences of a hypothetical intervention And we can use DAGs we can analyze them to figure out Which statistical models we need to answer particular specified questions About the variables in the graph and about particular hypothetical interventions And in a sense, uh, and that's all the DAGs have in them DAGs don't make any specific assumptions about The relationships between these variables. They just name influences So they don't assume that things are linear And by default they assume that all Variables interact there's everything is moderation in in the language of psychologists So they're useful for lots of reasons I'll try to demonstrate to you But one of the things that I like about them is that they answer very general questions about what we can decide Without making additional assumptions eventually we will make additional assumptions We will make assumptions about the functional relationships between these variables and that'll give us more scientific power But the DAG has usefulness Even after we do that So let's talk a little bit more about this this first DAG and this maybe looks a little bit complicated I want to break it down into the kinds of relationships that that you have to specify in these things And why we need to do it So the first let's gray out most of the DAG and just talk about the relationship between x and y So in most research or in the simplest research We're interested in the the causal effect of one variable here x on another here y and we call this The treatment x and the outcome y And this relationship goes in one direction At least at one moment in time in a time series you can have reciprocal relationships, but i'm not showing that here There are other variables in the world and these other variables Influence x and y and how they influence x and y and how they influence one another is something it turns out We need to draw it as well in order to study the relationship between x and y So there are variables like b on the right hand side here, which are competing causes of y they're they're Like x but we're not interested in them and nevertheless it can be useful to measure them these competing causes And then there are variables like a which are influences of the treatment And these are also things that we might be concerned about At times and then there are variables like c which are common causes of x and y together c to foreground things a little bit is a confound It's the kind of variable that we would want to control for in a statistical analysis so that we could correctly estimate the relationship between x and y However, variables like c and a and b have relationships among themselves and those relationships among the other variables can Confuse our regression strategies And we're going to return to this particular example a little bit later, and I'll highlight how for you So let me try to summarize a little bit so The thing about a causal model like like the dag on the screen is you can ask multiple questions of it You don't only have to ask what's the influence of x on y you can also ask about the influence of a on y and so on And and the key insight is that you will need multiple statistical models to do that that each Causal query will imply a different statistical procedure a different estimate And in many cases you will not be able to use one statistical model to answer all of those causal queries for reasons I'll teach you It comes down to the issue of choosing what some fields call control variables And it turns out that there are good controls Absolutely, there are variables you want to add because adding them controls for some confounding influence and lets you correctly measure a causal influence But it's not safe to just add everything and see what happens to the coefficients because there are also bad controls There are variables that create confusion when you add them to the model that create bias and mess up your estimates So one of the things that the dag let you do is avoid those hazards assuming that the dag is correct And another thing that the dag does is it provides a clear route for testing and refining the causal model because it's logically specified And you can deduce its implications One of the things that dag's do even independent of doing a data analysis is that they're intuition pumps They get the researcher's head out of the data out of the numbers and into the science And then we can go back into the data and make more sense of it Okay, so you have a dag you have a strategy For which control variables you want to use you still need a statistical model And in this course we call statistical models golems, which is a metaphor from the book Let me try to explain where this comes from It comes from prog So prog in the 16th century was part of a continental empire The holy roman empire and there were many learned Scholars and artists and other sorts of people there It was quite a happening place and it was all to also a multicultural community It had a large urban jewish community led by this fellow here rabbi love and there was As the legend goes, a certain amount of discrimination and blood libel against the jews of prog at the time And according to legend rabbi love used magic cabala to construct A clay robot a golem probably the one of the world's first robots and Again according to legend this clay robot was used to defend the jews against tax against libel but Mistakes were made and innocent people were accidentally hurt by it And so rabbi love decommissions at the end of legend the clay robot and swears never again to toy with the power of creation I really like the golem legend. I mean if you go to prog you'll see it's a big tourist attraction You can buy golem cookies and and trinkets and earrings and all sorts of things But it's a wonderful story Especially in the contemporary world because we're surrounded by robots of all kinds And they're not always physical. They're just software or something else But also physical robots and these robots like the golem are built for particular task But they're blind to our intent when we make them. There's nothing about their They're programming which understands the intent it can interpret it and reprogram themselves In that light and so if they're not used wisely and in only the right contexts They can do severe damage and there's a lot of ethical responsibility which comes from deploying machine learning artificial intelligence and statistical models because they're all basically the same kind of thing They're golems And we're going to make golems And hopefully we're not going to wreck prog These are our golems are computer programs But computer programs also run on clay. They run on silicon like the golem. They're powerful But they have no wisdom or foresight. They merely execute the instructions we've given them And so they can be quite dangerous when used inappropriately And I want to spend a little bit of time talking about one particular tradition and statistics Which is very golem-like in that there's nothing Essentially bad about the golem the golem didn't mean to hurt anyone Uh and statistical models are the same Uh, they're not bad. They're good for particular things They're designed with um really interesting logic and are quite powerful But they're applied in the wrong context and they're applied too broadly and they can do damage And the the tradition and statistics I want to focus on is this tradition that many people learn In their first introductory stats course Probably when they were getting their first degree in the sciences And it's this idea that you use flowcharts Answer a few simple questions and select some sort of Test for testing a null hypothesis Now I have nothing against the individual tests in this when used in the right place But this is not the kind of curriculum to train research scientists This is the kind of curriculum for basic quality control and experimental science Each of the little um devices in here like a spearman's rank correlation or a t-test is extremely useful But it's also extremely narrow This is a very limiting picture of statistics to give people and I say by the way this has nothing to do with um Old boomer arguments about Bayes versus frequentism There are Bayesian versions of every one of these procedures says has nothing to do with that It's about the tradition of teaching students and researchers these little isolated tests and letting them test And teaching them that the sole goal of statistics is to reject null hypotheses Now there are certainly contexts in which rejecting null hypotheses is very useful I think lots of experimental work for example Industrial quality control there are lots of reasons to do that But in most of research science, it is not a useful goal And I want to spend some time arguing that position for you Oh, I wanted to say something about industrial framework at the bottom Yeah, so a number of these tests are invented for industrial work, and they're very important like quality control. So The t-test some of you may know Was developed by William C. Lee Gossett who was a statistician who was working for Guinness Brewery in Dublin seen here And Guinness Brewery was one of the first really ambitious breweries to do Science with their beer and they wanted Customers when they ordered to Guinness anywhere in the world to get the same experience Every bad if Guinness should taste the same. They're like the McDonald's of beer I hope no one's offended by that because it's a compliment Right, you can go to a McDonald's anywhere in the world and the cheeseburger tastes the same for better or worse And the same for Guinness not everybody likes Guinness But if you do everywhere in the world you go it will taste the same and that's because of science They science it and the t-test was designed to do small batch testing on Guinness and it's extremely useful that way So kind of industrial control settings that in introductory statistics curriculum is extremely useful But many of us study much more complicated systems, even if they're experimental and Most of us study systems in which the the ability to do experimental interventions is incredibly limited Either it's not practical Practically impossible or it's wholly unethical And so we study observational systems and in such systems No models are not unique That is it's it's typically not possible to define a Clear and sensible null hypothesis that can be rejected What we have to do instead is design multiple process models and study their implications And so for example, I may ask you what's a null population dynamic Population dynamics is the study of how entities in a population change over time As they influence one another What does it mean for a population dynamic to be null or neutral? Null phylogenies Null ecological communities a null social network people Do reject null hypotheses about all of these things? But I don't think this is sensible Let me spend a little bit of time talking about some of these examples So in population genetics, and this is an example that that I was taught in graduate school There was this historical fight between neutral theory and well everybody else The book on the left and just as an exemplar of the so-called selectionists Gillespie the book on the right And the scientific issue here is a really interesting one. It's about population dynamics. How does dna evolve? Over time and dna molecules are complex and the question and they vary The question is why does that variation come from which forces of evolution strongly contribute to it? And Under the neutral theory of molecular evolution The idea isn't that there's no selection It's just that most of the molecular structure of dna is neutral variation non-coding variation. That's not important to phenotype Most in the population and So let's break this down a little bit So we could have some vague hypothesis evolution is neutral, which is to say that selection doesn't influence the molecule that much even though obviously adaptation happens that this is no one's denying that and That hypothesis is too vague to compare to any data. So you need some mathematical model and population geneticists Make mathematical models of population dynamics and those models have particular assumptions So if you make a process model of molecular molecular evolution where there's no selection at all, we call this a neutral model You also have to make other assumptions like how does the population size fluctuate and what's the life cycle of the organism like? You can't get away from making assumptions about those things And so one particular process model that that people studied who were interested in neutral evolution was the neutral equilibrium model The equilibrium model the population size stays the same And this implies a particular statistical test To test whether some population meets that distribution You can think about the statistical model on the right as being some distributional implication of the process model There are other process models, which you might also call neutral For example, there could be a non-equilibrium model in which population size fluctuates And it turns out you get different distributions of DNA molecules under that model And then the really frustrating thing in the history of this topic And under the vague hypothesis on the left selection matters, you can also make multiple process models And so for example a constant selection model directional selection model the kind of first cartoon version of natural selection that the biology students are taught Very unrealistic, but it's a model Has some particular Implications labeled here in three on the far right, but there's another kind of process model of selection The Gillespie and others made which in which selection fluctuates and it turns out the fluctuating selection models Can make the same distributional predictions as the neutral equilibrium model The null model is not unique And so now you can test whether evolution is neutral and it's not But the point here is not who was right It's that do our data processing correctly correctly We're going to need process models and we're going to have to look away from the goal of rejecting a null This same kind of drama has played out in multiple fields. So in ecology in the study of biodiversity, there was this Theory of the the unified neutral theory of biodiversity Which is just sensitively the neutral model applied to ecological communities the idea that there are no species differences structuring communities Um, unfortunately, this has the same problems. It's not Really a causal model And the quote I have here on the screen is one of my favorites is from James Clark Equal probability is not a theory, but a lack of one It does not include or exclude any process relevant to coexistence of competitors models lacking explicit species can make useful predictions But this does not support neutral theory All right, so the the predictions of a of a particular model lacking forces Does not show that that's the model that's that's Producing it. We need other causal models and and we need to look at where they're different Even a little bit older in the late 70s and early 80s in ecology There was this fight between some giants in ecology, uh, cymbal often and diamond were the Most aggressive in this as I understand the history and the idea here was they were interested again in community ecology Which species co-occur the study of coexistence? and a competitive exclusion and um Connor and cymbal off had a method of permuting matrices like the ones you see the one you see on the right here of the presence of species in particular locations to to test and reject null models of whether species Co-occurred or not And The basic problem here is well these messages don't work. Uh, there's no argument about that now and diamond and gilpin Wrote a quite aggressive takedown of it here. You could quote the null hypothesis analysis by connor and cymbal off They is characterized by hidden structure inefficiency lack of common sense imprudence And statistical weakness and ultimately by a scandalous disregard for their own procedure. Wow Okay, so I don't think we should write criticism in this tone But it is true that the connor cymbal off procedure just doesn't work It has very low power and a very high false positive rate And the basic problem is there is no unique way to permute a matrix To meet any particular null model There's a lot of information built into a data matrix like the one you see on the screen That cannot be permuted away And this is a huge problem Now we can study species co-occurrence, but we can't do it by creating some artificial null matrix With the species present in it The same problem arises in the study of social networks in other case where there are permutation methods People used to use these permutation methods because that's all they knew how to do But again, they just don't work. They don't do what they claim to be able to do So here's a paper from heart at all recently in 2021 which summarizes this which has been known for decades actually These methods like quadratic assignment procedures simply do not statistically Do what we think they do and the reason is because there is no clear unique null network More recently another example just a primary imagination. So you may have heard um that uh neanderthals which were uh Well, some people say the same species some people say a different species Let's just say they were very very similar to humans And they lived mainly in europe and also in the near east And are now extinct and you may have heard that all humans outside of africa Have dna from neanderthals that which seems to suggest that neanderthals and modern humans interpret um so All living humans evolved in africa after neanderthals evolved in europe and so One model of the interbreeding is that and you see this on the map when modern humans Arise shown in red And leave africa they they Interact with neanderthals and they interbreed and they have some families together eventually neanderthals go extinct But the surviving humans carry that neanderthal dna with them There's no neanderthal dna in africa because modern africans They're just as modern as the rest of us never had that population history of interacting with neanderthals So it's something like two or three percent in in people like me of of european ancestry And we study this at my institute here in leipzig for example. Well, I don't my colleagues do Uh, but there are other Um hypotheses here. It's not sufficient here to simply test the null hypothesis of no neanderthal dna In modern humans outside of africa, which you can reject you can reject the null hypothesis that people like me don't have any neanderthal dna Okay, and the early papers on this topic. That's what they did. They rejected the null hypothesis Of no neanderthal dna There's not a lot, but there it's there. It's not zero But there are other process models consistent with the same fact So for example There could be neanderthal dna What looks like neanderthal dna and people like me because of ancient population substructure in the human population There are lots of humans and they're geographically really dispersed and local populations have different neutral molecular variation That we can use to identify people from those places. This is neutral variation. It doesn't offend influence phenotype at all But it lets us track who's related to who and so neanderthals Also left africa The ancestors neanderthals also left africa long ago And then the ancestors of modern humans After that and in that process they would have both passed through Northeast africa where it connects to asia and so any substructure in the african population Could be transmitted to both groups any group leaving africa And so we could share what looks like Neanderthal dna with neanderthals because we we and neanderthals both got it from Northeastern african populations which are now extinct And this is called the ancient substructure hypothesis And both of those are consistent with rejecting the null hypothesis of no neanderthal dna So it's just not enough to study these processes that way Now you can test these two hypotheses against one another But you have to consider them as process models and see what implications they have and then look at the data differently You can't just reject the null hypothesis Okay, let me try to summarize some of that. I know it's a lot And those examples were just meant to to show you in realistic research contexts That this null hypothesis framework is very limiting and we want to think instead of scientific models and how to Introduce those scientific models to data by analyzing them to design golems And those golems at least in this class will not be designed to test the null hypotheses. They'll be designed to do much more What we're going to need to make those golems are generative causal models Not just daggs daggs don't have enough Details to them to be generative generative means you can simulate data from the model So we're going to start with daggs, but then we're going to turn them into generative models that can produce synthetic data And then we're going to write statistical models That can analyze the synthetic data to begin with to produce certain Goals called s demands to answer particular questions And then once we're sure that the model works in principle on the synthetic data Designed in light of a specific transparent generative model, then we'll introduce the real data to it So let's come back to the dagg and walk through this in a heuristic fashion and think about this this issue of justifying controls So one of the things about statistical modeling Is that we're interested in a relationship between two particular variables say x and y And we know we have other variables. Should we use any of them in the analysis? And This is this is a kind of question I'm going to assert and teach you cannot be answered in the absence of a generative model Or at least some kind of causal model What's the basic problem? Well, there are lots of particular say regression models those of you who have already had a course in regression Models that model y Uh using its association with multiple other variables. So on the left here, I've listed some of the possibilities here We could have a model where we only Look at the the association between y and x Which is the relationship of interest We could have one where we also add the variable a the second model on the screen We could look at a and b together with x we could do x plus c We could do x plus a and c x plus b and c and i've left off the one that has them all Um Which of these should we use and this is one of the most common Questions that we have and apply statistics is which covariates or controls to add And you cannot decide this without at least a dag and Hopefully even more than that some more generative model that specifies the shape of the relationships among these variables Uh and the reason is because the relationships among the variables cause problems for us when we add control variables What we want to do and i'll teach you in later lectures is analyze the graph like this So that we can deduce given the the assumptions in this graph Which control variables are good and which control variables are bad In this particular example, you know, I won't explain this today, but i'll show you uh in a future lecture The correct adjustment set is what it's called Is to Include the variables b and c in the model to stratify By b and c when examining the relationship between x and y and again I'm not going to explain today why I just want to wet your appetite for it in a future lecture. I'll explain Why only these two? Okay, so we've used the dag. We've analyzed it. We have our adjustment set. This is not enough Um and I mentioned before we want a generative version of the causal model So we can design and debug our code and we're going to do that in even the first example in the next lecture And then we need some strategy to Create an estimate and there are different ways to do it That is we need what's our uh Strategy for coping with finite data to study something about a population That could in potential produce infinite data And how do we properly characterize the uncertainty in the estimate we produce? And the easiest approach At least I feel is Bayesian data analysis. I don't use it out of some philosophical commitment I use it because i'm a scientist and Bayesian data analysis lets me take the generative assumptions in my scientific models And confront them with data with the least fuss So I have to admit that uh, um Sometimes Bayes is overkill and often I think a problem in courses that teach Bayesian statistics is they teach very simple examples where it There don't seem to be any real advantages of the Bayesian approach So Bayesian linear regression extremely similar to non Bayesian linear regression But there's additional fuss. So this is a bit like cutting a birthday cake with a chainsaw. It works It's stylish. It produces a lot of additional mess. You might as well just use a cake knife But the interest in Bayes here really is practical because outside the birthday cake scenario in a realistic analysis Like you need to cut a tree down Bayes can do it So what do I mean to carry this this metaphor forward? In realistic analyses, we routinely have to deal with measurement error missing data latent variables and goals like regularization and I'll explain what these things mean as we go forward, but Uh, these these are not exotic problems. They're routine problems in scientific research, especially at the cutting edge where we're just figuring out measurement And Bayes has very natural and comfortable ways to deal with these problems Um, you can do it in other in other frameworks, but it's harder Uh, and so um Bayes has we got has gotten a lot more popular in research in recent decades I think exactly for this reason is that the interest is practical not philosophical whatever philosophical commitments people had one way or the other Uh, uh, we don't discuss those things so much anymore And in particular one of the nice things about Bayesian modeling is that Bayesian statistical models are generative They can simulate data like a causal model And this allows us to express our Bayesian statistical models to a very close identity with the causal models of interest So I hinted at this just now. I think the statistics wars are over. They feel like they're over at least, um There was a time when Bayesian statistics was controversial Uh, uh early 20th century Um, but it's that's no longer true. It's extremely mainstream now I mean, there are some fields like social psychology where it's still considered a bit taboo people tell me But in biology, uh people if they use a Bayesian technique They'll often put it right in the title even or or at least in the abstract because it's a bit Uh prestigious to do it. Uh, I don't think it should be necessarily just probability theory as I'll I'll teach you in the next lecture But the point is the wars are over and we shouldn't talk about Bayes frequentist combat any longer um I do think there's a problem with University curriculums still catching up most places There aren't dedicated teaching slots for people to teach applied Bayesian data analysis But we're getting there It's becoming much more common because people are using Bayes more in their research than there are classes to teach it And this creates problems in use and leaves people feeling that they don't have a floor beneath them Uh, so it's just going to take some time, um for the curriculum to catch up. Uh, but we're getting there I also think that that a lot of the research innovation the action is in machine learning circles now And they have their own battles to fight. Uh, so we can we can let the remaining Boomer combatants fight about Bayes and frequentism. Uh, let them fight. Uh, we have our own battles Okay, last topic in this introductory lecture. I want to talk about owls Um, so some of you have seen this internet joke about how to draw an owl The joke begins by saying well step one you draw some circles one Uh, or rather ellipses one for the head and one for the body And then step two is you draw the rest of the owl Okay, ha ha I think the joke is funny. At least it was the first hundred times I saw it I want to use this as a metaphor for how we teach. Well Computational tasks in in research not just, uh, statistics, but all kinds of programming and technical things are often taught like this There's some guide to how to do it and and they tell you how to do the initial steps And there are a bunch of steps between one and two here That seem to go by really fast. Uh, so we want to move more slowly We want to draw out all the intermediate steps In drawing the owl so that the student has some hope Of finding out which part which step they're having trouble with And learning effectively and this naturally means it takes more time It takes more time both from the teacher and from the students But it's much more successful. Uh, when you want to draw the owl to get all the steps And we're interested in documenting our steps of drawing the owl So to speak and what this means is we're going to have an explicit workflow Where we set up our code so that we have our generative simulation in step one and we write an estimator in step two And then we validate that estimator in step three using the simulated data and then step four We analyze real data and we have all this documentation in the flow And then I'll show you some other step fives and things we'll we can reuse The step one code to do things like compute hypothetical interventions and other very useful tasks Drawing the bayesian owl It's necessary because scientific data analysis is a very bizarre kind of software engineering It's like software engineering done by amateurs who've not been taught anything about software engineering Right. This is an unfortunate state of affairs, but most data analysis in the sciences Now Is done with scripting. Uh, there are some people who do point and click and that's terrible for reasons i'll get to But scripting is a kind of of programming a simple kind of programming and you should approach it like that and Test that the software works and document it and comment it appropriately Um, we want quality control and quality assurance So there's kind of three modes to drawing the bayesian owl that we'll do in this course The first mode is you want to understand what you're doing and breaking it down into steps and having a recipe and a workflow That you that you hold yourself to is extremely useful for that Otherwise, you'll just have a salad of code and it'll get lost in which version of the code you need Lots of people have done that. Uh, hopefully they only do it once and they learn from the experience Um Documenting your work reduces error. This isn't this isn't just about understanding. It's about reducing scientific error as well And giving your colleagues some faith that your that your code actually works Uh, and so on. This is the most important part of this is uh, we're professionals and we should behave Professionally, we want a respectable scientific workflow that we're not afraid To describe to our colleagues, right? What we don't want to do is be asked to see the research code and say Well, I'm not sure I can find it and then you find it and you can't find out which script It is and you're not sure how this works and you can't get it to run There's too much of that going on in the sciences and we must stop This is a profession Right, the public isn't paying us to goof off We want to work responsibly so we can get things right or so when errors arise and they always do We can find them and correct them so, uh The steps of the the basic drawing the bayesian owl are first we have to define some theoretical estimate What are we even trying to do in this study? Then we're going to use that to design Some scientific model a causal model and this can start out as a dag, but it eventually needs to be generative Um, we use steps one and two to build some series of statistical models Which address the specific estimates that can be justified in light of the causal models in step two And then in step four we do testing we simulate from the generative model to validate that the estimator works And then in step five we analyze the real data and there may be additional steps after this We might decide to loop back and revise the causal models But as long as we document all that this is the workflow that we want to draw the owl Okay, that's really all the material I wanted to get through in this first lecture talking about dag's golems and owls just to review The point of dag's this is a stand-in for all kinds of causal modeling Not just directed directed acyclic graphs dag's and other causal models provide transparent scientific assumptions To communicate those assumptions to our colleagues. They allow us to inspect them ourselves and this justifies our effort It exposes our assumptions to critique and it lets us logically build golems statistical models That can credibly get at the estimates we declare And these golems, uh, this is my metaphor for models statistical models in this course. They're brainless powerful statistical devices We need them, but we have to use them responsibly and ethically And then finally owls. This is our workflow We're going to hold ourselves to a clear workflow that integrates dag's with golems and documents it So we provide some quality assurance so that our colleagues and the public can take our work seriously So I think there's a strong argument for reciprocity between all the stages of this and I tried to illustrate that jokingly on this screen with rock paper scissor think about the relationships between theories and and Scientific theories allow us to to design statistical models statistical procedures that can that can test their assumptions So theories in a sense dominate models models Are needed to process evidence and then evidence critiques theories so no single part of this workflow and Scientific theorizing in general Is more important than all the others and every little bit of code you write in statistical procedures Is just as important as the grand theorizing That the greatest scientists have ever done Because it can well kill theories And so we're going to go forward in this course and i'm going to teach you how to kill some theories We're going to have 10 weeks of instruction I might revise The particular topics in each week a little bit as we go because remember i'm i'm rapidly revising for the third edition as I go But I think they'll mostly be this organization Up through the first five weeks. It's basically a course in regression in Bayesian regression in light of causal inference So i'll teach you how to use daggs and teach you about confounders and colliders and fun things like that And the second half of the course we get into more specialized topics and talk about Multi-level models and latent variable models and social network models and phylogenetic models and other sorts of things But the tools all the way through it's the same basic golem engine that I will teach you in the next lecture