Sign In | Subscribe

Enter your Sign on user name and password.

Forgot password?
  • Follow us on:
Start learning today, and be successful in your academic & professional career. Start Today!
Loading video...
This is a quick preview of the lesson. For full access, please Log In or Sign up.
For more information, please see full course syllabus of Statistics
  • Discussion

  • Download Lecture Slides

  • Table of Contents

  • Transcription

  • Related Books

Bookmark and Share
Lecture Comments (2)

0 answers

Post by Lois Han on April 30, 2012

You are a breath of fresh air in my statistics life. Thank you so much!

0 answers

Post by Matt Lin on March 18, 2012

Why we are not reject the Null if sample chi-square is larger than critical chi-square?

Chi-Square Goodness-of-Fit Test

Lecture Slides are screen-captured images of important points in the lecture. Students can download and print out these lecture slide images to do practice problems as well as take notes while watching the lecture.

  • Intro 0:00
  • Roadmap 0:05
    • Roadmap
  • Where Does the Chi-Square Test Belong? 0:50
    • Where Does the Chi-Square Test Belong?
  • A New Twist on HT: Goodness-of-Fit 7:23
    • HT in General
    • Goodness-of-Fit HT
  • Hypotheses about Proportions 12:17
    • Null Hypothesis
    • Alternative Hypothesis
    • Example
  • Chi-Square Statistic 17:52
    • Chi-Square Statistic
  • Chi-Square Distributions 24:31
    • Chi-Square Distributions
  • Conditions for Chi-Square 28:58
    • Condition 1
    • Condition 2
    • Condition 3
    • Condition 4
  • Example 1: Chi-Square Goodness-of-Fit Test 32:23
  • Example 2: Chi-Square Goodness-of-Fit Test 44:34
  • Example 3: Which of These Statements Describe Properties of the Chi-Square Goodness-of-Fit Test? 56:06

Transcription: Chi-Square Goodness-of-Fit Test

Hi, welcome to

We are going to talk about the chi-square goodness of fit test.0002

So first, we are going to start with the bigger review of where the chi-square test actually fits in.0005

Amongst all the different inferential statistics we have been learning so far and then we are going to talk0012

about a new kind of hypothesis testing, the goodness of fit hypothesis test.0018

So it is going to be similar to hypothesis testing as we been doing so far but there is a slightly different logic behind it.0023

So because it is a slightly different logic there is a new all hypothesis as well as the alternative hypothesis.0029

Then we are going to introduce the chi-square distribution and the chi-square statistic.0037

And then we are going to talk about the conditions for chi-square test when do we actually do it.0044

So where does the chi-square test belong?0049

And it is been a while since we have looked at this if you are going in order with the videos but I think it is0054

pretty good to stop right now and sort of think where we come from?0059

Where are we now?0063

So the first thing we want to think about are the different independent variables that we been able to look at.0065

We been able to look at independent variables the predictor variables that are either categorical or continuous.0072

When the idea is categorical you have groups right?0084

Or different samples, right?0095

When the idea is continuous you do not have different groups you have a different levels that predict something.0098

So just to give you a idea of a categorical IV that would be something like experimental group versus the0107

control group or something like this categorical IV may be someone who gets a drug versus someone who0116

gets the placebo , a group that gets the drivers of the group that gets the placebo and example of the0127

continuous IV might be looking at how much you study predicting your score on a test , so how much you0132

study would be a continuous IV.0140

So that is one of the dimensions that we need to know, is your IV categorical or continuous.0143

You also need to know whether the DV is categorical or continuous so the DV is the thing that were0150

interested in measuring at the end of the day the things that we want to know that this thing change this is0160

the thing we want to predict right, and so far here is how would come.0167

At the very beginning we looked at continuous types of tests and those types of measures and those were0177

the regression, linear regression, as well as correlation.0187

Remember R and regression was that stuff about like Y equals the not + b sub 1 times X, so that was0193

regression and correlation way back in the day.0210

