Remember that for the Chi-square test of independence we need to determine whether the observed counts are significantly different from the counts that we would expect if there was no association between the two variables. We have the observed counts (see the table above), so we now need to compute the expected counts in the case the variables were independent. These expected frequencies are computed for each subgroup one by one with the following formula:
\[\text{exp. frequencies} = \frac{\text{total # of obs. for the row} \cdot \text{total # of obs. for the column}}{\text{total number of observations}}\]
where obs. correspond to observations. Given our table of observed frequencies above, below is the table of the expected frequencies computed for each subgroup:
Non-smoker | Smoker | Total | |
---|---|---|---|
(18 * 14) / 28 = 9 | (18 * 14) / 28 = 9 | 18 | |
(10 * 14) / 28 = 5 | (10 * 14) / 28 = 5 | 10 | |
14 | 14 | 28 |
Note that the Chi-square test of independence should only be done when the expected frequencies in all groups are equal to or greater than 5. This assumption is met for our example as the minimum number of expected frequencies is 5. If the condition is not met, the Fisher’s exact test is preferred.
Talking about assumptions, the Chi-square test of independence requires that the observations are independent. This is usually not tested formally, but rather verified based on the design of the experiment and on the good control of experimental conditions. If you are not sure, ask yourself if one observation is related to another (if one observation has an impact on another). If not, it is most likely that you have independent observations.
If you have dependent observations (paired samples), the McNemar’s or Cochran’s Q tests should be used instead. The McNemar’s test is used when we want to know if there is a significant change in two paired samples (typically in a study with a measure before and after on the same subject) when the variables have only two categories. The Cochran’s Q tests is an extension of the McNemar’s test when we have more than two related measures.
We have the observed and expected frequencies. We now need to compare these frequencies to determine if they differ significantly. The difference between the observed and expected frequencies, referred as the test statistic (or t-stat) and denoted \(\chi^2\) , is computed as follows:
\[\chi^2 = \sum_{i, j} \frac{\big(O_{ij} - E_{ij}\big)^2}{E_{ij}}\]
where \(O\) represents the observed frequencies and \(E\) the expected frequencies. We use the square of the differences between the observed and expected frequencies to make sure that negative differences are not compensated by positive differences. The formula looks more complex than what it really is, so let’s illustrate it with our example. We first compute the difference in each subgroup one by one according to the formula:
and then we sum them all to obtain the test statistic:
\[\chi^2 = 2.78 + 5 + 2.78 + 5 = 15.56\]
The test statistic alone is not enough to conclude for independence or dependence between the two variables. As previously mentioned, this test statistic (which in some sense is the difference between the observed and expected frequencies) must be compared to a critical value to determine whether the difference is large or small. One cannot tell that a test statistic is large or small without putting it in perspective with the critical value.
If the test statistic is above the critical value, it means that the probability of observing such a difference between the observed and expected frequencies is unlikely. On the other hand, if the test statistic is below the critical value, it means that the probability of observing such a difference is likely. If it is likely to observe this difference, we cannot reject the hypothesis that the two variables are independent, otherwise we can conclude that there exists a relationship between the variables.
The critical value can be found in the statistical table of the Chi-square distribution and depends on the significance level, denoted \(\alpha\) , and the degrees of freedom, denoted \(df\) . The significance level is usually set equal to 5%. The degrees of freedom for a Chi-square test of independence is found as follow:
\[df = (\text{number of rows} - 1) \cdot (\text{number of columns} - 1)\]
In our example, the degrees of freedom is thus \(df = (2 - 1) \cdot (2 - 1) = 1\) since there are two rows and two columns in the contingency table (totals do not count as a row or column).
We now have all the necessary information to find the critical value in the Chi-square table ( \(\alpha = 0.05\) and \(df = 1\) ). To find the critical value we need to look at the row \(df = 1\) and the column \(\chi^2_{0.050}\) (since \(\alpha = 0.05\) ) in the picture below. The critical value is \(3.84146\) . 1
Chi-square table - Critical value for alpha = 5% and df = 1
Now that we have the test statistic and the critical value, we can compare them to check whether the null hypothesis of independence of the variables is rejected or not. In our example,
\[\text{test statistic} = 15.56 > \text{critical value} = 3.84146\]
Like for many statistical tests , when the test statistic is larger than the critical value, we can reject the null hypothesis at the specified significance level.
In our case, we can therefore reject the null hypothesis of independence between the two categorical variables at the 5% significance level.
\(\Rightarrow\) This means that there is a significant relationship between the smoking habit and being an athlete or not. Knowing the value of one variable helps to predict the value of the other variable.
Thanks for reading.
I hope the article helped you to perform the Chi-square test of independence by hand and interpret its results. If you would like to learn how to do this test in R, read the article “ Chi-square test of independence in R ”.
As always, if you have a question or a suggestion related to the topic covered in this article, please add it as a comment so other readers can benefit from the discussion.
For readers that prefer to check the \(p\) -value in order to reject or not the null hypothesis, I also created a Shiny app to help you compute the \(p\) -value given a test statistic. ↩︎
Yes, receive new posts by email
FAQ Contribute Sitemap
Department of sociology, main navigation, the chi-square test for independence, learning objectives.
Chi-Square Distribution: a family asymmetrical, positively skewed distributions, the exact shape of which is determined by their respective degrees of freedom Observed Frequencies: the cell frequencies actually observed in a bivariate table Expected Frequencies: The cell frequencies that one might expect to see in a bivariate table if the two variables were statistically independent
The primary use of the chi-square test is to examine whether two variables are independent or not. What does it mean to be independent, in this sense? It means that the two factors are not related. Typically in social science research, we're interested in finding factors that are dependent upon each other—education and income, occupation and prestige, age and voting behavior. By ruling out independence of the two variables, the chi-square can be used to assess whether two variables are, in fact, dependent or not. More generally, we say that one variable is "not correlated with" or "independent of" the other if an increase in one variable is not associated with an increase in the another. If two variables are correlated, their values tend to move together, either in the same or in the opposite direction. Chi-square examines a special kind of correlation: that between two nominal variables.
The chi-square distribution, like the t distribution, is actually a series of distributions, the exact shape of which varies according to their degrees of freedom. Unlike the t distribution, however, the chi-square distribution is asymmetrical, positively skewed and never approaches normality. The graph below illustrates how the shape of the chi-square distribution changes as the degrees of freedom (k) increase:
Earlier in the semester, you familiarized yourself with the five steps of hypothesis testing: (1) making assumptions (2) stating the null and research hypotheses and choosing an alpha level (3) selecting a sampling distribution and determining the test statistic that corresponds with the chosen alpha level (4) calculating the test statistic and (5) interpreting the results. Like the t tests we discussed previously, the chi-square test begins with a handful of assumptions, a pair of hypotheses, a sampling distribution and an alpha level and ends with a conclusion obtained via comparison of an obtained statistic with a critical statistic. The assumptions associated with the chi-square test are fairly straightforward: the data at hand must have been randomly selected (to minimize potential biases) and the variables in question must be nominal or ordinal (there are other methods to test the statistical independence of interval/ratio variables; these methods will be discussed in subsequent chapters). Regarding the hypotheses to be tested, all chi-square tests have the same general null and research hypotheses. The null hypothesis states that there is no relationship between the two variables, while the research hypothesis states that there is a relationship between the two variables. The test statistic follows a chi-square distribution, and the conclusion depends on whether or not our obtained statistic is greater that the critical statistic at our chosen alpha level .
In the following example, we'll use a chi-square test to determine whether there is a relationship between gender and getting in trouble at school (both nominal variables). Below is the table documenting the raw scores of boys and girls and their respective behavior issues (or lack thereof):
Gender and Getting in Trouble at School
Got in Trouble | Did Not Get in Trouble | Total | |
Boys | 46 | 71 | 117 |
Girls | 37 | 83 | 120 |
Total | 83 | 154 | 237 |
To examine statistically whether boys got in trouble in school more often, we need to frame the question in terms of hypotheses. The null hypothesis is that the two variables are independent (i.e. no relationship or correlation) and the research hypothesis is that the two variables are related. In this case, the specific hypotheses are:
H0: There is no relationship between gender and getting in trouble at school H1: There is a relationship between gender and getting in trouble at school
As is customary in the social sciences, we'll set our alpha level at 0.05
Next we need to calculate the expected frequency for each cell. These values represent what we would expect to see if there really were no relationship between the two variables. We calculate the expected frequency for each cell by multiplying the row total by the column total and dividing by the total number of observations. To get the expected count for the upper right cell, we would multiply the row total (117) by the column total (83) and divide by the total number of observations (237). (83 x 117)/237 = 40.97. If the two variables were independent, we would expect 40.97 boys to get in trouble. Or, to put it another way, if there were no relationship between the two variables, we would expect to see the number of students who got in trouble be evenly distributed across both genders.
We do the same thing for the other three cells and end up with the following expected counts (in parentheses next to each raw score):
Got in Trouble | Did Not Get in Trouble | Total | |
Boys | 46 (40.97) | 71 (76.02) | 117 |
Girls | 37 (42.03) | 83 (77.97) | 120 |
Total | 83 | 154 | 237 |
With these sets of figures, we calculate the chi-square statistic as follows:
For each cell, we square the difference between the observed frequency and the expected frequency (observed frequency – expected frequency) and divide that number by the expected frequency. Then we add all of the terms (there will be four, one for each cell) together, like so:
After we've crunched all those numbers, we end up with an obtained statistic of 1.87. ( Please note: a chi-square statistic can't be negative because nominal variables don't have directionality. If your obtained statistic turns out to be negative, you might want to check your math.) But before we can come to a conclusion, we need to find our critical statistic, which entails finding our degrees of freedom. In this case, the number of degrees of freedom is equal to the number of columns in the table minus one multiplied by the number of rows in the table minus one, or (r-1)(c-1). In our case, we have (2-1)(2-1), or one degree of freedom.
Finally, we compare our obtained statistic to our critical statistic found on the chi-square table posted in the "Files" section on Canvas. We also need to reference our alpha, which we set at .05. As you can see, the critical statistic for an alpha level of 0.05 and one degree of freedom is 3.841, which is larger than our obtained statistic of 1.87. Because the critical statistic is greater than our obtained statistic, we can't reject our null hypothesis.
There are two limitations to the chi-square test about which you should be aware. First, the chi-square test is very sensitive to sample size. With a large enough sample, even trivial relationships can appear to be statistically significant. When using the chi-square test, you should keep in mind that "statistically significant" doesn't necessarily mean "meaningful." Second, remember that the chi-square can only tell us whether two variables are related to one another. It does not necessarily imply that one variable has any causal effect on the other. In order to establish causality, a more detailed analysis would be required.
To perform a chi square test with SPSS, click "Analyze," then "Descriptive Statistics," and then "Crosstabs." As was the case in the last chapter, the independent variable should be placed in the "Columns" box, and the dependent variable should be placed in the "Rows" box. Now click on "Statistics" and check the box next to "Chi-Square." This test will provide evidence either in favor of or against the statistical independence of two variables, but it won't give you any information about the strength or direction of the relationship.
After looking at the output, some of you are probably wondering why SPSS provides you with a two-tailed p-value when chi-square is always a one-tailed test. In all honesty, I don't know the answer to that question. However, all is not lost. Because two-tailed tests are always more conservative than one-tailed tests (i.e., it's harder to reject your null hypothesis with a two-tailed test than it is with a one-tailed test), a statistically significant result under a two-tailed assumption would also be significant under a one-tailed assumption. If you're highly motivated, you can compare the obtained statistic from your output to the critical statistic found on a chi-square chart. Here's a video walkthrough with a slightly more detailed explanation:
Hypothesis testing in statistics helps us use data to make informed decisions. It starts with an assumption or guess about a group or population—something we believe might be true. We then collect sample data to check if there is enough evidence to support or reject that guess. This method is useful in many fields, like science, business, and healthcare, where decisions need to be based on facts.
Learning how to do hypothesis testing in statistics step-by-step can help you better understand data and make smarter choices, even when things are uncertain. This guide will take you through each step, from creating your hypothesis to making sense of the results, so you can see how it works in practical situations.
Table of Contents
Hypothesis testing is a method for determining whether data supports a certain idea or assumption about a larger group. It starts by making a guess, like an average or a proportion, and then uses a small sample of data to see if that guess seems true or not.
For example, if a company wants to know if its new product is more popular than its old one, it can use hypothesis testing. They start with a statement like “The new product is not more popular than the old one” (this is the null hypothesis) and compare it with “The new product is more popular” (this is the alternative hypothesis). Then, they look at customer feedback to see if there’s enough evidence to reject the first statement and support the second one.
Simply put, hypothesis testing is a way to use data to help make decisions and understand what the data is really telling us, even when we don’t have all the answers.
Hypothesis testing is important because it helps us make smart choices and understand data better. Here’s why it’s useful:
Here’s a simple guide to understanding hypothesis testing, with an example:
Explanation: Start by defining two statements:
Example: Suppose a company says their new batteries last an average of 500 hours. To check this:
Explanation: Pick a statistical test that fits your data and your hypotheses. Different tests are used for various kinds of data.
Example: Since you’re comparing the average battery life, you use a one-sample t-test .
Explanation: Decide how much risk you’re willing to take if you make a wrong decision. This is called the significance level, often set at 0.05 or 5%.
Example: You choose a significance level of 0.05, meaning you’re okay with a 5% chance of being wrong.
Explanation: Collect your data and perform the test. Calculate the test statistic to see how far your sample result is from what you assumed.
Example: You test 30 batteries and find they last an average of 485 hours. You then calculate how this average compares to the claimed 500 hours using the t-test.
Explanation: The p-value tells you the probability of getting a result as extreme as yours if the null hypothesis is true.
Example: You find a p-value of 0.0001. This means there’s a very small chance (0.01%) of getting an average battery life of 485 hours or less if the true average is 500 hours.
Explanation: Compare the p-value to your significance level. If the p-value is smaller, you reject the null hypothesis. If it’s larger, you do not reject it.
Example: Since 0.0001 is much less than 0.05, you reject the null hypothesis. This means the data suggests the average battery life is different from 500 hours.
Explanation: Summarize what the results mean. State whether you rejected the null hypothesis and what that implies.
Example: You conclude that the average battery life is likely different from 500 hours. This suggests the company’s claim might not be accurate.
Hypothesis testing is a way to use data to check if your guesses or assumptions are likely true. By following these steps—setting up your hypotheses, choosing the right test, deciding on a significance level, analyzing your data, finding the p-value, making a decision, and reporting results—you can determine if your data supports or challenges your initial idea.
Hypothesis testing is a way to use data to make decisions. Here’s a straightforward guide:
Hypothesis testing helps you make decisions based on data. It involves setting up your initial idea, picking a significance level, doing the test, and looking at the results. By following these steps, you can make sure your conclusions are based on solid information, not just guesses.
This approach lets you see if the evidence supports or contradicts your initial idea, helping you make better decisions. But remember that hypothesis testing isn’t perfect. Things like sample size and assumptions can affect the results, so it’s important to be aware of these limitations.
In simple terms, using a step-by-step guide for hypothesis testing is a great way to better understand your data. Follow the steps carefully and keep in mind the method’s limits.
A one-tailed test assesses the probability of the observed data in one direction (either greater than or less than a certain value). In contrast, a two-tailed test looks at both directions (greater than and less than) to detect any significant deviation from the null hypothesis.
The choice of test depends on the type of data you have and the hypotheses you are testing. Common tests include t-tests, chi-square tests, and ANOVA. You get more details about ANOVA, you may read Complete Details on What is ANOVA in Statistics ? It’s important to match the test to the data characteristics and the research question.
Sample size affects the reliability of hypothesis testing. Larger samples provide more reliable estimates and can detect smaller effects, while smaller samples may lead to less accurate results and reduced power.
Hypothesis testing cannot prove that a hypothesis is true. It can only provide evidence to support or reject the null hypothesis. A result can indicate whether the data is consistent with the null hypothesis or not, but it does not prove the alternative hypothesis with certainty.
Leave a comment cancel reply.
Your email address will not be published. Required fields are marked *
IMAGES
VIDEO
COMMENTS
Learn how to use a Chi-Square test of independence to determine if two categorical variables are associated. The degrees of freedom are equal to (#rows-1)* (#columns-1). See a step-by-step example with gender and political party preference.
Uji Hipotesis â€" Uji Chi Kuadrat
Learn how to use a chi-square test of independence to test whether two categorical variables are related. The p value is the probability of obtaining a test statistic as extreme or more extreme than the observed value, given the null hypothesis is true.
Learn how to use chi-square tests to analyze categorical data and test hypotheses about frequency distributions. Find out the difference between chi-square goodness of fit and chi-square test of independence, and see examples and practice questions.
Obtaining Probability Values for the \(\chi^{2}\) goodness-of-fit test of the null hypothesis: As you can see from the equation of the chi-square, a perfect fit between the observed and the expected would be a chi-square of zero. ... Chi-squared test for given probabilities data: c(16, 80) X-squared = 3.5556, df = 1, p-value = 0.05935.
Learn how to test the independence of two categorical variables using the Chi-Square test. Find the expected counts for each cell under the null hypothesis and compare them with the observed counts to calculate the test statistic.
A chi-squared test is a statistical hypothesis test used to examine the independence of two categorical variables in a contingency table. The test statistic follows a chi-squared distribution under the null hypothesis, and the p-value is the probability of obtaining a value as extreme or more extreme than the observed one.
Learn how to use the chi-square test of independence to test for a relationship between two categorical variables. See an example with gender and online learning data, and follow the five-step hypothesis testing procedure.
Computational Exercises. In each of the following exercises, specify the number of degrees of freedom of the chi-square statistic, give the value of the statistic and compute the P -value of the test. A coin is tossed 100 times, resulting in 55 heads. Test the null hypothesis that the coin is fair.
Learn how to use chi-square tests to judge whether two factors are independent, based on a 2 x 2 contingency table. Find out how to compute the degrees of freedom, the expected values, and the test statistic for each factor.
Formulating the null hypothesis is a critical step in any chi-square test. First, identify the variables being tested. Then, once the variables are determined, the null hypothesis can be formulated to state no association between them. Next, collect your data. This data must be frequencies or counts of categories, not percentages or averages.
Learn how to conduct a chi-square test to determine if there is a significant association between two categorical variables. The alternative hypothesis for a chi-square test is always two-sided and states that there is a difference in the distribution of the variables.
Chi-square test is a nonparametric statistic that compares observed and expected frequencies in a contingency table. It measures the significance of the association between two or more categorical variables. Learn how to calculate, interpret, and report chi-square test results with SPSS and examples.
Learn how to calculate the expected frequencies and the chi-squared test statistic for a contingency table with two categorical variables. The expected frequencies are the values we'd expect if the null hypothesis is true, and they are based on the row and column totals.
The null hypothesis for the chi-square test of independence is that there is no relationship between the categorical variables. Learn how to perform the test and interpret the results with a Star Trek example.
Learn how to use the chi squared test to compare the distribution of a categorical variable in two samples. See the formula, the quick method, and the table of chi squared distribution with degrees of freedom.
The null hypothesis (H 0) and alternative hypothesis (H 1) of the Chi-Square Test of Independence can be expressed in two different but equivalent ways: H 0: "[Variable 1] is independent of ... Since the p-value is less than our chosen significance level α = 0.05, we can reject the null hypothesis, ...
Learn how to use the Chi-Square test to explore relationships between categorical variables, such as voter intent and political party membership. See how to calculate the Chi-Square statistic, interpret the p-value, and avoid common pitfalls in SPSS.
Learn how to use the chi-square statistic to test if a sample follows a certain distribution, such as equal probabilities for four choices. See examples, formulas, and tips for hypothesis testing with chi-square goodness of fit.
Learn how to use a chi-square goodness of fit test to test whether the observed distribution of a categorical variable differs from your expectations. The null hypothesis is that the population follows the specified distribution, while the alternative hypothesis is that it does not.
Learn how to use Pearson's chi-squared test to compare categorical data and evaluate the likelihood of chance differences. Find out the test statistic, degrees of freedom, p-value, and examples of applications.
Learn how to use a chi-square test to judge whether a sample fits a particular population well. See examples of die tossing and ethnic distribution data, and how to compute the test statistic and critical value.
The Chi-square test of independence is a hypothesis test so it has a null (\(H_0\)) and an alternative hypothesis (\(H_1\)): \(H_0\): the variables are independent, there is no relationship between the two categorical variables. Knowing the value of one variable does not help to predict the value of the other variable
The Chi-Square Test. Earlier in the semester, you familiarized yourself with the five steps of hypothesis testing: (1) making assumptions (2) stating the null and research hypotheses and choosing an alpha level (3) selecting a sampling distribution and determining the test statistic that corresponds with the chosen alpha level (4) calculating ...
Misunderstanding 2: A Small p-value Means the Null Hypothesis is False. Clarification: A small p-value shows that your data is unlikely if the null hypothesis is true. It suggests that the alternative hypothesis might be right, but it doesn't prove the null hypothesis is false. Misunderstanding 3: The Significance Level (Alpha) Can Be Chosen ...