 Hello, this is a video covering the goodness of fit test So what is a goodness of fit test a goodness of fit test is actually used to test the hypothesis that an observed frequency distribution fits or conforms to Some sort of claim distribution. So what does this test exactly good for? Well One thing you could do is say you have a friend and you think your friend decided to create a weighted or a loaded die Meaning the die will always land on five or may always land on three whatever side the die is weighted towards You can actually use this test to determine if that die is fair or if it actually truly is loaded or weighted So the requirements for this test are that the data have been randomly selected the sample data consists of frequency counts for each of the different categories and for each category the expected frequency Not the observed but the expected Frequency has to be at least five There's no requirement that the observed frequency has to be at least five just expect So oh capital O represents your observed frequency for each of the outcomes or categories Big E represents the expected frequency of each outcome or category K is the number of different categories for instance when you're rolling a die the number of categories or outcomes is Six little n is the total number of trials and this x squared looking thing It represents the test statistic. It's actually called a it's actually called Chi squared Chi squared test statistic The X looking thing is actually the Greek letter Chi CHI Still learning Greek to this day Here are the hypotheses for the goodness of it test The null hypothesis is that the frequency counts agree with the claim distribution so observed and expected frequencies equal each other and then the alternative hypothesis is that the Frequency counts do not agree with the claim distribution. So observed and expected frequencies are not equal to each other Statistically significantly not equal to each other and how do you calculate the test statistic the Chi squared test? Statistic is found by taking the observed frequency and subtracting the expected frequency for each category Squaring that value Dividing by the expected frequency and then adding up all of those values We're not going to spend a lot of time or any time calculating the test statistic by hand Just know that it is a little bit of work, but it's not impossible. Technology is going to calculate it for us So how can we form a conclusion about our hypothesis test? Remember the p-value method if the p-value is less than the significance level alpha we reject the null hypothesis There's also the critical value method The critical value method we found will be found from what is called a Chi square table using k minus 1 degrees of freedom Number k is the number of outcomes or number of categories and Just FYI a goodness of fit hypothesis test It is always right-tailed because of the shape of the Chi square distribution It's got this big peak and then it's got this tail that lingers off to the right You'll see a picture of it in just a minute And here's the criteria for the critical math critical value method If the test statistic falls within the critical region, which is the region separated by the critical value We reject an all hypothesis We will pretty much resort to the p-value method All right So if you have close agreement between the observed and expected frequencies Then you're going to get a small value of Chi squared of your test statistic and a large p-value If you see large disagreement between observed and expected values This will lead to a large value of Chi squared and a small p-value So the two are inversely related to each other if you have a large test statistic You'll have a small p-value if you have a large p-value. You'll have a small test statistic So therefore if you have a significantly large value of the test statistic Which means you have a really low p-value It will cause rejection of the null hypothesis So how will we do this well in Google sheets? We're going to go to the Chi square tab and We'll type our information. It will be given to us in the form of a table We'll pick the appropriate type of test, which is goodness of fit and then It'll give us the information we need So in our first example, there are five different categories with observed frequency of each category given at a significance level of point zero five We are actually going to test the claim that all five categories all occur with each of the following proportions So out of all the observations Point three of them or three tenths of them will be from category a We expect that point one from category B point two from C point one from D and point three from E We'll conduct the hypothesis test. We will provide the test statistic Provide the critical value provide the p-value and we'll even state the conclusion First stop is the hypothesis The null hypothesis is that the frequency counts agree with the claim distribution In other words are observed frequencies equal or expected frequencies. That's our claim We're trying to see if the expected frequencies as broken down by the point three point one point two point one and point three The proportions agree with what we observed The alternative is that the frequency counts do not agree with the claim distribution observed frequencies do not equal the expected frequencies So what we need to do is we need to calculate the expected frequencies So it is expected that point three of All of the observations will be from category a well, how many observations total do I have? What is the sum of the five numbers here? It's going to be seventy seven So out of those seventy seven observations, we should expect point three of them Three tenths of them to be category a so you do seventy seven times point three all around to the nearest whole number And I get twenty three Next order of business you get seventy seven times point one for category B Which is eight? You get seventy seven times point two or category C, which is 15 Category D is seventy seven times point one again, which is eight And then category E is seventy seven times point three which will give you twenty three So we now have our expected frequencies So now we're going to go through and we're going to find The test statistic the critical value the p-value and Then we're also going to state the conclusion So I'm going to make some space here And I'm going to say okay Make a spot for test statistic Remember it's represented by the symbol chi-squared that CHI square. We're going to do critical value Which is found from a table And then we'll do p-value which will be found from Google Sheets test statistic and p-value are found from Google Sheets the critical value has to be found by Finding the degrees of freedom and the degrees of freedom is always going to be the number of categories Which are represented by the variable K minus one In this case you have five categories you take away one to get four So let's look at the chi-squared table to find the critical value So you locate I have a picture of the chi-squared distribution on top notice it is right tail You locate the degrees of freedom along the left hand side so four and then along the top you find your Significance level point zero five And look at where the row and column intersect The critical value is just nine point forty nine So that's what separates the rest of the curve from the critical region or rejection region. So nine point forty nine All right, so nine point forty nine it is I Always recommend just using that table. It's better than having to learn a new process in Google Sheets to find that critical value All right, so now let's actually Work on the chi-squared tab in Google Sheets the chi-squared tab will tell you the test statistic It will tell you the p-value. It would also tell you degrees of freedom. It does not tell you critical value That's why I say just use the table for the critical value All right, so we'll go on an adventure to the Google Sheets document to the chi-squared tab You'll pick your type of test which is currently goodness of fit and then literally you type in your row Categories and column D you type in your row categories where it says row one or whatever your spreadsheet currently says just put a BECD and then along row one Where it says column one or whether it says category one or whatever it may say and so e1 start typing your column headings for your table so observed frequency and Expected frequency That's all you care about for this one And then you fill in your numbers, so you're very top left most knit Top left most number in your table should start being typed in cell e2. So that's 23 5 14 15 20 those are all of the observed frequencies then you're going to enter all the expected frequencies So you're basically just replicating your table in the Google Sheets give it some time it takes some time to calculate Sometimes it'll do it quickly. Sometimes it'll do it in a very slow manner But I think it's done so you see your p-value point one zero two nine Rounded a four decimal places just for you and then you have your test statistic, which is seven point seven one So we got all the important information we need so the test statistic is seven point seven one and And then the p-value is point one zero two nine So the easiest way to conduct this test is to compare the p-value to alpha This is how you form your conclusion and the p-value is clearly greater than alpha So we fail to reject a null and you should also get the same result if you compare this test statistic to the critical value compare The test statistic that should be chi-squared by the way if you compare the test statistic to your critical value 9.49 notice it is less than if the test statistic is less than the critical value That means fail to reject H naught. I don't care what approach you use but at the end of the day Make sure you know that you fail to reject The null hypothesis, which means you fail to reject the claim meaning there is Not sufficient evidence to reject the claim in this case There is not sufficient evidence to warrant rejection of the claim that the frequency counts agree with the claim distribution or claim frequency So that's one goodness to fit test example How about another one a person drilled a hole in a die and filled it with a lead weight Then proceeded to roll it 200 times Here are the observed frequencies for the outcomes of one through six and They list 29 32 46 39 26 28 and they want you to use a point 10 Point 10 significance level to test to claim that the outcomes are Not equally likely does it appear that the loaded die behaves differently than a fair die Let's conduct the hypothesis test and provide the test statistic the critical value p-value and state the conclusion So here are the hypotheses The null is that the frequency counts agree with the claim distribution So observed frequencies will equal the expected frequencies and then the alternative is that frequency counts do not agree with the claim distribution So the observed frequencies are not equal to the expected So the way we want to set up this test is that okay? I rolled the die 200 times and I had all this information here 29 32 46 39 if that die were indeed fair Then overall Every outcome should occur the same number of times So if that die were fair out of the 200 rolls How much should I get of each number? What's 200 divided by 6 and we're out to nearest whole number It's about 33 So everything should have an expected frequency of 33 if that die Was indeed fair So I'm trying to show that the observed frequencies differ than the expected frequencies That's why my claim is the alternative hypothesis All right, so now I'm gonna go through and I'm gonna find the test statistic find the critical value find the p-value And we will even state the conclusion So I'm gonna make some room here for my test statistic Like high squared test statistic I Will make some room for that critical value Remember degrees of freedom is number of categories minus one Which six minus one is five and then I will make some space here for my p-value And we'll see what that's equal to All right, so the first stop will be we'll use the table We'll look at five degrees of freedom and determine what the critical value is Please note that alpha in this case is equal to point one So it has five degrees of freedom We had alpha point one So the critical value is nine point twenty four use the table to find the critical value That's a critical value of nine point twenty four Let's go to Google sheets now and type in this information so we can get the test statistic and the p-value So column D starting a cell D to type each of your categories You don't have to put your category row category labels there, but it helps for the sake of organization And I have observed an expected frequencies Then start typing your data and me to So I'm typing my data and sell you to and then F2. I'm going to type my expected frequencies Which is 33s Down the column and give your Google sheets spreadsheets in time to calculate It'll do all the magic for you and I'll show you a test statistic chi square of eight point nine seven And a p-value of point one one zero three So eight point nine seven That's point one one zero three Remember the easiest comparison approach is to compare that p-value to alpha The p-value is greater than alpha So that means we fail to reject the null hypothesis And you can also compare the test statistic to the critical value nine point twenty four It's less than the critical value in that case that also means fail to reject the null hypothesis Remember two different methods you should always get the same result though So that means I fail to reject the null So sad so that means I can't say anything about the claim I can't say anything about the alternative There is not sufficient evidence to support the claim that the outcomes are not equally likely So basically it appears that the loaded die behaves the same as a fair die So you might want to retry your weighted dice making skills So that's all I have for now for goodness to fit test. Thanks for watching