{"id":2679,"date":"2024-07-24T10:12:07","date_gmt":"2024-07-24T14:12:07","guid":{"rendered":"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/?post_type=part&#038;p=2679"},"modified":"2024-07-27T01:53:07","modified_gmt":"2024-07-27T05:53:07","slug":"chi-squared-test-of-independence","status":"publish","type":"part","link":"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/part\/chi-squared-test-of-independence\/","title":{"raw":"Chi-Squared Test of Independence","rendered":"Chi-Squared Test of Independence"},"content":{"raw":"This chapter will present the [latex]\\chi^2[\/latex] (Chi-Square) test for independence.\r\n<h2>When do we use the test?<\/h2>\r\nIt is useful to:\r\n<ul>\r\n \t<li>determine if there is a difference between 2 or more population proportions<\/li>\r\n \t<li>determine if two or more categorical variables are dependent on each other \u03c7<\/li>\r\n<\/ul>\r\nIf two variables are dependent, the probability of one variable having a certain value (or belonging to a certain category) is dependent on the other variable having a certain value (or belonging to a certain category).\r\n<h2>Comparing \u03c7<sup>2<\/sup>\u00a0to the Difference in Two Proportions Test<\/h2>\r\n<ul>\r\n \t<li>In the test for the difference in proportions, we test if there is a difference in two population proportions for two different groups\/samples<\/li>\r\n \t<li>In the Chi-Squared (\u03c7<sup>2<\/sup>) test, we are testing if there is a relationship two populations and their characteristics.<\/li>\r\n \t<li>In the test for the difference in proportions, we can possibly know if one population proportion is higher, lower or not equal to the other one.<\/li>\r\n \t<li>In the Chi-Squared (\u03c7<sup>2<\/sup>) test, if there is a relationship between populations and characteristics (there is a dependence), we can't know the nature of the relationship.<\/li>\r\n \t<li>In the test for the difference in proportions, we only test the proportion in each population with one characteristic (and determine if it is different between populations)<\/li>\r\n \t<li>In the Chi-Squared (\u03c7<sup>2<\/sup>) test, there can be more than two categories\/characteristics in each group and we test if there is some relationship between at least one characteristic and the populations.<\/li>\r\n<\/ul>\r\n<h2>What is \u03c7<sup>2<\/sup> (Chi-Squared)?<\/h2>\r\nLike in previous sections, we will be using a certain continuous distribution, called the \u03c7<sup>2<\/sup> (Chi-Squared) distribution to compute probabilities. In our case, the probability will be associated with the probability of getting the sample result we did when there is no dependence between the categorical variables in question.\r\n\r\n[caption id=\"attachment_2680\" align=\"aligncenter\" width=\"654\"]<a href=\"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/ChiSquared_CDF.jpg\"><img class=\" wp-image-2680\" src=\"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/ChiSquared_CDF.jpg\" alt=\"Image of cumulative density curves for 2, 3 and 4 degrees of freedom. The curves sharply increase then taper off. The lower the number of degrees of freedom, the steeper the curve initially.\" width=\"654\" height=\"401\" \/><\/a> Figure X.1 Chi-Squared Cumulative Density Functions (CDFs)[\/caption]\r\n\r\nThe cumulative density functions for the \u03c7<sup>2<\/sup> distribution are shown above for several degrees of freedom (\u03bd). We will review degrees of freedom for this distribution in the next section.\r\n<h2>Parameters of Chi-Squared Distribution<\/h2>\r\nLike other distributions, we can define certain parameters for the \u03c7<sup>2<\/sup> distribution:\r\n<ul>\r\n \t<li>[latex]\\nu[\/latex] = degrees of freedom (to be defined in the next section)<\/li>\r\n \t<li>Mean = [latex]\\nu[\/latex]<\/li>\r\n \t<li>Mode = [latex]\\nu[\/latex] (only when \u03bd &lt; 2)<\/li>\r\n \t<li>Standard deviation =[latex]\\sqrt{2\\nu}[\/latex]<\/li>\r\n \t<li>Variance = [latex]2\\nu[\/latex]<\/li>\r\n \t<li>Skewness =\u00a0[latex]2\\sqrt{\\frac{2}{\\nu}}[\/latex]<\/li>\r\n<\/ul>","rendered":"<p>This chapter will present the [latex]\\chi^2[\/latex] (Chi-Square) test for independence.<\/p>\n<h2>When do we use the test?<\/h2>\n<p>It is useful to:<\/p>\n<ul>\n<li>determine if there is a difference between 2 or more population proportions<\/li>\n<li>determine if two or more categorical variables are dependent on each other \u03c7<\/li>\n<\/ul>\n<p>If two variables are dependent, the probability of one variable having a certain value (or belonging to a certain category) is dependent on the other variable having a certain value (or belonging to a certain category).<\/p>\n<h2>Comparing \u03c7<sup>2<\/sup>\u00a0to the Difference in Two Proportions Test<\/h2>\n<ul>\n<li>In the test for the difference in proportions, we test if there is a difference in two population proportions for two different groups\/samples<\/li>\n<li>In the Chi-Squared (\u03c7<sup>2<\/sup>) test, we are testing if there is a relationship two populations and their characteristics.<\/li>\n<li>In the test for the difference in proportions, we can possibly know if one population proportion is higher, lower or not equal to the other one.<\/li>\n<li>In the Chi-Squared (\u03c7<sup>2<\/sup>) test, if there is a relationship between populations and characteristics (there is a dependence), we can&#8217;t know the nature of the relationship.<\/li>\n<li>In the test for the difference in proportions, we only test the proportion in each population with one characteristic (and determine if it is different between populations)<\/li>\n<li>In the Chi-Squared (\u03c7<sup>2<\/sup>) test, there can be more than two categories\/characteristics in each group and we test if there is some relationship between at least one characteristic and the populations.<\/li>\n<\/ul>\n<h2>What is \u03c7<sup>2<\/sup> (Chi-Squared)?<\/h2>\n<p>Like in previous sections, we will be using a certain continuous distribution, called the \u03c7<sup>2<\/sup> (Chi-Squared) distribution to compute probabilities. In our case, the probability will be associated with the probability of getting the sample result we did when there is no dependence between the categorical variables in question.<\/p>\n<figure id=\"attachment_2680\" aria-describedby=\"caption-attachment-2680\" style=\"width: 654px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/ChiSquared_CDF.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-2680\" src=\"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/ChiSquared_CDF.jpg\" alt=\"Image of cumulative density curves for 2, 3 and 4 degrees of freedom. The curves sharply increase then taper off. The lower the number of degrees of freedom, the steeper the curve initially.\" width=\"654\" height=\"401\" srcset=\"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/ChiSquared_CDF.jpg 767w, https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/ChiSquared_CDF-300x184.jpg 300w, https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/ChiSquared_CDF-65x40.jpg 65w, https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/ChiSquared_CDF-225x138.jpg 225w, https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/ChiSquared_CDF-350x214.jpg 350w\" sizes=\"auto, (max-width: 654px) 100vw, 654px\" \/><\/a><figcaption id=\"caption-attachment-2680\" class=\"wp-caption-text\">Figure X.1 Chi-Squared Cumulative Density Functions (CDFs)<\/figcaption><\/figure>\n<p>The cumulative density functions for the \u03c7<sup>2<\/sup> distribution are shown above for several degrees of freedom (\u03bd). We will review degrees of freedom for this distribution in the next section.<\/p>\n<h2>Parameters of Chi-Squared Distribution<\/h2>\n<p>Like other distributions, we can define certain parameters for the \u03c7<sup>2<\/sup> distribution:<\/p>\n<ul>\n<li>[latex]\\nu[\/latex] = degrees of freedom (to be defined in the next section)<\/li>\n<li>Mean = [latex]\\nu[\/latex]<\/li>\n<li>Mode = [latex]\\nu[\/latex] (only when \u03bd &lt; 2)<\/li>\n<li>Standard deviation =[latex]\\sqrt{2\\nu}[\/latex]<\/li>\n<li>Variance = [latex]2\\nu[\/latex]<\/li>\n<li>Skewness =\u00a0[latex]2\\sqrt{\\frac{2}{\\nu}}[\/latex]<\/li>\n<\/ul>\n","protected":false},"parent":0,"menu_order":15,"template":"","meta":{"pb_part_invisible":false,"pb_part_invisible_string":""},"contributor":[],"license":[],"class_list":["post-2679","part","type-part","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-json\/pressbooks\/v2\/parts\/2679","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-json\/pressbooks\/v2\/parts"}],"about":[{"href":"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-json\/wp\/v2\/types\/part"}],"version-history":[{"count":6,"href":"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-json\/pressbooks\/v2\/parts\/2679\/revisions"}],"predecessor-version":[{"id":2971,"href":"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-json\/pressbooks\/v2\/parts\/2679\/revisions\/2971"}],"wp:attachment":[{"href":"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-json\/wp\/v2\/media?parent=2679"}],"wp:term":[{"taxonomy":"contributor","embeddable":true,"href":"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-json\/wp\/v2\/contributor?post=2679"},{"taxonomy":"license","embeddable":true,"href":"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-json\/wp\/v2\/license?post=2679"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}