We have been covering a lot of this quadrant actually looking at t-tests and ANOVA right?0215

One important thing to know that t-tests and ANOVAs are both hypothesis tests, only so far have not0224

learned hypothesis testing with regression and correlation.0238

A lot of inferential statistics in college does not cover hypothesis testing of regression until you get to more advance levels of statistics.0241

So what do ANOVAs and t-tests sort of have in common?0255

Well they have in common that they are both categorical IV and continuous DV.0261

The IV is categorical and you only have one, one IV.0269

And your DV is continuous.0277

So that sort of what they have in common, what is different about them?0282

Well the difference is that the IV in t-tests has two levels in only two levels so there is only two groups or two samples.0287

In ANOVAs we could test for more than two samples, we can do that for 3 4 5 samples.0297

So that IV has greater than two levels and so that is where we been spending a lot of our time.0302

So for the most part continuous DV are really important because they tell us a lot, they tell us the find ways0312

that we could actually be different, that the data could actually be different.0320

So you are going to, it is more rare that you will use the categorical dependent variable, that is not going to0327

be as informative to us but it is still possible and that is where the chi-square is going to come in.0334

The chi-square is been coming right in this quadrant where we have categorical IV also a categorical DV so0340

for instance we might want to see something like if you are given a particular job or the placebo, do you0347

feel like you are getting better, yes or no right?0357

So that is a categorical DV, it is not like the score that we can find a mean and so this is where the chi-square tests come in.0360

And there is going to be 2 chi-square tests that we are going to look at.0375

The first one, we are going to cover today and it is called goodness of fit.0379

The next one is in the next lesson and it is called a test of homogeneity.0382

They are both chi-square test.0386

The other way you will see that what is written is chi-squared, so sometimes, do not think of, oh what is this doing here?0387

When it has this little curvy part here we need chi-square, the Greek letter chi, finally this is a test that0398

rarely is covered in inferential statistics but at more advanced levels of statistics he did cover it and it is called0407

the logistic test and logistic test takes you from continuous IV to categorical DV.0415

But that is rare design used in conducting science, it is not as informative as continuous to continuous or categorical to continues.0424

Alright so we are going to spend your time right in here.0436

So there is a new twist on hypothesis testing, it is not totally different, it is still very similar but there is there is a subtle difference.0441

Today we are going to start off with the chi-square goodness of fit test.0454

Basically let us think about hypothesis testing in general.0457

In general you want to determine whether a sample is very different from expected results that is the big idea of hypothesis testing0462

and expected results come from your hypothesized population.0470

If your sample is very different than we usually determine that with some sort of test statistic and looking0474

at how far it is on the on the tested statistics distribution right and we look at whether it is past that Alpha0481

cut off or the critical test statistic right and then we say, oh this sample is so different than would be0489

expected given that the null hypothesis is true that we are going to reject the null hypothesis.0496

That is usually hypothesis testing. It still takes that idea whether to look at whether a sample is very0504

different from expected results, but the question is how are we going to compare these two things?0511

We are not going to compare means anymore, we are not going to look at the distance between means,0517

nor are we going to look at the proportion of variances that is not what we are going to look at either.0521

Instead we are going to determine whether the sample proportions for some category are very different0527

from the hypothesized population proportion.0539

And the question will be how do we determine very different and here is what I mean by determine0542

whether the sample proportions are different from the hypothesized population proportion.0549

So here I am just going to draw for you sort of schematically what the hypothesized population proportions might look like.0554

So this is just sort about the idea, so you might think of the population as being like this and in the0569

population you might see a proportion of one third being blue, one third being red, and one third being yellow.0577

Now already it is hard to think about like you could already sort of see, well we cannot get the average of0588

blue red and yellow right like what would be the average of that, and how would you find the variability of0597

that so already we are starting to see why you cannot use t-tests or ANOVAs if you cannot find the mean or0605

variance you cannot use those test so is this is what our hypothesized population looks like and when we0613

