BAM!
Mr. Tarrou!
In the second of two videos, covering the Chi-squared test, the first video being on one-way tables,
this video being on two-way tables. We are looking at analyzing categorical variables, and looking to see
if they have equal distributions, or if there is an association between two variables in these two way tables.
Let's get started!
We are going to start with an example from an old chapter - the two proportion z test.Then, we are going
to relate this two proportion z test to our first example of doing the same problem with the chi-squared test.
Then, we will move on to a bigger two way table in our second example.
Do men and women snack differently? You take an SRS of 380 men and and SRS of 370 women.
68% of men and 53% of women say that they snack. Is there convincing evidence there is a difference in
snacking habits between genders? I am going to show you the work and the final answer, and we will refer to
that later in this video. This is going to be a two sided test. We are going to be looking for the proportion of
men minus the proportion of women not equaling zero. Because all we are being asked about is if there is a
difference in snacking habits. We are not assuming that men snack more or women snack more.
Based on that we have a H-sub-0 statement and an H-sub-a statement. The proportion of men minus the
proportion of women equals zero. And then that difference is not equal to zero. Remember, I like
to set up my statements like this to make sure that my shading is in the correct direction at the end of the
problem. It is not required, and indeed if you are using your calculator or computer, they will not have
the hypothesis statement set up quite like that. Now, because H-sub-0 is assuming that the proportion
of men and women who snack is the same, we are going to do a pooled proportion test. A two sample
proportion z test.
Here is our z score calculation. And our final result is a p-value of 3%. So, there is good evidence that
yes, there is a difference between the snacking habits of men and women.
Now, if you want to see this example worked out completely, click on the link of the two proportion
z test and I will go over all the condition checks and the proper summary statement and whatnot.
But, we are going to do the same test now with a Chi-square test. You can, or have the option of doing
a Chi-square test on a two way table, when you have this two proportion set up.
It is a little bit quicker, maybe, or a little bit different with the Chi-square test. The limit with the Chi-square test
though, is that it only directly relates with the two sided test. So, if you are expecting men to snack more than
women, let's say, then this p-value would be 0.015 , where the Chi-square test would give you 0.03.
I'm giving you a preview about comparing those p values.
That's enough of the preview... let's get into the Chi-square test.
Bam!
Now! What I have done is, I have summarize the results for the values that were given in that two proportion
z test into a two way table. Comparing the gender of the respondent with whether or not they snack.
Now, what I have done is...We said that we looked at 380 men, so I multiplied that by 60.8 and rounded off
the count value to 231.
I set up the question to purposefully get the count values that are very, very close to that.
These are supposed to be actual observered counts, not calculated counts. So, it would not make sense to
have a decimal in this table. 60.8% of 380 and 53% of 370 gives us the number of yes's between males
and females. So, of course we have gender, whether they said
yes or no...and I have a two way table.
We are now going to set up a Ch-squared test on this two way table. Again, this direct back and forth
is not only possible when it is only two sample proportion z test, but there is that nice direct
relationship here. For tables getting bigger than this, you will generally be doing them with a Chi-squared test.
And not be trying to turn it into a two proportion z test.
Though you could force the issue, I am not going to speak of that in this video.
This is a two way table because you are comparing gender, whether or not they snack. So you are
comparing 2 categorical variables.
Besides this table is a two-by-two table. We describe size by the number of rows-by- the number of columns.
In the Chi-squared tests on categorical variables, when displated in a two way table, will allow you to determine
if those variables have the same distribution - in this case is the percent the same between men and
women who snack or are they different? Or, if they are associated or not.
This second language about them being associated or not, or independent or dependent, is saved
for when the data is only collected with ONE SRS.
Our problem stated that we have an SRS of men and women, and two 2 SRS's were independent of
each other. So thus, we are going to be using the langauge of same distribution, or same proportions.
Next screen!
Let me make a comment about what I have up here written in purple and repeat what I said on the
previous screen.
The Chi-squared test on categorical variables displayed in a two way table, will allow you to determine
if those two variables have the SAME distribution, not one is higher than the other.
So, that is why a Chi-squared test will always give you the same p value as a two sided, two proportion
z test. We are told that we have an SRS of men taken and there
was an SRS of women taken, and we compare those two proportions. So, thus, we are going to do a Chi-squared
test for homogeneity of populations.
Whoo! Glad I got that word said right.
So we are going to state the hypothesis first. H-sub-0 is the probabilities of snacking is equal between genders.
Or you can say the distributions.
And H-sub-a is the probabilities of snacking is not equal between genders.
Our conditions are we need an SRS, and they need to be independent of each other - the men and women.
So, men and women must be an SRS from each respective population. And we do always want
those populations to be greater than 10 times the sample size.
Also, all of our expected cell counts are greater than one and no more than 20% are less than 5.
Now, we do not have our expected cell counts. We could using this formula, calculate them all by hand
but when doing a full Chi-square test, our calculator or computer will compute those values for us.
So, I am saying this is the case, but I do not actually have those values yet.
I will refer to them and point those expected cell counts to this condition check once I have them.
Do make sure that you know this formula, though - that row total times column total, divided by the entire
total of the table is how you calculate each individual cell count.
We will generally be allowing our calculator, like I said, to give us those values for us.
So, here is our example. As you can see, I have the Ch-square formula written.
It is the same as the one we had in the first video.
Chi-square is equal to the summation of the observed data minus the expected counts within cells,
So, observed minus expected cell counts squared.
Divided by the expected cell count of each individual cell in that table.
And we had a 2 by 2 table. These are the expected cell counts that we have - that our calculator gave us.
With 4 cells, we have 4 multiplications. So, we have observed minus the expected value, squared, divided by
the expected value. This came out to be 0.992. And then we have our other 3 values here that add up to
a Chi-square statistics of 4.67.
Now, in a 2 way table, your degree of freedom is the number of rows, minus one.
Times the number of columns minus one.
Since it is a 2 by 2 table, our degree of freedom is simply 1 times 1, which is 1.
And the p values is 0.03.
Chi-Squared distributions appear to have this right skew distribution. Our Chi-squared value is here, over
4.67 units.
Then this tail area is 0.03.
Now again, if you go back to the beginning of this video, this is the same p value that we got from our
two sample proportion z test, which was 2 sided.
And again, for the 3rd time, I've noted they are the same. I am just really trying to emphasize that this is
realted to and gives you the same answer as 2 sided z test.
So our conclusion of course is, the p value of 0.03 gives pretty good evidence against H0.
There does appear to be a difference in snacking habits between men and women.
Chi-square will only tell you if there is an association there, or if the distributions are different.
It will not describe what that difference is. So, we did have in our original problem that we observed 68.8%
of men snacking, and 53% of women. And if we would like to discuss what we observed, the differences
in those distributions in our summary statement, that is when we go back
and look at those examples.
So that is the end of my first example.
BAM!
Let's do another one!
In our next example, we want to study the relationship between education and income levels.
We take a single SRS of the population of all working adults, size 591. Are these two variables independent
or dependent?
I am making these questions up, but I am sure in your textbook you will have a bit more of a wordy setting.
I just want to emphasize here that we are talking about one sample being taken, as opposed to 2.
Like in our first example, where we had an SRS of men and another SRS of women. And those were
independent of each other.
So the fact that this is a single SRS, and we are going to measure a couple of categorical variables within those
respondents of that SRS, we are going to have a name change for the type of Chi-square test it is.
A little bit of rewording of H-sub-0 and H-sub-a, but everything else pretty much works the same.
Or actually, identical to the first example.
Is education independent to income?
I have used this example before when we talked about 2 way tables, many chapters ago.
This is a fairly straight forward example. I have made up my own numbers. I have no high school education,
high school education, and college. And I am not talking about 2 year and 4 year degrees, and masters and
doctorate. We will just simplify it and say college education.
We have some categories of income. Less than 25,000. Between 25000 and 40000, and if you cross that 40000
threshold, we are into 40000 and 65000. Then finally, those people who make over 65000.
In green we have our observed, made up numbers, but our observed counts.
We are not going to use these proportions in the calculation of Chi-squared.
We need to, and can only work with, count values to actually run the test.
But, if we determine at the end of this problem that yes, these are indeed related or associated or dependent
variables, then I would like to be able to discuss in my summary statement what patterns did I actually
see in the data? And I am going to use these percents to do that.
I've made these column percents. You can see that I have the bottom marginal distribution.
And I am doing column percents because I do believe that your education helps to determine how much
you make. As a teacher of higher level math, of course, I am hoping that the more education you have, the higher
that you do tend to make.
And that actually is a proven fact.
These, however, are just made up numbers, so that I could not worry about copyright issues and
referencing some other study.
At any rate, let's state our hypothesis and do our checks!
Since again, we are collecting this data from a single SRS, now we are going to call it a Chi-square
test for association, or independence. Our hypothesis statement is H-sub-0: Education
and income are independent. You could also say there is no association between
education and income.
H-sub-a is that education and income are dependent, or that there is an association.
Our conditions: SRS - we have randomly selected people for this study through an SRS.
Just one.
And all the expected cell counts are greater than or equal to one. And no more than 25% are less than 5.
Again, there is a formula to do this by hand, but we will be allowing the calculator to find these values in bulk,
for us, for the entire table.
So, I have written this check, but I will reference it later on in the problem after we have actually run the
Chi-Square test and allow the calculator to give us those values.
One last screen and we will be done with this example!
Here, we have the last step. Run the calculation.
Unlike in the first video, when we were doing Chi-square tests for goodness of fit, we do not have any
issues with the age of the calculator - 83s, 84s with the old software - all calculators that I know of
will run a Chi-square test on a two way table just fine.
Remember we had a little issue with the Chi-square goodness of fit, with TI-83s, and the older
software on the TI-84s if it has not been updated.
We could still use of calculator, but we kind of had to use the calculator to assist us, instead of a more
automated, just tell it to do it, and it comes out.
I am giving you the chi-square value. I am showing you the calculation for degree of freedom.
It is number of rows minus one, times number of columns minus one.
Thus, this 4 by 3 table has a degree of freedom of 6. Again, there will be a video linked above my head
or down here to the bottom left hand corner - I'll give you a link to the video so you can find that video
of finding and doing the Chi-sqaure test on your TI-nsprie.
With such a very, very large Chi-square value, we are very far to the right hand tail. Almost basically off
the charts. So our p values is effectively zero.
I can't say it is zero, just because like a normal distribution, the right skewed Chi-squared distribution
is a mathematical model, and thus goes on forever.
So, I can say the p value is approximately zero, but not exactly equal to zero.
I've referenced the expected cell count matrix that my calculator will give me. Again, you will have that video
posted in a minute, and linked. However, I have this written so I can justify that condition I stated just a
minute ago about all the expected cell counts being greater than one, and no more than 20% being less
than 5. Indeed, none of them are. But, I am going to write that condition out just like it is in my book.
Conclusion: There is extremely strong evidence that education and income are dependent.
Thus, I have very strong evidence for H-sub-a, with a p value of near zero. Notice my conclusion is
incorporating my p value and referencing if I feel there is evidence for H-sub-a or not for H-sub-a.
Now this last sentence: we observe that 64% of non high school individuals making less than 25000
while 69% of college educated made over 40000. I have combined those last two groups.
This is just one example. We have now said in the first sentence that they are dependent.
That there is a relationship between the two variables. Whether your teacher wants you to go on and
describe what that relationship is, now that you have said their is one or not, is up to that teacher.
But, remember, we made those column percents with the income sort of being explained by amount of
education you had, by doing column percents.
I am just going to go back and look at these values and analyze what is going on.
You can clearly see that the non high school students compared to the high school and college, that you
have a much higher percent of people making not so much money. Or, with the college educated people, you
know a greater percent making more amounts of money.
So you can include some of those percents into your conclusion at the end, so that you can explain
or describe what patterns you saw in those numbers.
That's all i've got to say.
That's two examples for chi-square.
One with two SRSs and one, this second one, where there was only one SRS.
Really, just a name change on the title and a slightly different wording for H-sub-0 and H-sub-a.
You're good to go!
BAM!
Go do your homework!
Thank you for watching!