{"id":1163,"date":"2021-06-23T14:15:01","date_gmt":"2021-06-23T18:15:01","guid":{"rendered":"https:\/\/openbooks.macewan.ca\/rcommander\/?post_type=chapter&#038;p=1163"},"modified":"2025-05-07T18:08:23","modified_gmt":"2025-05-07T22:08:23","slug":"11-3-chi-square-goodness-of-fit-test","status":"publish","type":"chapter","link":"https:\/\/openbooks.macewan.ca\/introstats\/chapter\/11-3-chi-square-goodness-of-fit-test\/","title":{"raw":"11.3 Chi-Square Goodness-of-Fit Test","rendered":"11.3 Chi-Square Goodness-of-Fit Test"},"content":{"raw":"The chi-square goodness-of-fit test can be applied to either a categorical or discrete quantitative variable with a finite number of values. The objective of the chi-square goodness-of-fit test is to test whether the variable does not follow the probability distribution specified in the null hypothesis [latex]H_0[\/latex].\r\n\r\nThe main idea behind the chi-square goodness-of-fit test is to compare the observed frequencies (O) to the expected frequencies ([latex]E[\/latex]), which are based on the probability distribution specified in [latex]H_0[\/latex]. If [latex]H_0[\/latex] is true, the observed and expected frequencies should be reasonably similar. Therefore, we reject [latex]H_0[\/latex] if the observed and expected frequencies are very different. The discrepancy between the observed and expected frequencies can be quantified by chi-square statistic\r\n<p align=\"center\">[latex]\\chi^2 = \\sum_{\\text{all cells}} \\frac{(O - E)^2}{E}[\/latex]<\/p>\r\nwhich follows a chi-square distribution with [latex]df = k-1[\/latex], where [latex]k[\/latex] is the number of possible values for the variable under consideration. The chi-square statistic will be large when the observed and expected frequencies are very different. Thus, we reject the null hypothesis when the chi-square statistic is sufficiently large. More specifically, at the significance level of [latex]\\alpha[\/latex], we reject [latex]H_0[\/latex] if the chi-square statistic is larger than the critical value [latex]\\chi_{\\alpha}^2[\/latex]. Since we only reject [latex]H_0[\/latex] if the chi-square statistic is sufficiently large, chi-square tests are always right-tailed. That is, both the rejection region and the p-value are upper-tailed probabilities.\r\n<h2><strong>Chi-Square Goodness-of-Fit Test<\/strong><\/h2>\r\n<div class=\"textbox\">\r\n\r\n<strong>Assumptions<\/strong>:\r\n<ol>\r\n \t<li>All expected frequencies are at least 1.<\/li>\r\n \t<li>At most 20% of the expected frequencies are less than 5.<\/li>\r\n \t<li>Simple random sample (if you need to generalize the conclusion to a larger population).<\/li>\r\n<\/ol>\r\n<strong>Note<\/strong>: If assumptions 1 or 2 are violated, one can consider combining the cells to increase the counts in those cells.\r\n\r\n<strong>Steps to perform a <\/strong><strong>chi-square goodness-of-fit test<\/strong>:\r\n\r\nFirst, check the assumptions. Calculate the expected frequency for each possible value of the variable using [latex]E=np[\/latex], where [latex]n[\/latex] is the total number of observations and [latex]p[\/latex] is the relative frequency (or probability) specified in the null hypothesis. Check whether the expected frequencies satisfy assumptions 1 and 2. If not, consider combining some cells.\r\n<ol>\r\n \t<li>Set up the hypotheses:\r\n[latex]\\begin{align*} H_0 &amp;: \\text{The variable has the specified distribution }\\\\ H_a &amp;: \\text{The variable does not have the specified distribution}. \\end{align*}[\/latex]<\/li>\r\n \t<li>State the significance level [latex]\\alpha[\/latex].<\/li>\r\n \t<li>Compute the value of the test statistic: [latex]\\chi_o^2 = \\sum_{\\text{all cells}} \\frac{(O - E)^2}{E}[\/latex] with [latex]df = k-1[\/latex].<\/li>\r\n \t<li>Find the P-value <strong>or<\/strong> rejection region based on the [latex]\\chi^2[\/latex] curve with [latex]df = k-1[\/latex].\r\n<div align=\"center\">\r\n<table class=\"first-col-border\" style=\"width: 100%; height: 60px;\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\r\n<tbody>\r\n<tr style=\"height: 30px;\">\r\n<th style=\"width: 16.88888888888889%; height: 30px; vertical-align: top;\" scope=\"row\" valign=\"top\">Rejection region<\/th>\r\n<td style=\"width: 82.96296296296296%; height: 30px; vertical-align: top;\" valign=\"top\">[latex]\\chi^2 \\geq \\chi_{\\alpha}^2[\/latex] the region to the right of [latex]\\chi_{\\alpha}^2[\/latex], the area is [latex]\\alpha[\/latex]<\/td>\r\n<\/tr>\r\n<tr class=\"border-top\" style=\"height: 30px;\">\r\n<th style=\"width: 16.88888888888889%; height: 30px; vertical-align: top;\" scope=\"row\" valign=\"top\">P-value<\/th>\r\n<td style=\"width: 82.96296296296296%; height: 30px; vertical-align: top;\" valign=\"top\">\u00a0[latex]P(\\chi^2 \\geq \\chi_o^2)[\/latex] the area to the right of [latex]\\chi_o^2[\/latex]\u00a0under the curve<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/div><\/li>\r\n \t<li>Reject the null [latex]H_0[\/latex]\u00a0if P-value [latex]\\leq \\alpha[\/latex]\u00a0or [latex]\\chi_o^2[\/latex]\u00a0falls in the rejection region.<\/li>\r\n \t<li>Conclusion.<\/li>\r\n<\/ol>\r\n<\/div>\r\n&nbsp;\r\n<div class=\"textbox textbox--examples\"><header class=\"textbox__header\">\r\n<p class=\"textbox__title\">Example: Chi-Square Goodness-of-Fit Test<\/p>\r\n\r\n<\/header>\r\n<div class=\"textbox__content\">\r\n\r\nAccording to the results of the federal election in 2015, 31.9% of votes supported the Conservative Party, 39.5% supported the Liberal Party, 19.7% supported the New Democratic Party (NDP), 4.7% supported Bloc Qu\u00e9b\u00e9cois, and 3.4% supported the Green Party (data from Wikipedia). Thirty-seven students in my Stat151 class responded to an\u00a0online survey and their preferences are summarized in the following table:\r\n<p style=\"text-align: center;\"><strong>Table 11.2<\/strong>: Voting Preference of the Class<\/p>\r\n\r\n<div align=\"center\">\r\n<table style=\"height: 30px; width: 100%;\" border=\"1\" cellspacing=\"0\" cellpadding=\"3\">\r\n<thead>\r\n<tr style=\"height: 15px;\">\r\n<th class=\"shaded\" style=\"vertical-align: top; text-align: center; width: 24.97308934337998%;\" scope=\"col\" valign=\"top\">\r\n<div align=\"center\">Conservative<\/div><\/th>\r\n<th class=\"shaded\" style=\"vertical-align: top; text-align: center; width: 13.347685683530678%;\" scope=\"col\" valign=\"top\">\r\n<div align=\"center\">Green<\/div><\/th>\r\n<th class=\"shaded\" style=\"vertical-align: top; text-align: center; width: 14.531754574811625%;\" scope=\"col\" valign=\"top\">\r\n<div align=\"center\">Liberal<\/div><\/th>\r\n<th class=\"shaded\" style=\"vertical-align: top; text-align: center; width: 10.979547900968784%;\" scope=\"col\" valign=\"top\">\r\n<div align=\"center\">NDP<\/div><\/th>\r\n<th class=\"shaded\" style=\"vertical-align: top; text-align: center; width: 21.420882669537136%;\" scope=\"col\" valign=\"top\">\r\n<div align=\"center\">Not Voting<\/div><\/th>\r\n<th class=\"shaded\" style=\"vertical-align: top; text-align: center; width: 14.639397201291713%;\" scope=\"col\" valign=\"top\">\r\n<div align=\"center\">Others<\/div><\/th>\r\n<\/tr>\r\n<\/thead>\r\n<tbody>\r\n<tr style=\"height: 15px;\">\r\n<td style=\"vertical-align: top; text-align: center; width: 24.97308934337998%;\" valign=\"top\">\r\n<div align=\"center\">9<\/div><\/td>\r\n<td style=\"vertical-align: top; text-align: center; width: 13.347685683530678%;\" valign=\"top\">\r\n<div align=\"center\">2<\/div><\/td>\r\n<td style=\"vertical-align: top; text-align: center; width: 14.531754574811625%;\" valign=\"top\">\r\n<div align=\"center\">17<\/div><\/td>\r\n<td style=\"vertical-align: top; text-align: center; width: 10.979547900968784%;\" valign=\"top\">\r\n<div align=\"center\">6<\/div><\/td>\r\n<td style=\"vertical-align: top; text-align: center; width: 21.420882669537136%;\" valign=\"top\">\r\n<div align=\"center\">3<\/div><\/td>\r\n<td style=\"vertical-align: top; text-align: center; width: 14.639397201291713%;\" valign=\"top\">\r\n<div align=\"center\">0<\/div><\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/div>\r\nTest at the 5% significance level whether the class had different voting preferences than all Canadians in the 2015 election.\r\n\r\n<strong>Check the assumptions<\/strong>: since [latex]n = 37[\/latex], each expected frequency is computed as [latex]E = np = 37 \\times p[\/latex]. For example, the expected count of conservative voters is [latex]E = 37 \\times 0.319 = 11.803[\/latex]. The following table gives all expected counts:\r\n<p style=\"text-align: center;\"><strong>Table 11.3<\/strong>: Expected Frequency of Voting Preference<\/p>\r\n\r\n<div align=\"center\">\r\n<table class=\"first-col-border\" style=\"width: 100%; height: 74px;\" border=\"1\" cellspacing=\"0\" cellpadding=\"2\">\r\n<thead>\r\n<tr class=\"border-bottom\" style=\"height: 30px;\">\r\n<td style=\"width: 42.73049645390071%; height: 30px; vertical-align: top;\" valign=\"top\" width=\"130\"><\/td>\r\n<th style=\"width: 10.99290780141844%; height: 30px; text-align: center; vertical-align: top;\" scope=\"col\" valign=\"top\" width=\"117\">Conservative<\/th>\r\n<th style=\"width: 9.042553191489361%; height: 30px; text-align: center; vertical-align: top;\" scope=\"col\" valign=\"top\" width=\"64\">Green<\/th>\r\n<th style=\"width: 7.446808510638297%; height: 30px; text-align: center; vertical-align: top;\" scope=\"col\" valign=\"top\" width=\"65\">Liberal<\/th>\r\n<th style=\"width: 8.865248226950357%; height: 30px; text-align: center; vertical-align: top;\" scope=\"col\" valign=\"top\" width=\"59\">NDP<\/th>\r\n<th style=\"width: 9.929078014184396%; height: 30px; text-align: center; vertical-align: top;\" scope=\"col\" valign=\"top\" width=\"139\">Bloc Qu\u00e9b\u00e9cois<\/th>\r\n<th style=\"width: 10.815602836879432%; height: 30px; text-align: center; vertical-align: top;\" scope=\"col\" valign=\"top\" width=\"77\">Others<\/th>\r\n<\/tr>\r\n<\/thead>\r\n<tbody>\r\n<tr style=\"height: 29px;\">\r\n<th style=\"width: 42.73049645390071%; height: 29px; vertical-align: top;\" scope=\"row\" valign=\"top\" width=\"130\">Proportion [latex](p)[\/latex]<\/th>\r\n<td style=\"width: 10.99290780141844%; height: 29px; text-align: center; vertical-align: top;\" valign=\"top\" width=\"117\">\r\n<div align=\"center\">0.319<\/div><\/td>\r\n<td style=\"width: 9.042553191489361%; height: 29px; text-align: center; vertical-align: top;\" valign=\"top\" width=\"64\">\r\n<div align=\"center\">0.034<\/div><\/td>\r\n<td style=\"width: 7.446808510638297%; height: 29px; text-align: center; vertical-align: top;\" valign=\"top\" width=\"65\">\r\n<div align=\"center\">0.395<\/div><\/td>\r\n<td style=\"width: 8.865248226950357%; height: 29px; text-align: center; vertical-align: top;\" valign=\"top\" width=\"59\">\r\n<div align=\"center\">0.197<\/div><\/td>\r\n<td style=\"width: 9.929078014184396%; height: 29px; text-align: center; vertical-align: top;\" valign=\"top\" width=\"139\">\r\n<div align=\"center\">0.047<\/div><\/td>\r\n<td style=\"width: 10.815602836879432%; height: 29px; text-align: center; vertical-align: top;\" valign=\"top\" width=\"77\">\r\n<div align=\"center\">0.008<\/div><\/td>\r\n<\/tr>\r\n<tr style=\"height: 15px;\">\r\n<th style=\"width: 42.73049645390071%; height: 15px; vertical-align: top;\" scope=\"row\" valign=\"top\" width=\"130\">Counts<\/th>\r\n<td style=\"width: 10.99290780141844%; height: 15px; text-align: center; vertical-align: top;\" valign=\"top\" width=\"117\">\r\n<div align=\"center\">11.803<\/div><\/td>\r\n<td style=\"width: 9.042553191489361%; height: 15px; text-align: center; vertical-align: top;\" valign=\"top\" width=\"64\">\r\n<div align=\"center\">1.258<\/div><\/td>\r\n<td style=\"width: 7.446808510638297%; height: 15px; text-align: center; vertical-align: top;\" valign=\"top\" width=\"65\">\r\n<div align=\"center\">14.615<\/div><\/td>\r\n<td style=\"width: 8.865248226950357%; height: 15px; text-align: center; vertical-align: top;\" valign=\"top\" width=\"59\">\r\n<div align=\"center\">7.289<\/div><\/td>\r\n<td style=\"width: 9.929078014184396%; height: 15px; text-align: center; vertical-align: top;\" valign=\"top\" width=\"139\">\r\n<div align=\"center\">1.739<\/div><\/td>\r\n<td style=\"width: 10.815602836879432%; height: 15px; text-align: center; vertical-align: top;\" valign=\"top\" width=\"77\">\r\n<div align=\"center\">0.296<\/div><\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/div>\r\n<div align=\"center\"><\/div>\r\nThere are [latex]k = 6[\/latex] cells and at most [latex]6 \\times 0.2 = 1.2[\/latex] cells are expected to have expected counts less than 5; however, there are actually three cells less than 5. We could combine the cells \u201cGreen\u201d, \u201cBloc Qu\u00e9b\u00e9cois\u201d and \u201cOthers\u201d, and name it as \u201cOthers\u201d. Therefore, we have the working table as follows.\r\n\r\n<strong>Table 11.4<\/strong>: Working Table for a Chi-Square Goodness of Fit Test (Example)\r\n<div align=\"center\">\r\n<table style=\"width: 100%; height: 180px;\" border=\"1\" cellspacing=\"0\" cellpadding=\"3\">\r\n<tfoot>\r\n<tr class=\"shaded\" style=\"height: 30px;\">\r\n<td style=\"text-align: left; width: 14.1642%; height: 30px;\" valign=\"top\" width=\"117\"><\/td>\r\n<td style=\"width: 17.9262%; height: 30px; text-align: left;\" valign=\"top\" width=\"99\">\r\n<div align=\"center\">[latex]\\text{Sum}=1[\/latex]<\/div><\/td>\r\n<td style=\"width: 18.1367%; height: 30px; text-align: left;\" valign=\"top\" width=\"94\">\r\n<div align=\"center\">[latex]\\text{Sum}=37[\/latex]<\/div><\/td>\r\n<td style=\"width: 24.9501%; height: 30px; text-align: left;\" valign=\"top\" width=\"151\">\r\n<div align=\"center\">[latex]\\text{Sum}=37[\/latex]<\/div><\/td>\r\n<td style=\"width: 24.6454%; height: 30px; text-align: right;\" valign=\"top\" width=\"189\">\r\n<div align=\"center\">[latex]\\text{Sum}=\\chi_o^2 = 2.1667[\/latex]<\/div><\/td>\r\n<\/tr>\r\n<\/tfoot>\r\n<thead>\r\n<tr style=\"height: 30px;\">\r\n<th class=\"shaded\" style=\"width: 14.1642%; vertical-align: top; height: 30px;\" scope=\"col\">\r\n<div align=\"center\">Parties<\/div><\/th>\r\n<th class=\"shaded\" style=\"width: 17.9262%; height: 30px;\" scope=\"col\">\r\n<div align=\"center\">Proportion [latex]p[\/latex]<\/div><\/th>\r\n<th class=\"shaded\" style=\"width: 18.1367%; height: 30px;\" scope=\"col\">\r\n<div align=\"center\">Observed [latex]O[\/latex]<\/div><\/th>\r\n<th class=\"shaded\" style=\"width: 24.9501%; height: 30px;\" scope=\"col\">\r\n<div align=\"center\">Expected\r\n[latex]E = np = 37 \\times p[\/latex]<\/div><\/th>\r\n<th class=\"shaded\" style=\"width: 24.6454%; height: 30px; text-align: right;\" scope=\"col\">\r\n<div align=\"center\">[latex]\\frac{(O - E)^2}{E}[\/latex]<\/div><\/th>\r\n<\/tr>\r\n<\/thead>\r\n<tbody>\r\n<tr style=\"height: 30px;\">\r\n<td style=\"text-align: left; width: 14.1642%; height: 30px;\" valign=\"top\" width=\"117\">\r\n<div align=\"center\">Conservative<\/div><\/td>\r\n<td style=\"width: 17.9262%; height: 30px; text-align: left;\" valign=\"top\" width=\"99\">\r\n<div align=\"center\">[latex]0.319[\/latex]<\/div><\/td>\r\n<td style=\"width: 18.1367%; height: 30px; text-align: left;\" valign=\"top\" width=\"94\">\r\n<div align=\"center\">[latex]9[\/latex]<\/div><\/td>\r\n<td style=\"width: 24.9501%; height: 30px; text-align: left;\" valign=\"top\" width=\"151\">\r\n<div align=\"center\">[latex]37 \\times 0.319=11.803[\/latex]<\/div><\/td>\r\n<td style=\"width: 24.6454%; height: 30px; text-align: right;\" valign=\"top\" width=\"189\">\r\n<div align=\"center\">[latex]\\frac{(9 - 11.803)^2}{11.803} = 0.6657[\/latex]<\/div><\/td>\r\n<\/tr>\r\n<tr style=\"height: 30px;\">\r\n<td style=\"text-align: left; width: 14.1642%; height: 30px;\" valign=\"top\" width=\"117\">\r\n<div>Liberal<\/div><\/td>\r\n<td style=\"width: 17.9262%; height: 30px; text-align: left;\" valign=\"top\" width=\"99\">\r\n<div align=\"center\">[latex]0.395[\/latex]<\/div><\/td>\r\n<td style=\"width: 18.1367%; height: 30px; text-align: left;\" valign=\"top\" width=\"94\">\r\n<div align=\"center\">[latex]17[\/latex]<\/div><\/td>\r\n<td style=\"width: 24.9501%; height: 30px; text-align: left;\" valign=\"top\" width=\"151\">\r\n<div align=\"center\">[latex]37 \\times 0.395=14.615[\/latex]<\/div><\/td>\r\n<td style=\"width: 24.6454%; height: 30px; text-align: right;\" valign=\"top\" width=\"189\">\r\n<div align=\"center\">[latex]\\frac{(17 - 14.615)^2}{14.615} = 0.3892[\/latex]<\/div><\/td>\r\n<\/tr>\r\n<tr style=\"height: 30px;\">\r\n<td style=\"text-align: left; width: 14.1642%; height: 30px;\" valign=\"top\" width=\"117\">NDP<\/td>\r\n<td style=\"width: 17.9262%; height: 30px; text-align: left;\" valign=\"top\" width=\"99\">\r\n<div align=\"center\">[latex]0.197[\/latex]<\/div><\/td>\r\n<td style=\"width: 18.1367%; height: 30px; text-align: left;\" valign=\"top\" width=\"94\">\r\n<div align=\"center\">[latex]6[\/latex]<\/div><\/td>\r\n<td style=\"width: 24.9501%; height: 30px; text-align: left;\" valign=\"top\" width=\"151\">\r\n<div align=\"center\">[latex]37 \\times 0.197=7.289[\/latex]<\/div><\/td>\r\n<td style=\"width: 24.6454%; height: 30px; text-align: right;\" valign=\"top\" width=\"189\">\r\n<div align=\"center\">[latex]\\frac{(6 - 7.289)^2}{7.289} = 0.2279[\/latex]<\/div><\/td>\r\n<\/tr>\r\n<tr style=\"height: 30px;\">\r\n<td style=\"text-align: left; width: 14.1642%; height: 30px;\" valign=\"top\" width=\"117\">\r\n<div>Others<\/div><\/td>\r\n<td style=\"width: 17.9262%; height: 30px; text-align: left;\" valign=\"top\" width=\"99\">\r\n<div align=\"center\"><strong>[latex]0.089[\/latex]<\/strong><\/div><\/td>\r\n<td style=\"width: 18.1367%; height: 30px; text-align: left;\" valign=\"top\" width=\"94\">\r\n<div align=\"center\">[latex]2+3+0=5[\/latex]<\/div><\/td>\r\n<td style=\"width: 24.9501%; height: 30px; text-align: left;\" valign=\"top\" width=\"151\">\r\n<div align=\"center\">[latex]37 \\times 0.089=3.293[\/latex]<\/div><\/td>\r\n<td style=\"width: 24.6454%; height: 30px; text-align: right;\" valign=\"top\" width=\"189\">\r\n<div align=\"center\">[latex]\\frac{(5 - 3.293)^2}{3.293} = 0.8849[\/latex]<\/div><\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/div>\r\nNote: After combining the cells, all the expected counts are greater than 1, while 25% of the expected counts are below 5 (the expected count for Others is below 5). Since more than 20% of the expected counts are below 5, there is still a violation in the assumptions. However, the expected frequency for \"Others\" is 3.293 which is not very far away from 5. To maintain a meaningful number of parties, we proceed to conduct the chi-square goodness-of-fit test.\r\n\r\n<strong>Steps <\/strong><strong>to perform a <\/strong><strong>chi-square goodness-of-fit test<\/strong>:\r\n<ol>\r\n \t<li>Set up the hypotheses: [latex]\\begin{align*}\r\nH_0 &amp; : p_{\\scriptsize C} = 0.319, p_{\\scriptsize L} = 0.395, p_{\\scriptsize NDP} = 0.197, p_{\\scriptsize Others} = 0.089 \\\\ H_a &amp; : \\text{At least one proportion is different from those specified in } H_0. \\end{align*}[\/latex]<\/li>\r\n \t<li>The significance level is [latex]\\alpha = 0.05[\/latex].<\/li>\r\n \t<li>The test statistic: [latex]\\chi_o^2 = \\sum_{\\text{all cells}} \\frac{(O- E)^2}{E} = 2.1677[\/latex], with [latex]df = k -1 = 4 - 1 =3[\/latex].<\/li>\r\n \t<li>Find the P-value. Since chi-square tests are always right-tailed, the p-value is\r\nP-value [latex] = P(\\chi^2 \\geq \\chi_o^2) = P(\\chi^2 \\geq 2.1677) \\: \\gt \\: 0.1[\/latex].<\/li>\r\n \t<li>Decision: We do not reject the null [latex]H_0[\/latex], since P-value [latex] \\: \\gt \\: 0.1 \\: \\gt \\: 0.05(\\alpha)[\/latex].<\/li>\r\n \t<li>Conclusion: At the 5% significance level, we do not have sufficient evidence that the class had different voting preferences than all Canadians in the 2015 election.<\/li>\r\n<\/ol>\r\n<strong>If using the critical value approach, steps 4\u20136 are as follows<\/strong>:\r\n<ol start=\"4\">\r\n \t<li>Find the rejection region. For a right-tailed test with [latex]df=3[\/latex], the rejection region is to the right of the critical value [latex]\\chi^2 \\geq \\chi_{\\alpha}^2 = \\chi_{0.05}^2 = 7.815[\/latex].<\/li>\r\n \t<li><span style=\"font-size: 1em;\">Decision: We do not reject the null [latex]H_0[\/latex] since [latex]\\chi_o^2 = 2.1667 &lt; 7.815[\/latex] falls in the non-rejection region.<\/span><\/li>\r\n \t<li>Conclusion: At the 5% significance level, we do not have sufficient evidence that the class had different voting preferences than all Canadians in the 2015 election.<\/li>\r\n<\/ol>\r\n<\/div>\r\n<\/div>\r\n<div style=\"height: 55px; margin-top: 5px;\"><img class=\"size-full wp-image-99 alignleft\" src=\"https:\/\/openbooks.macewan.ca\/rcommander\/wp-content\/uploads\/sites\/8\/2020\/06\/activity.png\" alt=\"\" width=\"250\" height=\"50\" \/><\/div>\r\n<div class=\"textbox textbox--exercises\"><header class=\"textbox__header\">\r\n<p class=\"textbox__title\">Exercise: Chi-square goodness-of-fit test<\/p>\r\n\r\n<\/header>\r\n<div class=\"textbox__content\">\r\n\r\nA company claims their deluxe mixed nuts consist of 20% peanuts, 60% cashews, and 20% almonds. An inspector obtains a random sample of [latex]n = 100[\/latex] nuts and observes 30 peanuts, 55 cashews, and 15 almonds. Test at the 5% significance level whether the percentages differ from what the company claims.\r\n\r\n<details><summary>Show\/Hide Answer<\/summary><strong>Answers:<\/strong>\r\n\r\n<strong>Check the assumptions<\/strong>: [latex]n = 100[\/latex]\u00a0and the expected counts are\r\n[latex]E_{\\text{peanut}} = 100 \\times 0.2 = 20, E_{\\text{cashew}} = 100 \\times 0.6 = 60,[\/latex] [latex]E_{\\text{almond}} = 100 \\times 0.2 = 20[\/latex] and all greater than 5.\r\n\r\n<strong>Steps to perform a chi-square goodness-of-fit test<\/strong>:\r\n<ol>\r\n \t<li>Set up the hypotheses:\r\n[latex]\\begin{align*} H_0 &amp;: p_{\\text{peanut}} = 0.2, p_{\\text{cashew}} = 0.6, p_{\\text{almond}} = 0.2 \u00a0\\\\ H_a &amp;: \\text{at least one proportion is different from those specified in } H_0. \\end{align*}[\/latex]<\/li>\r\n \t<li>The significance level is [latex]\\alpha = 0.05[\/latex].<\/li>\r\n \t<li>The test statistic with the working table:\r\n<div align=\"center\">\r\n<p style=\"text-align: center;\"><strong>Table 11.5<\/strong>: Working Table for Chi-Square Goodness-of-Fit Test (Exercise)<\/p>\r\n\r\n<table style=\"width: 100%; height: 176px;\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\r\n<tfoot>\r\n<tr class=\"shaded\" style=\"height: 30px;\">\r\n<td style=\"height: 30px; width: 15.96153846153846%;\" valign=\"top\" width=\"88\">\r\n<div align=\"center\"><strong>\u00a0<\/strong><\/div><\/td>\r\n<td style=\"height: 30px; text-align: center; width: 19.423076923076923%;\" valign=\"top\" width=\"103\">\r\n<div align=\"center\">[latex]\\text{Sum}=1[\/latex]<\/div><\/td>\r\n<td style=\"height: 30px; text-align: center; width: 18.269230769230766%;\" valign=\"top\" width=\"100\">\r\n<div align=\"center\">[latex]\\text{Sum}=100[\/latex]<\/div><\/td>\r\n<td style=\"height: 30px; text-align: center; width: 21.346153846153847%;\" valign=\"top\" width=\"141\">\r\n<div align=\"center\">[latex]\\text{Sum}=100[\/latex]<\/div><\/td>\r\n<td style=\"height: 30px; text-align: center; width: 25%;\" valign=\"top\" width=\"188\">\r\n<div align=\"center\">[latex]\\text{Sum}= \\chi_o^2 = 6.667[\/latex]<\/div><\/td>\r\n<\/tr>\r\n<\/tfoot>\r\n<thead>\r\n<tr class=\"shaded\" style=\"height: 58px;\">\r\n<th style=\"text-align: left; height: 11px; vertical-align: top; width: 15.96153846153846%;\" scope=\"col\" valign=\"top\" width=\"88\"><strong>Nuts<\/strong><\/th>\r\n<th style=\"text-align: center; height: 11px; vertical-align: top; width: 19.423076923076923%;\" scope=\"col\" valign=\"top\" width=\"103\"><strong>Proportion<\/strong>\r\n<strong>p<\/strong><\/th>\r\n<th style=\"text-align: center; height: 11px; vertical-align: top; width: 18.269230769230766%;\" scope=\"col\" valign=\"top\" width=\"100\"><strong>Observed <\/strong>\r\n<strong><em>(O)<\/em><\/strong><\/th>\r\n<th style=\"text-align: center; height: 11px; vertical-align: top; width: 21.346153846153847%;\" scope=\"col\" valign=\"top\" width=\"141\"><strong>Expected<\/strong>\r\n[latex]E = np = 100 \\times p[\/latex]<\/th>\r\n<th style=\"text-align: center; height: 11px; vertical-align: top; width: 25%;\" scope=\"col\" valign=\"top\" width=\"188\">[latex]\\frac{(O-E)^2}{E}[\/latex]<\/th>\r\n<\/tr>\r\n<\/thead>\r\n<tbody>\r\n<tr style=\"height: 45px;\">\r\n<td style=\"height: 45px; text-align: left; width: 15.96153846153846%;\" valign=\"top\" width=\"88\">\r\n<div align=\"center\">Peanut<\/div><\/td>\r\n<td style=\"height: 45px; text-align: center; width: 19.423076923076923%;\" valign=\"top\" width=\"103\">\r\n<div align=\"center\">[latex]0.2[\/latex]<\/div><\/td>\r\n<td style=\"height: 45px; text-align: center; width: 18.269230769230766%;\" valign=\"top\" width=\"100\">\r\n<div align=\"center\">[latex]30[\/latex]<\/div><\/td>\r\n<td style=\"height: 45px; text-align: center; width: 21.346153846153847%;\" valign=\"top\" width=\"141\">\r\n<div align=\"center\">[latex]100 \\times 0.2 = 20[\/latex]<\/div><\/td>\r\n<td style=\"height: 45px; text-align: center; width: 25%;\" valign=\"top\" width=\"188\">\r\n<div align=\"center\">[latex]\\frac{(30 - 20)^2}{20} = 5.000[\/latex]<\/div><\/td>\r\n<\/tr>\r\n<tr style=\"height: 45px;\">\r\n<td style=\"height: 45px; text-align: left; width: 15.96153846153846%;\" valign=\"top\" width=\"88\">\r\n<div align=\"center\">Cashew<\/div><\/td>\r\n<td style=\"height: 45px; text-align: center; width: 19.423076923076923%;\" valign=\"top\" width=\"103\">\r\n<div align=\"center\">[latex]0.6[\/latex]<\/div><\/td>\r\n<td style=\"height: 45px; text-align: center; width: 18.269230769230766%;\" valign=\"top\" width=\"100\">\r\n<div align=\"center\">[latex]55[\/latex]<\/div><\/td>\r\n<td style=\"height: 45px; text-align: center; width: 21.346153846153847%;\" valign=\"top\" width=\"141\">\r\n<div align=\"center\">[latex]100 \\times 0.6 = 60[\/latex]<\/div><\/td>\r\n<td style=\"height: 45px; text-align: center; width: 25%;\" valign=\"top\" width=\"188\">\r\n<div align=\"center\">[latex]\\frac{(55 - 60)^2}{60} = 0.417[\/latex]<\/div><\/td>\r\n<\/tr>\r\n<tr style=\"height: 45px;\">\r\n<td style=\"height: 45px; text-align: left; width: 15.96153846153846%;\" valign=\"top\" width=\"88\">\r\n<div align=\"center\">Almond<\/div><\/td>\r\n<td style=\"height: 45px; text-align: center; width: 19.423076923076923%;\" valign=\"top\" width=\"103\">\r\n<div align=\"center\">[latex]0.2[\/latex]<\/div><\/td>\r\n<td style=\"height: 45px; text-align: center; width: 18.269230769230766%;\" valign=\"top\" width=\"100\">\r\n<div align=\"center\">[latex]15[\/latex]<\/div><\/td>\r\n<td style=\"height: 45px; text-align: center; width: 21.346153846153847%;\" valign=\"top\" width=\"141\">\r\n<div align=\"center\">[latex]100 \\times 0.2 = 20[\/latex]<\/div><\/td>\r\n<td style=\"height: 45px; text-align: center; width: 25%;\" valign=\"top\" width=\"188\">\r\n<div align=\"center\">[latex]\\frac{(15 - 20)^2}{20} = 1.250[\/latex]<\/div><\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/div>\r\n[latex]\\chi_o^2 = \\sum_{\\text{all cells}} \\frac{(O - E)^2}{E} = 6.667[\/latex] with [latex]df = k - 1 = 3-1 =2[\/latex].<\/li>\r\n \t<li>Find the P-value: P-value [latex]P(\\chi^2 \\geq \\chi_o^2) = P(\\chi^2 \\geq 6.667)[\/latex].\r\nSince [latex]5.991 (\\chi_{0.05}^2) &lt; \\chi_o^2=6.667 &lt; 7.378 (\\chi_{0.025}^2)[\/latex], 0.025 &lt; P-value &lt; 0.05.<\/li>\r\n \t<li>Decision: We should reject the null [latex]H_0[\/latex] since P-value &lt;0.05([latex]\\alpha[\/latex]).<\/li>\r\n \t<li>Conclusion: At the 5% significance level, we have sufficient evidence that the percentages of nuts are different from what the company claims.<\/li>\r\n<\/ol>\r\n<\/details><\/div>\r\n<\/div>","rendered":"<p>The chi-square goodness-of-fit test can be applied to either a categorical or discrete quantitative variable with a finite number of values. The objective of the chi-square goodness-of-fit test is to test whether the variable does not follow the probability distribution specified in the null hypothesis [latex]H_0[\/latex].<\/p>\n<p>The main idea behind the chi-square goodness-of-fit test is to compare the observed frequencies (O) to the expected frequencies ([latex]E[\/latex]), which are based on the probability distribution specified in [latex]H_0[\/latex]. If [latex]H_0[\/latex] is true, the observed and expected frequencies should be reasonably similar. Therefore, we reject [latex]H_0[\/latex] if the observed and expected frequencies are very different. The discrepancy between the observed and expected frequencies can be quantified by chi-square statistic<\/p>\n<p style=\"text-align: center;\">[latex]\\chi^2 = \\sum_{\\text{all cells}} \\frac{(O - E)^2}{E}[\/latex]<\/p>\n<p>which follows a chi-square distribution with [latex]df = k-1[\/latex], where [latex]k[\/latex] is the number of possible values for the variable under consideration. The chi-square statistic will be large when the observed and expected frequencies are very different. Thus, we reject the null hypothesis when the chi-square statistic is sufficiently large. More specifically, at the significance level of [latex]\\alpha[\/latex], we reject [latex]H_0[\/latex] if the chi-square statistic is larger than the critical value [latex]\\chi_{\\alpha}^2[\/latex]. Since we only reject [latex]H_0[\/latex] if the chi-square statistic is sufficiently large, chi-square tests are always right-tailed. That is, both the rejection region and the p-value are upper-tailed probabilities.<\/p>\n<h2><strong>Chi-Square Goodness-of-Fit Test<\/strong><\/h2>\n<div class=\"textbox\">\n<p><strong>Assumptions<\/strong>:<\/p>\n<ol>\n<li>All expected frequencies are at least 1.<\/li>\n<li>At most 20% of the expected frequencies are less than 5.<\/li>\n<li>Simple random sample (if you need to generalize the conclusion to a larger population).<\/li>\n<\/ol>\n<p><strong>Note<\/strong>: If assumptions 1 or 2 are violated, one can consider combining the cells to increase the counts in those cells.<\/p>\n<p><strong>Steps to perform a <\/strong><strong>chi-square goodness-of-fit test<\/strong>:<\/p>\n<p>First, check the assumptions. Calculate the expected frequency for each possible value of the variable using [latex]E=np[\/latex], where [latex]n[\/latex] is the total number of observations and [latex]p[\/latex] is the relative frequency (or probability) specified in the null hypothesis. Check whether the expected frequencies satisfy assumptions 1 and 2. If not, consider combining some cells.<\/p>\n<ol>\n<li>Set up the hypotheses:<br \/>\n[latex]\\begin{align*} H_0 &: \\text{The variable has the specified distribution }\\\\ H_a &: \\text{The variable does not have the specified distribution}. \\end{align*}[\/latex]<\/li>\n<li>State the significance level [latex]\\alpha[\/latex].<\/li>\n<li>Compute the value of the test statistic: [latex]\\chi_o^2 = \\sum_{\\text{all cells}} \\frac{(O - E)^2}{E}[\/latex] with [latex]df = k-1[\/latex].<\/li>\n<li>Find the P-value <strong>or<\/strong> rejection region based on the [latex]\\chi^2[\/latex] curve with [latex]df = k-1[\/latex].\n<div style=\"margin: auto;\">\n<table class=\"first-col-border\" style=\"width: 100%; height: 60px; border-spacing: 0px;\" cellpadding=\"0\">\n<tbody>\n<tr style=\"height: 30px;\">\n<th style=\"width: 16.88888888888889%; height: 30px; vertical-align: top;\" scope=\"row\" valign=\"top\">Rejection region<\/th>\n<td style=\"width: 82.96296296296296%; height: 30px; vertical-align: top;\" valign=\"top\">[latex]\\chi^2 \\geq \\chi_{\\alpha}^2[\/latex] the region to the right of [latex]\\chi_{\\alpha}^2[\/latex], the area is [latex]\\alpha[\/latex]<\/td>\n<\/tr>\n<tr class=\"border-top\" style=\"height: 30px;\">\n<th style=\"width: 16.88888888888889%; height: 30px; vertical-align: top;\" scope=\"row\" valign=\"top\">P-value<\/th>\n<td style=\"width: 82.96296296296296%; height: 30px; vertical-align: top;\" valign=\"top\">\u00a0[latex]P(\\chi^2 \\geq \\chi_o^2)[\/latex] the area to the right of [latex]\\chi_o^2[\/latex]\u00a0under the curve<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/li>\n<li>Reject the null [latex]H_0[\/latex]\u00a0if P-value [latex]\\leq \\alpha[\/latex]\u00a0or [latex]\\chi_o^2[\/latex]\u00a0falls in the rejection region.<\/li>\n<li>Conclusion.<\/li>\n<\/ol>\n<\/div>\n<p>&nbsp;<\/p>\n<div class=\"textbox textbox--examples\">\n<header class=\"textbox__header\">\n<p class=\"textbox__title\">Example: Chi-Square Goodness-of-Fit Test<\/p>\n<\/header>\n<div class=\"textbox__content\">\n<p>According to the results of the federal election in 2015, 31.9% of votes supported the Conservative Party, 39.5% supported the Liberal Party, 19.7% supported the New Democratic Party (NDP), 4.7% supported Bloc Qu\u00e9b\u00e9cois, and 3.4% supported the Green Party (data from Wikipedia). Thirty-seven students in my Stat151 class responded to an\u00a0online survey and their preferences are summarized in the following table:<\/p>\n<p style=\"text-align: center;\"><strong>Table 11.2<\/strong>: Voting Preference of the Class<\/p>\n<div style=\"margin: auto;\">\n<table style=\"height: 30px; width: 100%; border-spacing: 0px;\" cellpadding=\"3\">\n<thead>\n<tr style=\"height: 15px;\">\n<th class=\"shaded\" style=\"vertical-align: top; text-align: center; width: 24.97308934337998%;\" scope=\"col\" valign=\"top\">\n<div style=\"margin: auto;\">Conservative<\/div>\n<\/th>\n<th class=\"shaded\" style=\"vertical-align: top; text-align: center; width: 13.347685683530678%;\" scope=\"col\" valign=\"top\">\n<div style=\"margin: auto;\">Green<\/div>\n<\/th>\n<th class=\"shaded\" style=\"vertical-align: top; text-align: center; width: 14.531754574811625%;\" scope=\"col\" valign=\"top\">\n<div style=\"margin: auto;\">Liberal<\/div>\n<\/th>\n<th class=\"shaded\" style=\"vertical-align: top; text-align: center; width: 10.979547900968784%;\" scope=\"col\" valign=\"top\">\n<div style=\"margin: auto;\">NDP<\/div>\n<\/th>\n<th class=\"shaded\" style=\"vertical-align: top; text-align: center; width: 21.420882669537136%;\" scope=\"col\" valign=\"top\">\n<div style=\"margin: auto;\">Not Voting<\/div>\n<\/th>\n<th class=\"shaded\" style=\"vertical-align: top; text-align: center; width: 14.639397201291713%;\" scope=\"col\" valign=\"top\">\n<div style=\"margin: auto;\">Others<\/div>\n<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr style=\"height: 15px;\">\n<td style=\"vertical-align: top; text-align: center; width: 24.97308934337998%;\" valign=\"top\">\n<div style=\"margin: auto;\">9<\/div>\n<\/td>\n<td style=\"vertical-align: top; text-align: center; width: 13.347685683530678%;\" valign=\"top\">\n<div style=\"margin: auto;\">2<\/div>\n<\/td>\n<td style=\"vertical-align: top; text-align: center; width: 14.531754574811625%;\" valign=\"top\">\n<div style=\"margin: auto;\">17<\/div>\n<\/td>\n<td style=\"vertical-align: top; text-align: center; width: 10.979547900968784%;\" valign=\"top\">\n<div style=\"margin: auto;\">6<\/div>\n<\/td>\n<td style=\"vertical-align: top; text-align: center; width: 21.420882669537136%;\" valign=\"top\">\n<div style=\"margin: auto;\">3<\/div>\n<\/td>\n<td style=\"vertical-align: top; text-align: center; width: 14.639397201291713%;\" valign=\"top\">\n<div style=\"margin: auto;\">0<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Test at the 5% significance level whether the class had different voting preferences than all Canadians in the 2015 election.<\/p>\n<p><strong>Check the assumptions<\/strong>: since [latex]n = 37[\/latex], each expected frequency is computed as [latex]E = np = 37 \\times p[\/latex]. For example, the expected count of conservative voters is [latex]E = 37 \\times 0.319 = 11.803[\/latex]. The following table gives all expected counts:<\/p>\n<p style=\"text-align: center;\"><strong>Table 11.3<\/strong>: Expected Frequency of Voting Preference<\/p>\n<div style=\"margin: auto;\">\n<table class=\"first-col-border\" style=\"width: 100%; height: 74px; border-spacing: 0px;\" cellpadding=\"2\">\n<thead>\n<tr class=\"border-bottom\" style=\"height: 30px;\">\n<td style=\"width: 42.73049645390071%; height: 30px; vertical-align: top; width: 130px;\" valign=\"top\"><\/td>\n<th style=\"width: 10.99290780141844%; height: 30px; text-align: center; vertical-align: top; width: 117px;\" scope=\"col\" valign=\"top\">Conservative<\/th>\n<th style=\"width: 9.042553191489361%; height: 30px; text-align: center; vertical-align: top; width: 64px;\" scope=\"col\" valign=\"top\">Green<\/th>\n<th style=\"width: 7.446808510638297%; height: 30px; text-align: center; vertical-align: top; width: 65px;\" scope=\"col\" valign=\"top\">Liberal<\/th>\n<th style=\"width: 8.865248226950357%; height: 30px; text-align: center; vertical-align: top; width: 59px;\" scope=\"col\" valign=\"top\">NDP<\/th>\n<th style=\"width: 9.929078014184396%; height: 30px; text-align: center; vertical-align: top; width: 139px;\" scope=\"col\" valign=\"top\">Bloc Qu\u00e9b\u00e9cois<\/th>\n<th style=\"width: 10.815602836879432%; height: 30px; text-align: center; vertical-align: top; width: 77px;\" scope=\"col\" valign=\"top\">Others<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr style=\"height: 29px;\">\n<th style=\"width: 42.73049645390071%; height: 29px; vertical-align: top; width: 130px;\" scope=\"row\" valign=\"top\">Proportion [latex](p)[\/latex]<\/th>\n<td style=\"width: 10.99290780141844%; height: 29px; text-align: center; vertical-align: top; width: 117px;\" valign=\"top\">\n<div style=\"margin: auto;\">0.319<\/div>\n<\/td>\n<td style=\"width: 9.042553191489361%; height: 29px; text-align: center; vertical-align: top; width: 64px;\" valign=\"top\">\n<div style=\"margin: auto;\">0.034<\/div>\n<\/td>\n<td style=\"width: 7.446808510638297%; height: 29px; text-align: center; vertical-align: top; width: 65px;\" valign=\"top\">\n<div style=\"margin: auto;\">0.395<\/div>\n<\/td>\n<td style=\"width: 8.865248226950357%; height: 29px; text-align: center; vertical-align: top; width: 59px;\" valign=\"top\">\n<div style=\"margin: auto;\">0.197<\/div>\n<\/td>\n<td style=\"width: 9.929078014184396%; height: 29px; text-align: center; vertical-align: top; width: 139px;\" valign=\"top\">\n<div style=\"margin: auto;\">0.047<\/div>\n<\/td>\n<td style=\"width: 10.815602836879432%; height: 29px; text-align: center; vertical-align: top; width: 77px;\" valign=\"top\">\n<div style=\"margin: auto;\">0.008<\/div>\n<\/td>\n<\/tr>\n<tr style=\"height: 15px;\">\n<th style=\"width: 42.73049645390071%; height: 15px; vertical-align: top; width: 130px;\" scope=\"row\" valign=\"top\">Counts<\/th>\n<td style=\"width: 10.99290780141844%; height: 15px; text-align: center; vertical-align: top; width: 117px;\" valign=\"top\">\n<div style=\"margin: auto;\">11.803<\/div>\n<\/td>\n<td style=\"width: 9.042553191489361%; height: 15px; text-align: center; vertical-align: top; width: 64px;\" valign=\"top\">\n<div style=\"margin: auto;\">1.258<\/div>\n<\/td>\n<td style=\"width: 7.446808510638297%; height: 15px; text-align: center; vertical-align: top; width: 65px;\" valign=\"top\">\n<div style=\"margin: auto;\">14.615<\/div>\n<\/td>\n<td style=\"width: 8.865248226950357%; height: 15px; text-align: center; vertical-align: top; width: 59px;\" valign=\"top\">\n<div style=\"margin: auto;\">7.289<\/div>\n<\/td>\n<td style=\"width: 9.929078014184396%; height: 15px; text-align: center; vertical-align: top; width: 139px;\" valign=\"top\">\n<div style=\"margin: auto;\">1.739<\/div>\n<\/td>\n<td style=\"width: 10.815602836879432%; height: 15px; text-align: center; vertical-align: top; width: 77px;\" valign=\"top\">\n<div style=\"margin: auto;\">0.296<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<div style=\"margin: auto;\"><\/div>\n<p>There are [latex]k = 6[\/latex] cells and at most [latex]6 \\times 0.2 = 1.2[\/latex] cells are expected to have expected counts less than 5; however, there are actually three cells less than 5. We could combine the cells \u201cGreen\u201d, \u201cBloc Qu\u00e9b\u00e9cois\u201d and \u201cOthers\u201d, and name it as \u201cOthers\u201d. Therefore, we have the working table as follows.<\/p>\n<p><strong>Table 11.4<\/strong>: Working Table for a Chi-Square Goodness of Fit Test (Example)<\/p>\n<div style=\"margin: auto;\">\n<table style=\"width: 100%; height: 180px; border-spacing: 0px;\" cellpadding=\"3\">\n<tfoot>\n<tr class=\"shaded\" style=\"height: 30px;\">\n<td style=\"text-align: left; width: 14.1642%; height: 30px; width: 117px;\" valign=\"top\"><\/td>\n<td style=\"width: 17.9262%; height: 30px; text-align: left; width: 99px;\" valign=\"top\">\n<div style=\"margin: auto;\">[latex]\\text{Sum}=1[\/latex]<\/div>\n<\/td>\n<td style=\"width: 18.1367%; height: 30px; text-align: left; width: 94px;\" valign=\"top\">\n<div style=\"margin: auto;\">[latex]\\text{Sum}=37[\/latex]<\/div>\n<\/td>\n<td style=\"width: 24.9501%; height: 30px; text-align: left; width: 151px;\" valign=\"top\">\n<div style=\"margin: auto;\">[latex]\\text{Sum}=37[\/latex]<\/div>\n<\/td>\n<td style=\"width: 24.6454%; height: 30px; text-align: right; width: 189px;\" valign=\"top\">\n<div style=\"margin: auto;\">[latex]\\text{Sum}=\\chi_o^2 = 2.1667[\/latex]<\/div>\n<\/td>\n<\/tr>\n<\/tfoot>\n<thead>\n<tr style=\"height: 30px;\">\n<th class=\"shaded\" style=\"width: 14.1642%; vertical-align: top; height: 30px;\" scope=\"col\">\n<div style=\"margin: auto;\">Parties<\/div>\n<\/th>\n<th class=\"shaded\" style=\"width: 17.9262%; height: 30px;\" scope=\"col\">\n<div style=\"margin: auto;\">Proportion [latex]p[\/latex]<\/div>\n<\/th>\n<th class=\"shaded\" style=\"width: 18.1367%; height: 30px;\" scope=\"col\">\n<div style=\"margin: auto;\">Observed [latex]O[\/latex]<\/div>\n<\/th>\n<th class=\"shaded\" style=\"width: 24.9501%; height: 30px;\" scope=\"col\">\n<div style=\"margin: auto;\">Expected<br \/>\n[latex]E = np = 37 \\times p[\/latex]<\/div>\n<\/th>\n<th class=\"shaded\" style=\"width: 24.6454%; height: 30px; text-align: right;\" scope=\"col\">\n<div style=\"margin: auto;\">[latex]\\frac{(O - E)^2}{E}[\/latex]<\/div>\n<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr style=\"height: 30px;\">\n<td style=\"text-align: left; width: 14.1642%; height: 30px; width: 117px;\" valign=\"top\">\n<div style=\"margin: auto;\">Conservative<\/div>\n<\/td>\n<td style=\"width: 17.9262%; height: 30px; text-align: left; width: 99px;\" valign=\"top\">\n<div style=\"margin: auto;\">[latex]0.319[\/latex]<\/div>\n<\/td>\n<td style=\"width: 18.1367%; height: 30px; text-align: left; width: 94px;\" valign=\"top\">\n<div style=\"margin: auto;\">[latex]9[\/latex]<\/div>\n<\/td>\n<td style=\"width: 24.9501%; height: 30px; text-align: left; width: 151px;\" valign=\"top\">\n<div style=\"margin: auto;\">[latex]37 \\times 0.319=11.803[\/latex]<\/div>\n<\/td>\n<td style=\"width: 24.6454%; height: 30px; text-align: right; width: 189px;\" valign=\"top\">\n<div style=\"margin: auto;\">[latex]\\frac{(9 - 11.803)^2}{11.803} = 0.6657[\/latex]<\/div>\n<\/td>\n<\/tr>\n<tr style=\"height: 30px;\">\n<td style=\"text-align: left; width: 14.1642%; height: 30px; width: 117px;\" valign=\"top\">\n<div>Liberal<\/div>\n<\/td>\n<td style=\"width: 17.9262%; height: 30px; text-align: left; width: 99px;\" valign=\"top\">\n<div style=\"margin: auto;\">[latex]0.395[\/latex]<\/div>\n<\/td>\n<td style=\"width: 18.1367%; height: 30px; text-align: left; width: 94px;\" valign=\"top\">\n<div style=\"margin: auto;\">[latex]17[\/latex]<\/div>\n<\/td>\n<td style=\"width: 24.9501%; height: 30px; text-align: left; width: 151px;\" valign=\"top\">\n<div style=\"margin: auto;\">[latex]37 \\times 0.395=14.615[\/latex]<\/div>\n<\/td>\n<td style=\"width: 24.6454%; height: 30px; text-align: right; width: 189px;\" valign=\"top\">\n<div style=\"margin: auto;\">[latex]\\frac{(17 - 14.615)^2}{14.615} = 0.3892[\/latex]<\/div>\n<\/td>\n<\/tr>\n<tr style=\"height: 30px;\">\n<td style=\"text-align: left; width: 14.1642%; height: 30px; width: 117px;\" valign=\"top\">NDP<\/td>\n<td style=\"width: 17.9262%; height: 30px; text-align: left; width: 99px;\" valign=\"top\">\n<div style=\"margin: auto;\">[latex]0.197[\/latex]<\/div>\n<\/td>\n<td style=\"width: 18.1367%; height: 30px; text-align: left; width: 94px;\" valign=\"top\">\n<div style=\"margin: auto;\">[latex]6[\/latex]<\/div>\n<\/td>\n<td style=\"width: 24.9501%; height: 30px; text-align: left; width: 151px;\" valign=\"top\">\n<div style=\"margin: auto;\">[latex]37 \\times 0.197=7.289[\/latex]<\/div>\n<\/td>\n<td style=\"width: 24.6454%; height: 30px; text-align: right; width: 189px;\" valign=\"top\">\n<div style=\"margin: auto;\">[latex]\\frac{(6 - 7.289)^2}{7.289} = 0.2279[\/latex]<\/div>\n<\/td>\n<\/tr>\n<tr style=\"height: 30px;\">\n<td style=\"text-align: left; width: 14.1642%; height: 30px; width: 117px;\" valign=\"top\">\n<div>Others<\/div>\n<\/td>\n<td style=\"width: 17.9262%; height: 30px; text-align: left; width: 99px;\" valign=\"top\">\n<div style=\"margin: auto;\"><strong>[latex]0.089[\/latex]<\/strong><\/div>\n<\/td>\n<td style=\"width: 18.1367%; height: 30px; text-align: left; width: 94px;\" valign=\"top\">\n<div style=\"margin: auto;\">[latex]2+3+0=5[\/latex]<\/div>\n<\/td>\n<td style=\"width: 24.9501%; height: 30px; text-align: left; width: 151px;\" valign=\"top\">\n<div style=\"margin: auto;\">[latex]37 \\times 0.089=3.293[\/latex]<\/div>\n<\/td>\n<td style=\"width: 24.6454%; height: 30px; text-align: right; width: 189px;\" valign=\"top\">\n<div style=\"margin: auto;\">[latex]\\frac{(5 - 3.293)^2}{3.293} = 0.8849[\/latex]<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Note: After combining the cells, all the expected counts are greater than 1, while 25% of the expected counts are below 5 (the expected count for Others is below 5). Since more than 20% of the expected counts are below 5, there is still a violation in the assumptions. However, the expected frequency for &#8220;Others&#8221; is 3.293 which is not very far away from 5. To maintain a meaningful number of parties, we proceed to conduct the chi-square goodness-of-fit test.<\/p>\n<p><strong>Steps <\/strong><strong>to perform a <\/strong><strong>chi-square goodness-of-fit test<\/strong>:<\/p>\n<ol>\n<li>Set up the hypotheses: [latex]\\begin{align*}  H_0 & : p_{\\scriptsize C} = 0.319, p_{\\scriptsize L} = 0.395, p_{\\scriptsize NDP} = 0.197, p_{\\scriptsize Others} = 0.089 \\\\ H_a & : \\text{At least one proportion is different from those specified in } H_0. \\end{align*}[\/latex]<\/li>\n<li>The significance level is [latex]\\alpha = 0.05[\/latex].<\/li>\n<li>The test statistic: [latex]\\chi_o^2 = \\sum_{\\text{all cells}} \\frac{(O- E)^2}{E} = 2.1677[\/latex], with [latex]df = k -1 = 4 - 1 =3[\/latex].<\/li>\n<li>Find the P-value. Since chi-square tests are always right-tailed, the p-value is<br \/>\nP-value [latex]= P(\\chi^2 \\geq \\chi_o^2) = P(\\chi^2 \\geq 2.1677) \\: \\gt \\: 0.1[\/latex].<\/li>\n<li>Decision: We do not reject the null [latex]H_0[\/latex], since P-value [latex]\\: \\gt \\: 0.1 \\: \\gt \\: 0.05(\\alpha)[\/latex].<\/li>\n<li>Conclusion: At the 5% significance level, we do not have sufficient evidence that the class had different voting preferences than all Canadians in the 2015 election.<\/li>\n<\/ol>\n<p><strong>If using the critical value approach, steps 4\u20136 are as follows<\/strong>:<\/p>\n<ol start=\"4\">\n<li>Find the rejection region. For a right-tailed test with [latex]df=3[\/latex], the rejection region is to the right of the critical value [latex]\\chi^2 \\geq \\chi_{\\alpha}^2 = \\chi_{0.05}^2 = 7.815[\/latex].<\/li>\n<li><span style=\"font-size: 1em;\">Decision: We do not reject the null [latex]H_0[\/latex] since [latex]\\chi_o^2 = 2.1667 < 7.815[\/latex] falls in the non-rejection region.<\/span><\/li>\n<li>Conclusion: At the 5% significance level, we do not have sufficient evidence that the class had different voting preferences than all Canadians in the 2015 election.<\/li>\n<\/ol>\n<\/div>\n<\/div>\n<div style=\"height: 55px; margin-top: 5px;\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-99 alignleft\" src=\"https:\/\/openbooks.macewan.ca\/rcommander\/wp-content\/uploads\/sites\/8\/2020\/06\/activity.png\" alt=\"\" width=\"250\" height=\"50\" srcset=\"https:\/\/openbooks.macewan.ca\/introstats\/wp-content\/uploads\/sites\/8\/2020\/06\/activity.png 250w, https:\/\/openbooks.macewan.ca\/introstats\/wp-content\/uploads\/sites\/8\/2020\/06\/activity-65x13.png 65w, https:\/\/openbooks.macewan.ca\/introstats\/wp-content\/uploads\/sites\/8\/2020\/06\/activity-225x45.png 225w\" sizes=\"auto, (max-width: 250px) 100vw, 250px\" \/><\/div>\n<div class=\"textbox textbox--exercises\">\n<header class=\"textbox__header\">\n<p class=\"textbox__title\">Exercise: Chi-square goodness-of-fit test<\/p>\n<\/header>\n<div class=\"textbox__content\">\n<p>A company claims their deluxe mixed nuts consist of 20% peanuts, 60% cashews, and 20% almonds. An inspector obtains a random sample of [latex]n = 100[\/latex] nuts and observes 30 peanuts, 55 cashews, and 15 almonds. Test at the 5% significance level whether the percentages differ from what the company claims.<\/p>\n<details>\n<summary>Show\/Hide Answer<\/summary>\n<p><strong>Answers:<\/strong><\/p>\n<p><strong>Check the assumptions<\/strong>: [latex]n = 100[\/latex]\u00a0and the expected counts are<br \/>\n[latex]E_{\\text{peanut}} = 100 \\times 0.2 = 20, E_{\\text{cashew}} = 100 \\times 0.6 = 60,[\/latex] [latex]E_{\\text{almond}} = 100 \\times 0.2 = 20[\/latex] and all greater than 5.<\/p>\n<p><strong>Steps to perform a chi-square goodness-of-fit test<\/strong>:<\/p>\n<ol>\n<li>Set up the hypotheses:<br \/>\n[latex]\\begin{align*} H_0 &: p_{\\text{peanut}} = 0.2, p_{\\text{cashew}} = 0.6, p_{\\text{almond}} = 0.2 \u00a0\\\\ H_a &: \\text{at least one proportion is different from those specified in } H_0. \\end{align*}[\/latex]<\/li>\n<li>The significance level is [latex]\\alpha = 0.05[\/latex].<\/li>\n<li>The test statistic with the working table:\n<div style=\"margin: auto;\">\n<p style=\"text-align: center;\"><strong>Table 11.5<\/strong>: Working Table for Chi-Square Goodness-of-Fit Test (Exercise)<\/p>\n<table style=\"width: 100%; height: 176px; border-spacing: 0px;\" cellpadding=\"0\">\n<tfoot>\n<tr class=\"shaded\" style=\"height: 30px;\">\n<td style=\"height: 30px; width: 15.96153846153846%; width: 88px;\" valign=\"top\">\n<div style=\"margin: auto;\"><strong>\u00a0<\/strong><\/div>\n<\/td>\n<td style=\"height: 30px; text-align: center; width: 19.423076923076923%; width: 103px;\" valign=\"top\">\n<div style=\"margin: auto;\">[latex]\\text{Sum}=1[\/latex]<\/div>\n<\/td>\n<td style=\"height: 30px; text-align: center; width: 18.269230769230766%; width: 100px;\" valign=\"top\">\n<div style=\"margin: auto;\">[latex]\\text{Sum}=100[\/latex]<\/div>\n<\/td>\n<td style=\"height: 30px; text-align: center; width: 21.346153846153847%; width: 141px;\" valign=\"top\">\n<div style=\"margin: auto;\">[latex]\\text{Sum}=100[\/latex]<\/div>\n<\/td>\n<td style=\"height: 30px; text-align: center; width: 25%; width: 188px;\" valign=\"top\">\n<div style=\"margin: auto;\">[latex]\\text{Sum}= \\chi_o^2 = 6.667[\/latex]<\/div>\n<\/td>\n<\/tr>\n<\/tfoot>\n<thead>\n<tr class=\"shaded\" style=\"height: 58px;\">\n<th style=\"text-align: left; height: 11px; vertical-align: top; width: 15.96153846153846%; width: 88px;\" scope=\"col\" valign=\"top\"><strong>Nuts<\/strong><\/th>\n<th style=\"text-align: center; height: 11px; vertical-align: top; width: 19.423076923076923%; width: 103px;\" scope=\"col\" valign=\"top\"><strong>Proportion<\/strong><br \/>\n<strong>p<\/strong><\/th>\n<th style=\"text-align: center; height: 11px; vertical-align: top; width: 18.269230769230766%; width: 100px;\" scope=\"col\" valign=\"top\"><strong>Observed <\/strong><br \/>\n<strong><em>(O)<\/em><\/strong><\/th>\n<th style=\"text-align: center; height: 11px; vertical-align: top; width: 21.346153846153847%; width: 141px;\" scope=\"col\" valign=\"top\"><strong>Expected<\/strong><br \/>\n[latex]E = np = 100 \\times p[\/latex]<\/th>\n<th style=\"text-align: center; height: 11px; vertical-align: top; width: 25%; width: 188px;\" scope=\"col\" valign=\"top\">[latex]\\frac{(O-E)^2}{E}[\/latex]<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr style=\"height: 45px;\">\n<td style=\"height: 45px; text-align: left; width: 15.96153846153846%; width: 88px;\" valign=\"top\">\n<div style=\"margin: auto;\">Peanut<\/div>\n<\/td>\n<td style=\"height: 45px; text-align: center; width: 19.423076923076923%; width: 103px;\" valign=\"top\">\n<div style=\"margin: auto;\">[latex]0.2[\/latex]<\/div>\n<\/td>\n<td style=\"height: 45px; text-align: center; width: 18.269230769230766%; width: 100px;\" valign=\"top\">\n<div style=\"margin: auto;\">[latex]30[\/latex]<\/div>\n<\/td>\n<td style=\"height: 45px; text-align: center; width: 21.346153846153847%; width: 141px;\" valign=\"top\">\n<div style=\"margin: auto;\">[latex]100 \\times 0.2 = 20[\/latex]<\/div>\n<\/td>\n<td style=\"height: 45px; text-align: center; width: 25%; width: 188px;\" valign=\"top\">\n<div style=\"margin: auto;\">[latex]\\frac{(30 - 20)^2}{20} = 5.000[\/latex]<\/div>\n<\/td>\n<\/tr>\n<tr style=\"height: 45px;\">\n<td style=\"height: 45px; text-align: left; width: 15.96153846153846%; width: 88px;\" valign=\"top\">\n<div style=\"margin: auto;\">Cashew<\/div>\n<\/td>\n<td style=\"height: 45px; text-align: center; width: 19.423076923076923%; width: 103px;\" valign=\"top\">\n<div style=\"margin: auto;\">[latex]0.6[\/latex]<\/div>\n<\/td>\n<td style=\"height: 45px; text-align: center; width: 18.269230769230766%; width: 100px;\" valign=\"top\">\n<div style=\"margin: auto;\">[latex]55[\/latex]<\/div>\n<\/td>\n<td style=\"height: 45px; text-align: center; width: 21.346153846153847%; width: 141px;\" valign=\"top\">\n<div style=\"margin: auto;\">[latex]100 \\times 0.6 = 60[\/latex]<\/div>\n<\/td>\n<td style=\"height: 45px; text-align: center; width: 25%; width: 188px;\" valign=\"top\">\n<div style=\"margin: auto;\">[latex]\\frac{(55 - 60)^2}{60} = 0.417[\/latex]<\/div>\n<\/td>\n<\/tr>\n<tr style=\"height: 45px;\">\n<td style=\"height: 45px; text-align: left; width: 15.96153846153846%; width: 88px;\" valign=\"top\">\n<div style=\"margin: auto;\">Almond<\/div>\n<\/td>\n<td style=\"height: 45px; text-align: center; width: 19.423076923076923%; width: 103px;\" valign=\"top\">\n<div style=\"margin: auto;\">[latex]0.2[\/latex]<\/div>\n<\/td>\n<td style=\"height: 45px; text-align: center; width: 18.269230769230766%; width: 100px;\" valign=\"top\">\n<div style=\"margin: auto;\">[latex]15[\/latex]<\/div>\n<\/td>\n<td style=\"height: 45px; text-align: center; width: 21.346153846153847%; width: 141px;\" valign=\"top\">\n<div style=\"margin: auto;\">[latex]100 \\times 0.2 = 20[\/latex]<\/div>\n<\/td>\n<td style=\"height: 45px; text-align: center; width: 25%; width: 188px;\" valign=\"top\">\n<div style=\"margin: auto;\">[latex]\\frac{(15 - 20)^2}{20} = 1.250[\/latex]<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>[latex]\\chi_o^2 = \\sum_{\\text{all cells}} \\frac{(O - E)^2}{E} = 6.667[\/latex] with [latex]df = k - 1 = 3-1 =2[\/latex].<\/li>\n<li>Find the P-value: P-value [latex]P(\\chi^2 \\geq \\chi_o^2) = P(\\chi^2 \\geq 6.667)[\/latex].<br \/>\nSince [latex]5.991 (\\chi_{0.05}^2) < \\chi_o^2=6.667 < 7.378 (\\chi_{0.025}^2)[\/latex], 0.025 &lt; P-value &lt; 0.05.<\/li>\n<li>Decision: We should reject the null [latex]H_0[\/latex] since P-value &lt;0.05([latex]\\alpha[\/latex]).<\/li>\n<li>Conclusion: At the 5% significance level, we have sufficient evidence that the percentages of nuts are different from what the company claims.<\/li>\n<\/ol>\n<\/details>\n<\/div>\n<\/div>\n","protected":false},"author":19,"menu_order":3,"template":"","meta":{"pb_show_title":"on","pb_short_title":"","pb_subtitle":"","pb_authors":[],"pb_section_license":""},"chapter-type":[],"contributor":[],"license":[],"class_list":["post-1163","chapter","type-chapter","status-publish","hentry"],"part":1148,"_links":{"self":[{"href":"https:\/\/openbooks.macewan.ca\/introstats\/wp-json\/pressbooks\/v2\/chapters\/1163","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/openbooks.macewan.ca\/introstats\/wp-json\/pressbooks\/v2\/chapters"}],"about":[{"href":"https:\/\/openbooks.macewan.ca\/introstats\/wp-json\/wp\/v2\/types\/chapter"}],"author":[{"embeddable":true,"href":"https:\/\/openbooks.macewan.ca\/introstats\/wp-json\/wp\/v2\/users\/19"}],"version-history":[{"count":41,"href":"https:\/\/openbooks.macewan.ca\/introstats\/wp-json\/pressbooks\/v2\/chapters\/1163\/revisions"}],"predecessor-version":[{"id":5522,"href":"https:\/\/openbooks.macewan.ca\/introstats\/wp-json\/pressbooks\/v2\/chapters\/1163\/revisions\/5522"}],"part":[{"href":"https:\/\/openbooks.macewan.ca\/introstats\/wp-json\/pressbooks\/v2\/parts\/1148"}],"metadata":[{"href":"https:\/\/openbooks.macewan.ca\/introstats\/wp-json\/pressbooks\/v2\/chapters\/1163\/metadata\/"}],"wp:attachment":[{"href":"https:\/\/openbooks.macewan.ca\/introstats\/wp-json\/wp\/v2\/media?parent=1163"}],"wp:term":[{"taxonomy":"chapter-type","embeddable":true,"href":"https:\/\/openbooks.macewan.ca\/introstats\/wp-json\/pressbooks\/v2\/chapter-type?post=1163"},{"taxonomy":"contributor","embeddable":true,"href":"https:\/\/openbooks.macewan.ca\/introstats\/wp-json\/wp\/v2\/contributor?post=1163"},{"taxonomy":"license","embeddable":true,"href":"https:\/\/openbooks.macewan.ca\/introstats\/wp-json\/wp\/v2\/license?post=1163"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}