get a sample we get a little sample from that population, we want to know whether our sample0622

proportions are very different from the hypothesized proportions or not, so let us say in our sample0631

proportion we get mostly blue, little bit of red, little bit of yellow so let say 60% blue 20% red 20% yellow.0637

Are those proportions different enough from our hypothesized proportion?0650

Another sample we might get is you know, half blue and half red and no yellow, is that really different from our hypothesized proportion?0655

Another sample we might get might be only like 110 blue and then 40% red and then the other half will be yellow.0674

So something like that we want to say if it is really different from these hypothesized population0694

proportion, and so that is what our new our new goal is.0700

How different are these proportions from these proportion and then the question becomes okay how to0706

determine whether something is very different?0713

Is this very different or just different?0717

How do we determine very different, that is going to be the key question here.0724

And that is why we are going to need the chi-square statistic and the chi-square distribution.0728

So we are changing our hypotheses a little bit now the null hypotheses is really about proportion and here is what we are talking about.0733

The null hypothesis now is that the proportions of the population are real population that we do not know?0749

Will this population be like the predicted or theorized proportion and so here we are asking is this unknown0756

population like or known population right and it should sound familiar as that sort of the fundamental basis of inferential statistics.0772

So that is our new null hypothesis.0782

That the proportions in the population are like the predicted will be like the predicted population proportion still be the same.0785

Remember sameness is always the hallmark of the null hypothesis alternatively if you want to say at least0798

one of the proportion in the population will be different than predicted so going back to our example, if our0807

population are hypothesized population is something like one third, one third, one third maybe what we0816

will find is something like in our sample will have one third blue but then some smaller proportion like 15% red and on the rest being yellow.0830

Now the one third should match up.0856

The one third matches up but what about these other two?0860

And so an alternative hypothesis at least one proportion in the population will be different from the predicted proportion,0864

there just has to be one guy that is different.0875

Suggest I give you an example, let us turn this problem into a null hypothesis in an alternative hypothesis.0878

So here it said according to early polls candidate A was supposed to win 63% of the votes and candidate B was supposed to win 37%.0886

When the votes are counted candidate a won 340 votes while B won 166 votes so here just to give you that0898

picture again the null hypothesis population was that candidate A color A in blue, candidate A should have0908

won 63% of the vote and candidate B all color in red should have won 37% of the vote so what would be our null hypothesis?0918

Our null hypothesis would be that our unknown population will be like this predicted the proportions of my unknown population0933

will have the same proportion as our predicted population.0945

So here we might see something like A's proportion of votes of the actual real votes should be like this,0949

the predicted population, and B’s proportion of votes should be like predicted population.0982

So let us say, A’s proportion the real proportion of votes should be like this, and so should B, B should be like this.1009

The other way we could say that is that the proportion of votes the real proportion of votes should be like1017

the predicted proportion of votes, and then you could just say for every single category for both A and B.1025

So what would be the alternative version of this?1031

The alternative would say at least one of the proportion one of the categories either A or B one of those1035

proportions will be different from the hypothesized proportion.1043

And in fact in this example if one of them is different the other will be different to because since we only1048

have two categories if we make one really different than the other one will automatically change.1056

But later on we might see example 3, 4, 5 category and so in those cases this will make more sense.1061

Okay so now let us talk about how to actually find out if out proportions are really off or not.1070

Are our proportion statistical outliers are they deviant, are they significant, do they stand out, that is what we want to know.1080

And in order to do that we have to use measure called the chi-square statistic instead of the T statistic1092

which looks at a distance away in terms of standard error instead of the S statistic which looks at the1099

proportion of the variance are interested in over the variance we cannot explain the chi-square does something different.1106

It is now looking at expected values what would we expect and what would we actually observe and so the1113

chi-square is going to look like this, so be careful that you do not, usually it is like a uppercase accident and1124

it is a little bit different than like a regular letter X, it is usually a little more curvy to let you know it is chi-square.1134

So the chi-square is really going to be interested in the difference between what we observe the actual1142

