 statistics and excel statistical inference questions of how close and how confident got data let's get stuck into it with statistics and excel introduction to statistical inference statistical inference is the process of use first a word from our sponsor yeah actually we're sponsoring ourselves on this one because apparently the merchandisers they don't want to be seen with us but but that's okay whatever because our merchandise is is better than their stupid stuff anyways like our trust me i'm an accountant product line yeah it's paramount that you let people know that you're an accountant because apparently we're among the only ones equipped with the number crunching skills to answer society's current deep complex and nuanced questions if you would like a commercial free experience consider subscribing to our website at accounting instruction dot com or accounting instruction dot think of it dot com send data from a sample to make estimates or test hypotheses about a population you will recall from prior presentations we talked about two major buckets or categories of statistics the first bucket being where we know all the information we have all the data our goal is to try to organize that data in such a way that we can draw meaning from it using tools such as mathematical tools like calculating the average or the mean the median the quartiles and so on and using pictorial tools such as the box and whiskers or box plot and the histogram the second major bucket of statistics what we're focused in on now is where we don't know all of the data for the entire population however we might be able to get like a sample data of the population and what we want to do there is to try to extract meaning from the sample data that we have once we have extracted that meaning we're hoping that we can infer some of that meaning onto the entire population so inference the major thing that comes to most people's mind is an election type of situation where people the pollers are trying to take polls to determine what the results of the election will be by taking a sample of the population and seeing if they can infer the results they have there to what's going to happen in the entire voting population when the actual election happens so note in this type of statistical analysis the actual sample that we're looking at the data that we're actually analyzing is not the the goal that's not the important point those people are not important in and of themselves they're important as people but not for the statistical poll what we're getting at what we're trying to get at is the inferring of the entire population we're looking for meaning for the entire population so we're going to use similar tools as with the first bucket of statistics where we're just trying to extract meaning if we already know the entire population meaning for the sample we're still going to be looking at things like the average the mean the median and so on the spread of the data but what we're hoping to do once we know that is infer that on the entire population so we have predictive power about the entire population so the key goal is to provide an approximate description of the larger population based on the observable data from a smaller sample so the small sample it's not our goal to just know everything about the small sample we want to know information about the small sample so that we can infer that to the larger population so how close the shape center and spread of just some of the population is to the shape center and spread of the whole population you will recall from prior presentations oftentimes when we're looking at a data set what we want to get from that data set is what's going to be the middle point of of the data set what's going to be the shape of the data set and so on and so we want know those characteristics for the sample but not so that we can understand the sample more but so we can infer that and say is this going to be similar for the entire population it's the entire population that is important although we're going to be analyzing of course the sample in a similar way as we did when we knew the entire population and we're just trying to get an understanding of of the data that we have and then this question of how confident we are gets to be quite tricky and we'll dive into that more in future presentations we just want to get an idea of what we're doing with the statistical inference here but if you take the sample then the questions are you know can we infer that sample to the entire population and how confidently can we do that can we do that with a certain level of competency the more we can get numerical data about how confident we are then the better predictive power we have the better tools we typically have as well so practical applications of statistical inference so clearly the election polling is usually the first thing that comes to people's minds oftentimes and in that situation when an election is impending it is not feasible to ask every single voter who they will vote for so clearly when you're trying to predict the results of the election we can't just ask everyone because that's basically we would be taking the election at that point in time so what we can possibly do is have pollsters take a sample say a thousand voters and based on their responses try to estimate the voting pattern of the entire electorate so of course they're going to try to get a sample and see if they can get the data on the sample and infer that results to the entire population so it is the challenge of statistical inference to extrapolate from the small sample to the larger population that's what our goal is going to be so for the medical trials is another common example so anytime we're doing any kind of scientific scientific kind of testing a hypothesis testing approach which is kind of like the foundational thing that you're going to do in science what is going to be a statistical kind of kind of test oftentimes right so in medicine for example in testing a new drug it is not possible to test the medication on the entire population so if we're trying to say is this drug effective if i if someone takes this drug will it do what we think it's going to do well we can't take the entire population even the population that is sick with what i do is take a smaller group uh and then and then test on the smaller group now obviously there's a lot more to the testing than this that will get into in future presentations because you have things like a placebo uh kind of effect and when you get into the pollster testing you have things like can you reach the entire population and so on and how exactly are we going to pick the sample so we'll get into all of those kind of nuances in future presentations which are very important nuances they're not just minor things but you get the general gist the idea of what we're doing here so based on the reactions of this group we infer the drug's efficiency and its potential effects on the larger population all right let's take a look at a scenario imagine that we have height data for a specific group of adult men and our objective is to gain a comprehensive understanding of the height distribution for all adult men now height is a is a good one to test out oftentimes when you're first kind of looking at the concept of this inference type of analysis because uh one the heights normally will come to somewhat of like a bell shaped distribution in other words most people when you look at the height of men for example are going to have you know 10 toward a middle point most people are going to be somewhere on an average height and then you have the the distributions somewhat around the average and as you as you get towards very tall or very short then it's a lot less likely there's a lot less people that fall into that category so it has that distribution that that is kind of a bell shaped type of distribution also people already have kind of a sense of what the height distribution should look like just from observing people so you kind of have an idea of what you expect to be happening and then with you when you run the testing you can you can kind of see that in your mind however note that of course with many other kind of tests that we we might run we might have different distributions of the data and if we might have no idea what the effective you know what what the what the results will look like we might be testing something that we have no idea but it's good to start with kind of height so we could potentially select a small number of men whose heights seem to reflect the heights of all men so you might say hey look if i was to take a sample the question of course will then be how am i going to take a sample of men i can't test all men in the population to see what the average height of of men are but what i could do is take a sample well how am i going to take the sample well i had you might say i have an idea in my mind of basically how tall people are so why don't i just choose in my sample men that i think look about average and then i'll and then i'll select men that have a distribution that i think is about right that mirrors the actual distribution and then it'll be easy for me to pick my sample however uh we're starting with a lack of knowledge about the overall distribution of heights across the entire population of adults so the problem with that of course is you you're assuming that you know the answer to what to the problem that you're trying to solve right so you can't so if we if we already knew the answer of the middle height then of course picking a sample would be easy it would also be defeating the points because we would just simply be picking a sample that ties out to the actual height and it seems like kind of obvious however uh you'll this this kind of thing happens sometimes right because we start to think well if i'm going to pick a sample it would be better since i already have some knowledge about the sample it would be easier if i just picked people that i know are kind of in the middle already but clearly by doing that then you're inserting your own bias into the sample and that's so you're trying to help things out in that case because you think you know something about the world and you're going to pick a sample that kind of reflects what you already know but in doing that then of course you're putting a bias into the sample and that's going to you know cause a problem and if you're wrong about the assumption then of course what your bias in the in the sample is going to mess up the whole thing so the whole point is then that you have to have some kind of randomness involved so this is going to be the key for the statistics when we pick the sample we have to have randomness now sometimes you could have different kinds of picking uh uh that could it be more complex than just simply total randomness but there's always going to be some format of randomness uh in in a sample whenever we're picking it because we don't we want to remove the biases when we pick the sample so we're going to have we're going to use the idea that we don't know we're going to say i i know i don't know right it's tough thing to do i know i don't know i'm not going to try to help when i know i have no idea what i'm doing right that i'm gonna i'm gonna use the idea that i have no idea and then i'm gonna try to pick completely randomly and and then we'll see then we'll then we'll go from there and then we'll have an unbiased kind of set of data would be the idea so randomness random selection is crucial to gathering the representative sample so this this key is going to come up again and again if we're trying to say i want to take a sample that's going to tell me something about the entire population i have to generally you have to use randomness in some way shape or form to pick the sample uh and that's and and that can be more nuanced so we'll talk about problems do that more in the future but that's the key concept so the concept of randomness ensures that every individual in the population has an equal chance of being selected in the sample now in some cases you might be able to do that in other cases you will not in real life if you're taking a poll for example for voting it's going to be very difficult to say that everybody in the population the voting population has an equally chance of being selected it's because you how are you going to do that you get you only have their phone number right you don't know it's going to be difficult uh to contact people that maybe they don't use the phone anymore maybe they contact by you know messages or something or something so it's going to be difficult so in the real world when you when you actually apply these this concept we have to of course adopt it to what is what is practical as well and take into consideration the the effect of that but the concept of course would be that i would like to have to have everybody in the population to have an equal chance of being selected so that i have a true random sample of the population so this reduces bias improves the real uh improves the reliability of our inferences about the population so estimates and confident and by the way just we'll get into this more in the future but just note of course like with the polling for example if you only poll people that have a telephone number in the phone book then a lot of people these days might not have a telephone number in the phone book or or they might not answer their phone and the people that are likely to answer the phone and have a telephone number in the phone book and are actually willing to talk to a pollster you know might have different voting patterns than other people right there so you can see why there's a there's a problem sometimes that we have to take into consideration when we're applying these concepts in the real world so estimates and confidence intervals statistical inference provides us with an estimate of population parameters like the mean or the proportion but it also provides a range of values around the estimate that is likely to contain the true population parameter so this range is called the confidence interval and the likelihood that this interval contains the true value is called the confidence level so if i analyze for example a a sample of the population i can get a mean a mid value for that sample i can get the distribution of the of that sample but then the question is well if i try to infer that answer to the entire population how confident am i of the results that i have and that gets to to be kind of a more of a nuanced question and we would like to lock that down as much as possible mathematically if we can because because the level of confidence will give us a lot more kind of predictive power if in the future so for example we might be 95 confidence that the population mean lies within a a certain interval so you've probably heard when you see statistical testings where 95 percent confident or there's a five percent margin of error or these kind of terms those are going to be more technical statistical terms we'll talk more about in future presentations right now we want to get down the idea of taking the sample data and and using that to infer onto the entire population once we get good at doing that once we have that conceptually down what we would like to do is to get as clear in terms of mathematical tools as possible using statistics so that in probability in essence so that so that so that we can be more confident right then we can if we can use statistical equations then we usually have more predictive power and confidence going into the future so probability theory is a theory in statistical inference so probability theory is the backbone of statistical inference it provides the language and the mathematic tools needed to quantify uncertainty and to make educated guesses so we're using the mathematical tool when we're looking at statistical inference of probability theory so it provides a means to quantify how likely or unlikely the observed data would be assuming a particular statistical model is true so note what we're what we have to do if you if you look at something from a scientific kind of approach usually if you go into a laboratory for example what they're trying to do is isolate everything that has an impact to a few different impacts on a particular item whatever they're testing right so that so that then they can see the cause and effect of the one of the one thing that they're looking at so they're trying to isolate everything so that they can look at the cause and effect when we look at kind of predictability in the real world we have to make similar kind of assumptions we have to basically say well here's the statistical model that i'm putting together certain assumptions are going to be made in the in the statistical model to make project projections predictions about future outcomes for example in an election and if these assumptions are true based on then then the then we can come up with a mathematical approach of what the result will be but of course a model is is just a model so a model is not the real world because usually in the real world unlike with a lab we can't trim everything down to just a couple factors to test a couple factors so we have to make of course assumptions and then the question is is the model that we put together does it have good predictive power for for the results for the entire population or not so it's going to be independent on the model and no model is perfect because the model is not the real world it's just a model hypothesis testing hypothesis testing is another key element of statistical inference where in essence we form two opposing hypotheses about the population the null hypotheses and the alternative hypotheses within collect data and compute a test statistic so clearly hypothesis testing is a core scientific tool if we were to go back into our laboratory for example and run a scientific test to see whether or not a particular element causes a fluid to turn green what we would want to do is try to remove all other factors on the fluid form a hypothesis that being the null hypothesis nothing's going to happen when we add the elements to the fluid and then the alternative being that it changes colors that it turns green for example and then we're going to run multiple tests from that point to see what happens is the general idea so depending on the value of this test statistic we decide whether to reject the null hypothesis in favor of the alternative this process allows us to make statistically informed decisions about the population based on our sample data so let's take a look at an example here so we want to be determining the fairness of a coin that is whether it is equally probable for the coin to land on heads as it is to land on tails so in other words we're given a coin a quarter for example and if we flip the coin multiple times we would expect that there's going to be an equal number of times that it's going to have heads versus tails or at least the probability of it landing heads and tails should be equal that would be the assumption we would have and that would be basically our null type of assumption and the null assumption oftentimes would be things are going to be as is right the standard type of assumption and then it would be more unusual generally if the coin did not land statistically speaking on a 50-50 chance so what are the chances that the coin is not fair that it's more likely to land on heads for example than on tails well what would we do in order to test this in the real world we can't flip the coin infinitely many times uh because we don't so we don't know all that the entire population of the coin flips but we could run tests on it we could run multiple tests and the way we would structure the test is to say like we do with the laboratory test we would say well the hypothesis is going to be the null hypothesis is that it's fair it's going to be 50-50 and then we're going to get the preponderance of evidence and if the evidence is such that it's going to be different than that the evidence is showing that it's not fair then we're going to have to change our assumption and notice that that i've heard this compared to like a legal type of procedure in the american justice system right if someone goes into a court for example for a crime they're supposed to be innocent until proven guilty right they're innocent until proven guilty so the innocence is kind of like the null assumption and you're kind of leaning towards the null assumption so it's not like most of the time when we run these these types of tests uh people might say something like well you can't prove that it isn't or something like that and it's like well no uh the coin we're assuming is 50-50 the preponderance it's on you it's your job to prove that that is that is not true with a preponderance of evidence the assumption is the null assumption the assumption is the null you have to give me evidence to that's sufficient to remove me from the null assumption you can't just say well you don't you're not you know you don't know either way kind of thing we'll know that they're just like in a court case where we say no that he's the citizens are innocent unless you give me a preponderance of evidence that is sufficient to overturn my my prior assumption same thing is happening here right we're saying the null assumption we assume it's 50-50 I have to have enough evidence you have to prove that that's not the case it's not enough to be even it's not enough to say well you know it's you know it could go either way no you have to prove it okay we know that so to investigate this we essentially put the coin through a test so we flip this a hundred times and keep track of how many times it lands on heads and how many times it lands on tails this process provides us with the randomized data about the likelihood of getting heads or tails in each flip so notice we're doing we're doing probability kind of concepts here and we're applying you can see how that's applicable in a statistical type of analysis because we're basically saying there's an infinite you know number of coin flips right there's an you know the the probability we don't know it because we don't know the infinite set of data if we flipped it like an infinite number of times but we can test it out for multiple times of flipping it and then and then and then get our results and see if we can infer based on the whole population which would be kind of like an infinite number of flips and see whether or and so if we get evidence for example if you just flipped it 10 times that might not be enough right because you get if he comes out 60 40 and you flipped it 10 times you can say well yeah it's not fair but that could happen just randomly speaking so now the question comes up what is a sufficient ponderance of evidence how many times would you have to flip it right and how and then these questions come up right so how close and how confident are we once we get our data if we got 10 flips and the middle the the middle point was was 60 percent or something instead of 50 you know maybe we don't have enough confidence to really remove remove me from the presumption of the null assumption similar to the presumption of the innocence but if we did it a multiple hundred time tests for example and they're averaging out or coming out to 60 more closer then then now you're coming to a preponderance of evidence where it's like oh i think the null i think i have to remove myself from the from the null just like we would if someone says well i've clearly have evidence of this person committing the crime it's on tape he's right there he's he's flipping off the camera right there you could see him as he's stealing the stuff and beating the guy up or something right so there okay i think i have to remove from my innocent you know to the to guilty okay so conclusion overall statistical inference is a set of tools that allows us to use sample data to make generalizations about an unknown population so randomness and probability theory are at its core enabling us to quantify our level of uncertainty make educated guesses and test hypotheses about the population statistical inference is fundamental to many aspects of life including science economic medicine business and even politics so these obviously these kind of concepts are coming come up all the time so whenever we read anything whenever someone gives you advice or something it's usually going to be medical advice you know business advice investment advice career advice we kind of assume that they've got some kind of statistical rationale for it in some in some way because that's that's usually how we think of of making a lot of these kinds of decisions so it's clearly a very useful important tool in many different areas of life and profession