All right. So what you're actually going to see on homework and tests for this class is really questions from 10.2 and 10.3. So 10.2 is the Chi-Squared goodness of fit test. Like it says here, we're going to be testing the behavior of categorical data, specifically when we know what to expect based off of some past information and something that has multiple categories. So really, we won't use this if we only have two options, because we already know what to do if we have categorical data with two options—we would just do a one-prop or two-prop test. This is something that has multiple categories. Okay, so a little review. Suppose you toss a coin 100 times and observe 70 heads and 30 tails. What do you expect the number of heads and tails to be if the coin is fair and balanced? Well, fair and balanced—probability of heads would be 50%, probability of tails would be 50%. So if n = 100, we would expect 50 heads and 50 tails. Oops—which is that 50% of that, right? How does this compare to what you observed? That's where the Chi-Squared value comes in. Chi-Squared looks at the difference between the observed and expected. We square it to make sure that we have a positive value so we don't get them to cancel each other out. We divide by what's expected, so we know how far off we are from what we would expect, and then we sum up all of those values. So in this case, it would be the 70 observed heads minus the 50 expected, squared, divided by 50, plus the 30 observed tails minus the 50 expected, squared, divided by 50. The sum means that we're adding this fraction up for those two cases. Right off screen, I'm going to go ahead and do this calculation real quick, just so we have an example of a Chi-Squared. That is actually a really large Chi-Squared value. So yeah, we've got some suspicion that maybe this coin isn't actually fair. Now again, this is actually something that we could really do with just a one-prop test, so we don't actually need the Chi-Squared goodness of fit test for this. Instead, Chi-Squared goodness of fit is going to help us more with a situation like this. All right. Suppose you roll a six-sided die 180 times and observe the following data. All right, so it landed on 1 = 23 times, 2 = 40 times, 3 = 25, 4 = 33, 5 = 24, 6 = 36. What do you expect the number of ones, twos, threes, fours, fives, and sixes to be if the die is fair and balanced? Well, if the die is fair and balanced, the probability of any one side should be equal—a chance of one out of six sides. So 1/6. So if our sample is 180, then 1/6 of 180 is 30. So really, we expect each of these values to actually be 30. So this one is unusually low compared to 30, this one is definitely unusually high compared to 30. How does this compare with what you observed? We would do a Chi-Squared calculation. Now, the TI-84 can do this really easily, really quickly, just using the goodness of fit test. It will give you your Chi-Squared value. Let's see this by hand once more. Let's maybe see this also using the longer calculation on a TI-83, because you would have to calculate this manually if you have an 83. So observed minus expected. For our first value, the observed was 23 minus expected 30, divided by 30—don't forget to square the numerator. Plus same thing for the next side, right? When you're doing this all by hand, it definitely feels a little bit like busy work. ...33, 4, 36. And we could plug this into our calculator and see what we get. Go ahead. Rather than just doing this all from the home screen on my graphing calculator, let me show you how I would do this calculation using the list feature of my graphing calculator. And if you have a TI-83, this is actually the work you would have to do to find Chi-Squared. So here's my graphing calculator. I've been doing some calculations, so ignore that key press history. Let's go ahead and go to Stat → Enter. Here are my lists. This was a calculation I did from 10.1. So let's just go ahead and clear out each of these lists: scroll up, Clear, Enter; over, up, Clear, Enter; over, up, Clear, Enter. Perfect. Okay, now let's go ahead—I'm going to type in all of my observed data: 23, 40, 25, 33, 24, 36. Enter. Now list two, I'm going to list what we expected. Right? Okay, this is fair—we expect it to actually be even across: 30 for each of them. All right, now what I want to do is I want to calculate each of those fractions, which is the observed data (it's in my list one) minus the expected data (which is in my list two), quantity squared, divided by my expected data. So I'm coming over here to list three, scroll up so that L3 is highlighted, hit enter. Now down here I can see my cursor and I can put in a formula. I can use parentheses: second list one minus second list two, parentheses, squared, divided by my expected data (which is list two). Second. When I hit enter, it'll fill in all my values. So these are each of those fractions. I would just need to add those all up. The easiest way I find to do that is do a one-var stats calculation: Stat → one-var stats, list three is good, calculate. So we just need that sum value right there. The sum is 8.5. Actually a really nice sum. That's weird. Okay, so going back to my notes. All right. So testing behavior of categorical data. Now let's talk about the goodness of fit test. So this tests that the outcomes of a single categorical variable are as expected. We conduct a Chi-Squared goodness of fit test using the ingredients from the last section and the four steps of hypothesis testing. We can determine if the single categorical variable is following the distribution that it is expected to. The test relies on the Chi-Squared statistic and can be applied when you are comparing the distribution of counts of one categorical variable with multiple categories. Now I'm struggling with spelling today—with the distribution of expected counts. All right. We already know the four steps. In fact, when we did our practice—that last example of calculating the Chi-Squared value—we've actually already done some of these steps. Just with a TI-84, we're going to be using a different function. We're not going to have to use that list three. So let's go over our steps. So first, we hypothesize. It's our first step—we always have, right? The safe assumption is that the distributions are the same. I would say an easier way to say this is that observed equals expected. Hₐ is that the distributions are different. Easiest way of saying this is: observed is not equal to expected. That is our assumption every time. So we actually don't have to state our hypothesis when we do our Chi-Squared goodness of fit test, because these are our hypotheses. All right. Prepare. State your alpha if it isn't already given. Usually you'll go with the default of 0.05. Verify the conditions of CLT. Really, all I want you to do is this one here: expected count should all be at least five. Compute. You'll enter the observed data into list one, the expected counts into list two. If you're lucky enough to have a TI-84, then we'll go ahead and do this. If instead you have a TI-83, look back to what we did in 10.1. Note your degrees of freedom. Degrees of freedom is equal to the number of categories minus one. That's one of the things we'll have to input into our Chi-Squared goodness of fit test. Then we'll go ahead and do the calculation. It'll spit out our Chi-Squared test statistic and our p-value. Right—great thing, like we've mentioned before—you'll interpret the p-value the same way you've always interpreted the p-value. This was true for chapter 8. This was true for chapter 9. This will be true in chapter 11. If the p-value is less than alpha, reject the null hypothesis. Restate your alternative hypothesis in context. If the p-value is less than alpha, decide to reject the null hypothesis. If you reject the null, clue that there is significant evidence to support the alternative hypothesis. And if the p-value is greater than alpha, we fail to reject—so we don't have enough evidence to support Hₐ. Here are the calculator instructions again for the goodness of fit test, if you're interested. These instructions really kind of tell you what to do. Here are the instructions. I have already shown some of this up to step three. The only part that we didn't do was actually calculating the Chi-Squared test—Chi-Squared CDF. We did practice that in 10.1, but I just haven't done that in this recording.