observed frequency or percentages minus the expected frequency.1150

So what were looking at observed versus expected this is what we see in our sample and this is what we1157

would predict given our hypothesized population so this is that predicted population part.1170

So were interested in the difference between those two frequencies.1180

Now although you could use proportions as well you can only do that if you have the same, if you have a1185

constant number of items so you probably are safer to go with frequencies because those are assertively1200

weeded proportion so you probably want to go with that.1203

So were interested in this difference but remember when we look at this different sometimes there can be1207

positive sometimes there can be negative and so we what we do here as is usual in statistics as we square1214

the whole thing, but we also want to know about this difference as a proportion of what was expected and we want to do this for every category.1220

For the number of categories and I goes from one to the number of categories and there is actually an I down here for everything.1234

So what this is saying is that for each category, each proportion that you are looking at so in our in our sort1249

of toy example with the red blue and yellow, in this example we would do this for blue we would do this1259

for red and we would do this for yellow so number of categories, so categories really speak to what are the proportions made of?1275

So in here we have three categories so we would do this three times and add those proportions up and we1291

want to eventually be able to find observed frequency and the expected frequency.1315

Now in the example that we saw with the voting of for candidate A and B, one of the things I hope you1321

noticed was that the observed frequencies were given is just number of votes how many people voted but1330

the expected frequencies would be expected hypothesized population, that was given as a percentage so1336

you cannot subtract votes from percentage, you have to translate them both into something that is the1346

same and so in that it is helpful to change the expected percentages into expected frequency and there is1353

going to be another reason for changing it into expected frequencies instead of changing the observed1366

frequencies into the observed proportion and I am going to that a little bit later.1371

So here is what I want you to think of this, is really the square difference between observed and expected1377

frequencies as a proportion of expected frequency and you want to do that and you want to sum that over all the categories.1384

Once you have that then you get your chi-square value, now let us think about this chi-square value.1394

If this difference is very large right so observed frequencies are just very different than expected one, is that difference is very large?1400

You are going to have a very large chi-square also if this difference is very small, they are really close to each other, then your chi-square is be very small.1413

So chi-square is giving us a measure of how far apart the observed and expected frequencies are, also I1422

want to see that the chi-square cannot be negative.1434

First of all because were squaring this difference right so the numerator cannot be negative not only that1439

the expected frequencies also cannot be negative because we are counting up how many things we have ,1445

how many things we observed and so this also cannot be negative so this whole thing cannot be negative.1451

So already we see in our mind the chi-square distribution will probably be positive and positively skewed1457

because it stops at zero there is a wall at zero.1465

Okay so now let us actually talk and draw the chi-square distribution so imagine having some sort of data1470

set and taking from it over and over again samples so you take a sample and so have this big data set, you1479

take the sample and you calculate the chi-square statistic and you plot that.1487

And then you put that back in you take another sample and you take the chi-square plotted again and do1493

that over and over and over and over again.1502

You will never get a value that is below zero and you will get values that might be way higher than zero1505

sometimes but for the most part though be clustered over here so you will get a skewed distribution and1514

indeed the chi-square distribution is a skewed distribution.1520

Now here when we look at this you might think, hey, that looks sort of like the F distribution and you are1527

right overall and shape it looks just like the F distribution and in a lot of ways we could apply the reasoning1536

from the F distribution directly to the chi-square distribution.1544

For instant in the chi-square distribution, our alpha is automatically one tailed it is only on one side and so1548

when we say something like alpha equals .05 this is what we mean, we mean that we will reject the null1556

when we have a chi-square value that somewhere out here or here or here but we will fail to reject if we1565

get a chi-square value in here from our sample.1573

Now this chi-square distribution like the S and t-distribution, it is a family of distribution, not just one1576

distribution the only one that is just one distribution is the normal distribution.1586

The chi-square distribution again depends on degrees of freedom and the degrees of freedom that the chi-1591

square depends on is going to be the number of categories -1 .1598

