The chi-square test for "goodness of fit" is one of the most popular and versatile of the non-parametric statistics.
Chi is a Greek letter X.
The test name is pronounced chi. It rhymes with my and pi.
Invented by Karl Pearson, the chi-square "goodness-of-fit" test is a non-parametric
procedure that uses sample data to test hypotheses about the proportion of a population distribution.
It tests whether the proportions from the obtained sample are a
good fit to the proportions known to exist in the population. What we will call the
expected proportions. It tests whether things are occurring randomly.
If so, the observed proportion should match what we expect from randomness, and if not
then the observed proportions are not random.
Chi-square answers the question "Are my observations a good fit to what I would expect?"
So what do I mean by a good fit?
Well imagine that the enrollment at my university is
50/50 male and female.
So if I choose a sample at random from that population,
what would you expect to be the proportions of males and females in that sample?
50/50
But if I choose to look at a certain department, and I find that their enrollment is
75% male, 25% female
Does that department look like the proportions that I know exist in my population?
Nope, not a good fit
Now on the other hand, suppose that my university enrollment is really
80/20 male and female
Would my 75/25 sample be a good fit?
Yes, in that case the sample looks like the population. Not a perfect fit, a good fit.
The chi-square is an excellent choice for examining proportion distributions within groups such as
distributions within ethnicity or
class standing like freshman, sophomore, junior, senior.
Or gender. Or education. Or occupation.
Here are the assumptions for using chi-square tests.
First, the chi-square "goodness-of-fit" test can compare frequencies of counts among categories or groups,
answering the research question,
"Are the data a good fit to a random distribution or perhaps even a hypothesized distribution?"
The independent variable is a single,
categorical variable with at least two groups or categories.
Chi-square can be done with ordinal variables, but the test will treat them as though they were nominal.
The dependent variable is the frequency of scores in each independent variable
category. So chi-square is very useful with count data when you count the number of occurrences in each group
Chi-square sampling method is assumed to be simple random sampling
No expected frequencies should be less than 5. We will compare observed to expected frequencies.
The recommendation is that
80% of cells should have an expected frequency greater than or equal to
5. If not, you get more type I errors, and as always, independence.
Observation should be independent
Each participant is counted in only one category
Sorry, you only get to choose]one type of soft drink, and
of course, if your data violate these assumptions you have options
If you have three or more categorical independent variables use log-linear analysis
If the independent variable is an ordinal variable, and you want to keep the order (in other words not treat them as nominal),
then you would use
Spearman's rank order correlation, or you could use a Kendall's tau.
So here are the null and alternative hypotheses for using a chi-square test.
The null hypothesis is that the observed data are a good fit to the expected data.
If your expected distribution is rando,m or you expect an equal distribution, a situation
I will call no preference, then your null hypothesis is that the observed data are occurring randomly.
So the alternative hypothesis is that the observed data are not occurring randomly.
Now you will, of course, need to customize this to your research question.
So you may, for example, say the rats will choose a maze direction randomly or
people entering the amusement park will choose a direction randomly.
Not true, by the way, most people go to the right which is why I always go to the left. Smaller crowds that way
If your expected distribution is known or you already have established
percentages (a situation I will call no difference)
then your null hypothesis is that the observed data will fit the identified distribution,
and your alternative hypothesis is that the observed data do not fit the identified distribution.
Again, you'll have to customize this to your research question.
You do not write the null hypothesis with numbers using a chi-square test
The alpha level is typically set to alpha = .05,
but it can be 0.01,
or any other level chosen by the researcher. The degrees of]freedom is
K -1, where K is the number of categories,
and the critical value is
calculated from the Chi-Square Values table based on degrees of freedom and alpha.
So here is the formula for]the Pearson chi-square test:
Chi-square equals the sum of O - E squared
divided by E
Where O equals the observed frequency.
E is the expected frequency.
Unlike parametric formulas where we plug into a formula and solve, with
chi-square we will use this formula over and over for each category and then add them all up at the end.
And I will show you an example in the next video.
Finally, this is the chi-squared distribution
As before, you set a critical value based upon degrees of freedom and your alpha level.
The critical value sets the fence beyond which chi square values are too
unlikely to represent the expected frequencies.
Computed chi-square values beyond the critical value make the test significant.
The observed frequencies were statistically significantly different than the expected frequencies
To set a critical value,
you need alpha, use.05 as a default although you could set alpha to .01 or some other value, and
you need the degrees of freedom.
We look up the critical value in the chi-squared table which is included at the back of your notes.
So if we have
190 people choosing among six types of sodas,
degrees of freedom is K - 1
Where K is the number of categories,. So 6 -1 is 5
The critical value for a chi-square alpha .05,
5 degrees of Freedom is 11.07
Any computed chi-square values greater than 11.07 are
statistically significantly different. And
by now you should not be surprised that a test with the word squared in the name is a one-tailed
distribution because it cannot have negative values.
Only positive values are generated using a chi-square
Okay, now that we know the basics, we are ready to apply what we know with a one-way chi-square test.