So if you have a lot of categories the chi-square it will look distribution will look different if you have a small1608

number of the categories like 2, the chi-square distribution will look different.1615

So let us talk about what Alpha means here.1619

The alpha here is this set significance level we are going to say, we are going to use this as the boundary so1623

that if we have a chi-square from our sample that bigger than this boundary then we will reject the null.1630

What is the difference now with P value?1643

Now the P value said this is the probability so we might have a P value somewhere out here or we might1647

have a P value somewhere here, the P value is going to be very similar to other hypothesis test what the P1656

value means and other hypothesis test, basically is going to be the probability of getting a high square value1669

larger more extreme and in this case there is only one kind of extreme, positive larger than the one from our sample but under condition.1681

Remember in this world which one is true?1700

The null hypothesis is true.1703

So considering if the null hypothesis were true this would be the probability of getting such an extreme chi-1712

square value , one that is that large or larger, that is all we need.1720

So, in that way the P value is from our data while the alpha is not from our data it is it is just something we sat as the cut off.1727

So there are some conditions that we need to know before we use the chi-square.1737

When we use the chi-square we cannot just always use it, there are conditions that have to be met so one of the conditions of the chi-square is this.1745

Each outcome in the population falls exactly into one of a fixed number of categories, so every time you1756

have some sort of case from the population so let us say we are drying out votes.1765

Each vote has to fall into one of a fixed number of categories so if it is two candidates, always two1773

candidates for every single voter so we cannot compare voters that had two candidates versus voters who had three candidates.1785

Also these have to be mutually exclusive categories, one vote cannot go to two candidates at ones so they1792

have to be mutually exclusive, you got vote for A or vote for B.1802

And you cannot opt out either, or else nobody has to be one of the fixed numbers of categories ahead of time.1807

So the numbering is slightly off here but the second condition that must be met is that you must have a1816

random sample from your population, that is just like all kinds of hypothesis testing though.1826

Number 3, the expected frequency in each category so once you once you compute all the expected1832

frequency in order to compute your chi-square, that needs to be each cell each square needs to have an1840

expected frequency of five or greater, here is why.1850

You need a big enough sample, if you have to small of the sample, again expected frequencies less than five1854

also unique big enough proportions, so let us say you want to compare proportions that are like you know1862

like one candidate is going to be predicted to win 99.999% of the votes and the other candidate is only1871

supposed to win .001% of the vote and you only have five people in your sample.1883

And so you need to also have big enough proportion and these balance each other out.1890

If you have a large and a sample than your proportions can be smaller also, if you have large enough1897

proportions in your sample could be smaller.1903

And the final condition is not really condition it is just sort of something I wanted you to know at the rule.1905

The chi-square goodness of fit test so that is always been talking about so far.1913

This test actually applies to more than two categories.1920

You do not just have 2 categories, you have 3 or 4 or 5 or 6 but they do need to be mutually exclusive and1927

each outcome in the population must be able to fall into any one of those.1935

So those are the conditions.1940

So now let us move on to some examples.1943

So the first example is the problem that we already looked at so far according to early polls candidate A1947

was supposed to win 63% of the vote and B was supposed to win 37%.1953

When the votes are counted, A won 340 votes while B won 166 votes.1958

One of the things that I like to do just to help myself is when I think of the null hypothesis, when I think of1967

the null hypothesis, I sort of write it in a sentence that the proportion of votes, that is my population,1975

should be like predicted proportions, and the alternative is that at least one of the proportion of votes will not be like predicted population.1990

What I also like to do is I like to draw this out for myself, I like to draw out the predicted population so I will2032

color candidate A in blue so that will be about 63%, candidate B will be in red, 37%.2040

And so eventually I want to know whether this is reflected in my actual votes.2053

The significance level we can set it up .05 just set of convention and we know that it has to be one tailed2059

because this is definitely going to be a chi-square and we know it is a chi-square because it is about expected proportions.2068

So now let us set our decision stage.2075

Now our decision stage, it is helpful to draw that chi-square distribution and to sort of label it, for alpha2081

here this is our rejection region .05, now it would be nice to know what our critical chi-square is, and in2100

order to find that we need degrees of freedom and degrees of freedom is the number of categories, in this2111

case 2 -1 and that is 1° of freedom and it is because if you know let us say that candidate B won that is2119

supposed to win 37% of the votes you could actually figure out candidate A like you do not need me to tell2131

you what that is to figure it out and candidate A cannot vary, the proportion cannot very freely once you2138

know this one and that is why it is number of categories – 1.2143

So now that we have that you might be useful to look at either in the back of your book or use XL2148

spreadsheet Excel function in order to find our critical chi-square.2156

So in order to find chi-square there are two functions that you need to know just like T this and T, F this and F in, now there is chi-this.2161

Actually we need to use chi in right now because here we have the probability .05 and the degrees of2182

freedom one and that will give us our critical chi-square and that is 3.84.2190

So critical and so this is the boundary were looking for 3.84 so anything more extreme more positive than2198

3.84 and were going to reject our null hypothesis.2208

So now that our decision stage is set, now it is helpful to actually work with our population and remember2214

when we talk about our population, should have left myself some room, when we talk about our actual sample here is what we ended having.2221

We have observed frequencies already so for candidate A, I am going to write a column for observed in2236

candidate B so candidate A, we observed 340 votes so that is our observed frequency for candidate B, we see 166 votes.2243

Now one that helps is we know what the total number of votes was, so the total number of votes is going to be 340+166 and that is 506.2261

So 506 people actually voted in this so down here I am going to write total 506.2274

Now the question is what should our active frequencies have been?2283

So here I am going to write expected and I know that my proportion of expected should be 63%.2291

That means is that the total number of people who voted?2298

So here is our little sample of 506 people.2302

This is our 100% but here we have 506 people in our sample, we should expect 63% of 506 to have voted2308

for A, and so how do we find that?2323

Well we are going to multiply 63% to 506 to find out how many votes that little blue bit is and so that is2328

going to be.63×506 that total amount.2341

If we multiply 506 x 1 we would get 506 right?2350

So if we multiply by a little bit of a smaller proportion that we get just that chunk. 318.78 actually I am2355

going to put this here, let me actually draw this little table right in here because that can help us do our 3939.1 finder chi-square much more quickly.2367

And so observed expected frequency observed frequency at 340 and 166, okay.2383

So what are the other expected frequency for B, so in order to find this little bit we are going to multiply2394

.37×506, so .37x506 and that is 187.22.2401

And usually if you add this entire column that you should get roughly a similar total.2414

When you do it, when you do these by hand sometimes you might not get exactly the same number it2422

might be off by just a little bit because of a rounding error, if you round to the nearest 10th, round to the nearest integer,2429

you make it a little bit around it here but you should be off by much so that one way you could check to see what you did was right.2438

And so once we have this, so let me just copy these down right here so 318.78 and 187.22 for each of these2445

the total is 506, so here, one of things we see is that the expected value for A are a little bit lower and the2463

expected values for B are little bit higher, but is this difference in proportion is that significant is that2476

standing out enough, and in order to find that we need to find the chi-square, the sample chi-square.2485

Now, we completely run out of room here.2493

But I will just write the chi-square formula up here.2497

So the chi-square is going to be the sum over all the categories of the observed frequency minus the2500

expected square as a proportion of the expected frequency.2510

And so what I am going to do is calculate this for each category, A and B and then add them up.2517

So right here I am going to call this a column, O minus E squared all over B.2525

So I am going to do that for A and B and then sum them up.2540

So, my observed minus expected squared all divided by expected and so here I get this proportion and I am2547

just going to copy and paste that down here and then here I am just going to some them up and I get 3.817.2565

We are really close but no cigar so where were right underneath so our sample chi-square is just a smidge2577

smaller than our critical chi-square so here were not rejecting the null, we are going to fail to reject the2589

null, so let us find the P value so in order to find the P value you could use chi disc or alternatively look it up2597

in the back of your book, look for the chi-square distribution.2609

It should be behind your normal, your T, your F and then chi-square should come right behind it, it usually goes in that order , maybe a slightly different order.2614

And our degrees of freedom remain the same one and so all our P value is just over .05, if we round, .51 right?2627

So because of that we are not going to reject the null so we are going to say the proportions of votes are roughly similar to the predicted proportions.2640

Well, they are not significantly different at least, they are not super similar but we cannot make a decision2657

about that but we can say they are not that different from, that they are not extremely different at least.2663

Okay, example 2. A study ask college students could tell dog food apart from expensive liver pâté liverwurst and spam.2669

All blended to the same consistency chilled and garnished with herbs and a lemon wedge, just to make it pretty.2684

Students are asked to identify which was dog food.2695

Researchers wanted to test the probability model where the students are randomly guessing.2698

How would they cast their hypothesized model?2703

Okay so see the download that shows how many students picked that item to be dog food, so it seems that2707

college students have a bunch of different choices in dog food liver Patty, liverwurst and spam, and then2714

they need to identify which was dog food so out of those, which of those is dog food?2723

So it is sort of like a multiple-choice question.2728

So if you hit example 2 in the download that listed below, you will see the number of students is selected that particular item as dog food.2732

Now be careful because some people right here, remember, you will really get this problem on a test and you would not know that it is a chi-square problem.2741

Sometimes people might immediately just think I will find the means and so they just go ahead and find the2751

mean but then if you do find the mean, ask yourself, what does this mean?2758

What is the idea or the concept?2763

If we average this, we would find the average number of students that selected any of these items as dog2768

food and that sort of a mean that does not make any sense right?2775

And so before you know, go ahead and find the mean, ask yourself whether the mean is actually meaningful.2779

So here we know that the chi-square because the students are choosing something and it is a categorical choice.2788

They are not giving you an answer like 20 inches or 50° or I got 10 questions correct right?2798

They are actually just saying, that one is dog food and they have five different choices and they have2804

chosen one of them as dog food so out of five choices of probability model that are just guessing would2813

mean that 20% of the time they should pick pâté, once we dog food, 20% of the time don't expand to be2821

dog food 20% of the time to pick dog food to be dog food and so on and so forth.2828

So let us try that probability model and by model we also need null hypothesis.2835

Model or hypothesized population so step one.2844

So the null hypothesis is the idea that they will fit into this picture so this is the population, and it is out of2848

100% and they have five choices of pictures just lightly un even, it helps really draw this is as well as you can, just as then it will help you reason to.2858

That they will have a equal chance of guessing either one of these and there is two liver patties that is why there are 5 choices.2878

So liver pâté 1, spam was next, then actual dog food just in the data set, patty 2 and a liverwurst.2885

So these are the five choices and were saying look the students are just guessing they should have a 20% probability of each.2909

Is this the right proportion for this sample, is the sample going to serve match that or be very different from this.2923

The alternative is that at least one of the real proportion is different from predicted.2938

So once we have that, we can set our alpha to be .05 our decision stage, could draw there chi-square and2954

our degrees of freedom, we now have five categories and so our degrees of freedom is 5-1 which equals 42970

and it is because once we know four of this, that we could actually figure out the proportion for the fifth one just from knowing 4 of this.2978

So that one is no longer free to vary, it does not have freedom anymore.2987

So what is our critical chi-square?2991

Well, if you want to pull up your Excel data, here I am just in a start off with step three, in step three we are2998

critical chi-square in order to find that we can use chi-in, put in the probability that were interested in and our degrees of freedom which is 4.3011

And so our critical chi-square is 9.49.3026

Noticed that as degrees of freedom goes up, what is happening to the chi distribution is that it is getting3035

fatter it is getting more variable and because of that we need a more extreme chi-square value.3053

So that is sort of different than like T distributions or F distribution.3059

Those distributions got sharper when we increased our degrees of freedom , chi distributions were the opposite way.3066

Those district chi distributions are getting more variable as degrees of freedom goes up.3075

So once we have this now we could start working on our actual data, our actual samples.3080

So step four is we need to find a sample chi-square and in order to do that it helps to draw out that table so3089

the table might look something like this.3102

I will just copy this down here and this is the type of food, so that is the category and here we have our observed frequencies.3106

The actual number of students that pick that thing to be dog food.3125

So here we seen one student pick pâté, one to be dog food, 15 students picked liverwurst to be the dog food.3130

What are the expected frequencies?3138

Well in order to find expected frequencies we know that the expected proportions are going to be .2 all the way down.3142

20% 20% 20% 20% and here I am just going to total this up.3153

And I see that 34 students were asked this question.3161

Are expected frequencies should add up to about 34?3170

Are expected proportions adds up to one?3175

And that is why we cannot just directly compare these two things, they are not in the same sort of currency3179

yet, you sort of have to change this currency into frequency.3184

So how do we do that?3189

Well we imagine here are all 34 students take 20% of them, how many students will that be?3192

So that is 0.2×34, this times 34.3199

And I am just going to lockdown that 34 because that total sum would not change.3207

So, this is what we should expect that if they were indeed guessing, this is the expected frequencies that3214

we should see and if I just move that over here , we will see that that also at the column also add up to 34.3226

Now once we have that we can compute our actual chi-square because remember that observed frequency3233

minus expected square divided by expected as a proportion of expected.3240

So, that is the observed frequency minus expected frequency squared divided by the expected frequency.3247

And I could take that down for each row and then add those up and here I get my chi-square statistic for3257

my sample and so my sample chi-square is going to be 16.29, and that is the larger more extreme chi-3268

square than my critical chi-square, and let's also find P value here.3281

In order to find P value I could use chi-disc, here I put in my chi-square and my degrees of freedom which is 4.3286

And so that is .003 and that is certainly smaller than .05 and so in step five, we reject the null.3297

Now I just want to make a comment here.3315

Notice that here, after we do the chi-square although we reject the null just like in the ANOVA we do not3318

actually know which of the categories is the one that is really off.3325

This one here, we can sort of see, this one probably seems to be the most off but we are just eyeballing it,3330

were not using actual statistical principles.3340

So once you reject the null there is a post hoc test that you could do but we are not going to cover those here.3343

So it seems that students are not randomly guessing they actually have a preference for something as being dog food.3349

My guess is liverwurst.3362

So example 3 which of these statements describe properties of the chi-square goodness of fit test?3365

So if you switch the order of categories the value of the test statistic does not change, that is actually true it3376

does not matter whether candidate A got added before candidate B addition is totally order insensitive you3383

could add A or B or B on A, you can add pâté or liverwurst and dog food or dog food the liverwurst and3391

pate, it does not really matter so this is actually true, as a true property.3398

Observed frequencies are always whole members that is also actually true because when you observe of3403

the frequency, you are actually counting how many category numbers you have so counting is going to be made up of whole numbers.3410

Expected frequencies are always whole numbers, that is actually not true, expected frequencies are predicted frequencies.3418

It is not that at any one time you will have plenty student saying that liverwurst is dog food but it is that on3427

average that is what you would predict given a certain proportion and so this is actually not true, expected3435

frequencies do not have to be whole numbers because they are theoretical, they are not actually things that we counted up in real life.3445

A high value of chi-square indicates high level of agreement between observed frequencies and the expected frequencies.3452

Actually if you think about the chi-square statistic, this is actually the opposite of what is the real case.3462

If we had a high level of agreement this number would be very small and because this numerator is small3472

the chi-square would also be small, a high value of chi-square would actually mean that this is quite large3479

compared to this and so this is actually also wrong, the opposite.3486

So that is it for chi-square goodness of fit test, join us next time on for chi-square test of homogeneity.3494