{"id":2706,"date":"2024-07-24T12:11:19","date_gmt":"2024-07-24T16:11:19","guid":{"rendered":"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/?post_type=chapter&#038;p=2706"},"modified":"2024-07-25T23:28:32","modified_gmt":"2024-07-26T03:28:32","slug":"examples-of-testing-for-differences-in-proportions","status":"publish","type":"chapter","link":"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/chapter\/examples-of-testing-for-differences-in-proportions\/","title":{"raw":"Testing for Differences Examples","rendered":"Testing for Differences Examples"},"content":{"raw":"<div class=\"textbox textbox--learning-objectives\"><header class=\"textbox__header\">\r\n<p class=\"textbox__title\">Learning Objectives<\/p>\r\n\r\n<\/header>\r\n<div class=\"textbox__content\">Perform left, right and two-tailed hypothesis tests for differences in proportions.<\/div>\r\n<\/div>\r\nIn this section, we will:\r\n<ul>\r\n \t<li>perform left and two-tailed hypothesis tests for differences in proportions<\/li>\r\n \t<li>compare this test to the test in the previous chapter (see the Right-Tailed Test section below)<\/li>\r\n \t<li>recap the important formulas given in the previous section<\/li>\r\n<\/ul>\r\n<h2>Hypotheses<\/h2>\r\nH<sub>0<\/sub>: [latex]p_1 = p_2[\/latex], or [latex]p_1 - p_2 = 0[\/latex]\r\n\r\nH<sub>A<\/sub>: [latex]p_1 - p_2 &lt; 0[\/latex] (left-tailed),\u00a0 [latex]p_1 - p_2 &gt; 0[\/latex] (right-tailed),\u00a0 [latex]p_1 - p_2 \\neq 0[\/latex] (two-tailed)\r\n<h2>Test Statistic<\/h2>\r\nThe test statistic formula is the same, regardless of what tailed test we are performing:\r\n\r\n\\[z_{test} = \\frac{\\bar{p_1}-\\bar{p_2}}{\\sqrt{\\bar{p}(1-\\bar{p})\\left(\\frac{1}{n_1}+\\frac{1}{n_2}\\right)}}\\]\r\n<h2>P-Values<\/h2>\r\nUse Excel's <a href=\"https:\/\/support.microsoft.com\/en-us\/office\/norm-s-dist-function-1e787282-3832-4520-a9ae-bd2a8d99ba88\">NORM.S.DIST<\/a>() function to calculate all p-values (see the <a href=\"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/chapter\/steps-for-testing-for-differences-in-proportions\/\">previous section<\/a> for all the formulas).\r\n<h1>left-tailed Test (VIDEO)<\/h1>\r\nLet us start by revisiting the click-through rate (CTR) \u00a0<a href=\"https:\/\/supersede.media\/blog\/topic\/pay-per-click\/search-network-vs-display-network\">Google Ads Search Network<\/a> campaign example.\r\n\r\n[caption id=\"attachment_2622\" align=\"aligncenter\" width=\"434\"]<a href=\"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/GoogleAds-scaled-e1720810262343.jpg\"><img class=\"wp-image-2622\" src=\"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/GoogleAds-scaled-e1720810262343.jpg\" alt=\"Photo of Google's search page and &quot;Pexels' is typed in the search bar. Suggested searches show up below the typed word.\" width=\"434\" height=\"398\" \/><\/a> Figure 61.1 Google search suggestions in search dropdown menu[\/caption]\r\n\r\nIn the example, we will examine the following:\r\n<ul>\r\n \t<li>The differences between the test in this section and the <a href=\"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/chapter\/hypothesis-testing-for-proportions-examples\/\">one proportion hypothesis test<\/a> in the previous chapter.<\/li>\r\n \t<li>How this problem can be performed as both a right and left-tailed hypothesis test.<\/li>\r\n<\/ul>\r\n<h2>Example 61.1<\/h2>\r\n<strong><span style=\"color: #003366\">Problem Setup<\/span><\/strong>: You and your marketing team are running an ad on Google Ad\u2019s Search Network. You examine the Click-Through Rate before and enabling the Google\u2019s search partners feature. Before enabling this feature, you had recorded 56 clicks on 2,946 impressions. After enabling this feature, you recorded 77 clicks-through on 3,054 impressions.\r\n\r\n<strong><span style=\"color: #003366\">Questions<\/span><\/strong>: Is there sufficient evidence, at the 5% level of significance, that the click-through rate is higher when your ad can also be seen via Google's search partners?\r\n\r\nhttps:\/\/youtu.be\/3_DMjb0v1MU\r\n\r\n<span style=\"color: #003366\"><strong>Solutions<\/strong><\/span>: <a href=\"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/Example61-1_Solutions.xlsx\">Click here<\/a>\u00a0to download the Excel solutions and click on the sections below to reveal the written solutions to each part of the above exercise.\r\n<div>\r\n<h1>Assumptions<\/h1>\r\n<ul>\r\n \t<li>The sample size is large enough to ensure that [latex]np&gt;5[\/latex] and [latex]n(1-p)&gt;5[\/latex].<\/li>\r\n \t<li>The other conditions for before and after the feature is turned on are similar<\/li>\r\n \t<li>The are data from the samples before and after are independent of one another<\/li>\r\n \t<li>The samples are random, representative and non-bias.<\/li>\r\n<\/ul>\r\n<h1>Hypotheses<\/h1>\r\n<ul>\r\n \t<li>H<sub>0<\/sub>: p<sub>1<\/sub>\u2212 p<sub>2<\/sub> = 0<\/li>\r\n \t<li>H<sub>A<\/sub>: p<sub>1<\/sub>\u2212 p<sub>2<\/sub> &lt; 0<\/li>\r\n<\/ul>\r\n<h1>Rejection Region<\/h1>\r\nTo determine which tail we are working with (left or right), we need to think about what we are looking to prove: the click-through with the feature enabled (p<sub>2<\/sub>) is higher than the click-through rate without the feature enabled (p<sub>1<\/sub>). This gives the following:\r\n<ul>\r\n \t<li>Click-through with feature (p<sub>2<\/sub>) is higher than the rate without the feature (p<sub>1<\/sub>)<\/li>\r\n \t<li>This gives: p<sub>2<\/sub> &gt; p<sub>1<\/sub><\/li>\r\n \t<li>Moving p<sub>2<\/sub> to the right side gives: 0 &gt; p<sub>1<\/sub>\u2212 p<sub>2<\/sub><\/li>\r\n \t<li>Flipping the inequality (read it right to left) gives: p<sub>1<\/sub>\u2212p<sub>2<\/sub> &lt; 0<\/li>\r\n \t<li>If we want to prove that p<sub>1<\/sub>\u2212p<sub>2<\/sub> &lt; 0, we are performing a left-tailed test.<\/li>\r\n<\/ul>\r\n<h1>Type of Test<\/h1>\r\nThis is a left-tailed test. If p<sub>1<\/sub> is much lower than p<sub>2<\/sub>, then their difference will be negative and the test statistic (z<sub>test<\/sub>) will be low enough to be in the rejection region on the far left of the graph:\r\n\r\n[caption id=\"attachment_2768\" align=\"aligncenter\" width=\"592\"]<a href=\"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/Lower5_w_Zcrit_and_Ztests.jpg\"><img class=\"size-full wp-image-2768\" src=\"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/Lower5_w_Zcrit_and_Ztests.jpg\" alt=\"Bell shaped curve with lowest 5% highlighted. At the start of that region is written z critical. Two red lines are indicated, one on either side of z critical. Beside both lines is marked z test ?\" width=\"592\" height=\"278\" \/><\/a> Figure 61.2 Will the test statistic (z<sub>test<\/sub>) land in the rejection region?[\/caption]\r\n<h1>Test Statistic<\/h1>\r\nFirst, let us calculate the sample proportions:\r\n<ul>\r\n \t<li>[latex]x_1 = 56 [\/latex] and [latex]n_1 = 2946 [\/latex] gives [latex]\\bar{p_1} = \\frac{56}{2946}= 0.0190 [\/latex]<\/li>\r\n \t<li>[latex]x_2 = 77 [\/latex] and [latex]n_2 = 3054 [\/latex] gives [latex]\\bar{p_2} = \\frac{77}{3054}= 0.0252 [\/latex]<\/li>\r\n \t<li>[latex]\\bar{p} = \\frac{x_1+x_2}{n_1+n_2} = \\frac{56+77}{2946+3054} = 0.02217 [\/latex]<\/li>\r\n<\/ul>\r\nWe can now calculate the test statistic:\r\n\r\n[latex] z_{test} = \\frac{\\bar{p_1}-\\bar{p_2}}{\\sqrt{\\bar{p}(1-\\bar{p})\\left(\\frac{1}{n_1}+\\frac{1}{n_2}\\right)}} = \\frac{0.0191-0.0252}{\\sqrt{0.02217(1-0.02217)\\left(\\frac{1}{2946}+\\frac{1}{3054}\\right)}} = -1.6318 [\/latex]\r\n<h1>P-value<\/h1>\r\nWe are performing a left-tailed and use Excel's <a href=\"https:\/\/support.microsoft.com\/en-us\/office\/norm-s-dist-function-1e787282-3832-4520-a9ae-bd2a8d99ba88\">NORM.S.DIST<\/a>\u00a0function:\r\n\r\n[latex] p\\text{-value}=\\text{NORM.S.DIST}(-1.6318, 1) = 0.0514 [\/latex]\r\n<h1>Decision<\/h1>\r\nBecause the p-value = 0.0514 (5.14%) is greater than (&gt;) the level of significance of 5% (0.05), we fail to reject H<sub>0<\/sub>.\r\n<h1>Conclusion<\/h1>\r\nBecause we failed to reject H<sub>0<\/sub>, there is not sufficient evidence to conclude that the click-through rate is higher when the feature is turned on than when it's turned off.\r\n\r\n<\/div>\r\n<h1>RIGHT-tailed Test (Exercise)<\/h1>\r\nWhat if, instead, we wanted to define the test as a right-tailed test. What would be different? Complete the exercise in the example below to determine the difference. In addition, let us reflect on how this example is different than the one sample proportion test from the previous chapter.\r\n<h2>Example 61.2<\/h2>\r\n<span style=\"color: #003366\"><strong>Problem Setup:<\/strong><\/span> Let us redo the problem in Example 61.1 but solve it using a right-tailed hypothesis test.\r\n\r\n<strong><span style=\"color: #003366\">You Try<\/span><\/strong>: Answer the questions in the exercise below to solve this problem:\r\n<div class=\"textbox textbox--exercises\">\r\n<div class=\"textbox__content\">\r\n\r\n[h5p id=\"185\"]\r\n\r\n<\/div>\r\n<\/div>\r\n<span style=\"color: #003366\"><strong>Solutions<\/strong><\/span>: <a href=\"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/Example61-2_Solutions.xlsx\">Click here<\/a> to download the Excel solutions or click the sections below to reveal their solutions.\r\n<div>\r\n<h1>How One-Sample and Two-Sample Tests Are Different<\/h1>\r\nIn differences between Two Proportions testing (this example):\r\n<ul>\r\n \t<li>We are testing if the two populations are different (before and after the feature is enabled).<\/li>\r\n \t<li>We are assuming that we don't know the 'true' proportion but have two different sample proportions (with and without the feature enabled) recorded.<\/li>\r\n \t<li>We use both sample proportions to come up with a 'best guess' for the population proportion, which we call the pooled sample proportion (p\u0304).<\/li>\r\n<\/ul>\r\nIn One-Sample Proportion Hypothesis Testing (Example 58.1):\r\n<ul>\r\n \t<li>We are testing the true proportion (the click-through rate) has changed from its historical value (the rate before the feature was enabled)<\/li>\r\n \t<li>We treat the historical value as our population proportion<\/li>\r\n \t<li>We compare to this amount to see if there is any difference<\/li>\r\n<\/ul>\r\n<h1>Setting Up the Problem as Right-Tailed<\/h1>\r\nWe want to prove that the rate after the feature is enabled is higher than without the feature being enabled. If we set the following to be true:\r\n<ul>\r\n \t<li>p<sub>1<\/sub> = the true click-through rate after the feature is enabled<\/li>\r\n \t<li>p<sub>2<\/sub> = the true click-through rate after the feature is enabled<\/li>\r\n<\/ul>\r\nThen, when proving that the click-through rate is higher with the feature enabled, we get:\r\n<ul>\r\n \t<li>H<sub>A<\/sub>: p<sub>1<\/sub> &gt; p<sub>2<\/sub> or H<sub>A<\/sub>: p<sub>1<\/sub> \u2212 p<sub>2<\/sub> &gt; 0<\/li>\r\n \t<li>This is a right-tailed test<\/li>\r\n<\/ul>\r\n<h1>The Null and Alternate Hypotheses<\/h1>\r\nFrom the previous section, we can determine the null and alternate hypotheses:\r\n<ul>\r\n \t<li>H<sub>0<\/sub>: p<sub>1<\/sub> = p<sub>2<\/sub> or H<sub>A<\/sub>: p<sub>1<\/sub> \u2212 p<sub>2<\/sub> = 0<\/li>\r\n \t<li>H<sub>A<\/sub>: p<sub>1<\/sub> &gt; p<sub>2<\/sub> or H<sub>A<\/sub>: p<sub>1<\/sub> \u2212 p<sub>2<\/sub> &gt; 0<\/li>\r\n<\/ul>\r\n<h1>The Test Statistic<\/h1>\r\nLet us first calculate the sample proportions:\r\n<ul>\r\n \t<li>[latex]x_1 = 77 [\/latex],\u00a0[latex]n_1 = 3054 [\/latex],\u00a0[latex]p_1 = \\frac{77}{3054}=0.0252 [\/latex]<\/li>\r\n \t<li>[latex]x_2 = 56 [\/latex], [latex]n_2 = 2946 [\/latex], [latex]p_2 = \\frac{56}{2946}=0.0190 [\/latex]<\/li>\r\n \t<li>[latex]\\bar{p}=\\frac{x_1+x_2}{n_1+n_2}=\\frac{77+56}{3054+2946} = 0.02217[\/latex]<\/li>\r\n<\/ul>\r\nWe can now use those proportions to calculate the test statistic:\r\n\r\n[latex] z_{test} = \\frac{\\bar{p_1}-\\bar{p_2}}{\\sqrt{\\bar{p}(1-\\bar{p})\\left(\\frac{1}{n_1}+\\frac{1}{n_2}\\right)}} = \\frac{0.0252-0.0191}{\\sqrt{0.02217(1-0.02217)\\left(\\frac{1}{3054}+\\frac{1}{2946}\\right)}} = 1.6318 [\/latex]\r\n<h1>P-value<\/h1>\r\nWe are performing a right-tailed and use Excel's <a href=\"https:\/\/support.microsoft.com\/en-us\/office\/norm-s-dist-function-1e787282-3832-4520-a9ae-bd2a8d99ba88\">NORM.S.DIST<\/a>\u00a0function:\r\n\r\n[latex] p\\text{-value}=1-\\text{NORM.S.DIST}(1.6318, 1) = 0.0514 [\/latex]\r\n<h1>Decision<\/h1>\r\nBecause the p-value = 0.0514 (5.14%) is greater than (&gt;) the level of significance of 5% (0.05), we fail to reject H<sub>0<\/sub>.\r\n<h1>Conclusion<\/h1>\r\nBecause we failed to reject H<sub>0<\/sub>, there is not sufficient evidence to conclude that the click-through rate is higher when the feature is turned on than when it's turned off.\r\n\r\n<\/div>\r\n<h1>TWO-tailed Test (Video of Written Solutions)<\/h1>\r\nIn this example, we will perform a two-tailed hypothesis test to test if there is a difference in proportions between two populations. In this case, we will look at sentiment surrounding the <a href=\"https:\/\/www.coastalgaslink.com\/\">LNG<\/a> pipeline in British Columbia.\r\n<h2>Example 61.3<\/h2>\r\n<strong><span style=\"color: #003366\">Problem Setup<\/span><\/strong>: The BC Government is conducting a survey on people's sentiments toward the natural gas pipeline being built.\r\n\r\n[caption id=\"attachment_2786\" align=\"aligncenter\" width=\"575\"]<a href=\"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/alaska-5004758_1280.jpg\"><img class=\" wp-image-2786\" src=\"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/alaska-5004758_1280.jpg\" alt=\"Image of pipeline spanning across winter landscape.\" width=\"575\" height=\"383\" \/><\/a> Figure 61.3 Natural gas pipeline running through countryside[\/caption]\r\n\r\nThey have sampled two different groups - those who voted for the <a href=\"https:\/\/en.wikipedia.org\/wiki\/British_Columbia_New_Democratic_Party\">NDP<\/a> in the previous election and those who voted for the <a href=\"https:\/\/en.wikipedia.org\/wiki\/BC_United\">Liberals<\/a>. They found the following to be true:\r\n<ul>\r\n \t<li>Out of 224 NPD supporters sampled, 98 were in favor of the LNG pipeline.<\/li>\r\n \t<li>Out of 206 Liberal supporters sampled, 115 were in favor of the LNG pipeline.<\/li>\r\n<\/ul>\r\n<span style=\"color: #003366\"><strong>Question<\/strong><\/span>: Is there sufficient evidence to conclude, at the 2% level of significance, that there is a difference in the proportion of people who support the pipeline between the two groups?\r\n\r\n<span style=\"color: #003366\"><strong>Solution<\/strong><\/span>: Click <a href=\"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/Example61-3_Solutions.xlsx\">here to download the Excel<\/a> solutions, or <a href=\"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/Example-61.3_Solution.pdf\">here for the PDF solutions<\/a>. Finally, click below to reveal the solutions.\r\n\r\nhttps:\/\/youtu.be\/g0lJqQqwrlM\r\n<div>\r\n<h1>Click here to reveal the written solutions<\/h1>\r\n<a href=\"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/Example61-3_Written_Solution.jpg\"><img class=\"wp-image-2798 aligncenter\" src=\"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/Example61-3_Written_Solution.jpg\" alt=\"Written solutions stepped through in above video\" width=\"657\" height=\"742\" \/><\/a>\r\n\r\n&nbsp;\r\n\r\n&nbsp;\r\n\r\n<\/div>","rendered":"<div class=\"textbox textbox--learning-objectives\">\n<header class=\"textbox__header\">\n<p class=\"textbox__title\">Learning Objectives<\/p>\n<\/header>\n<div class=\"textbox__content\">Perform left, right and two-tailed hypothesis tests for differences in proportions.<\/div>\n<\/div>\n<p>In this section, we will:<\/p>\n<ul>\n<li>perform left and two-tailed hypothesis tests for differences in proportions<\/li>\n<li>compare this test to the test in the previous chapter (see the Right-Tailed Test section below)<\/li>\n<li>recap the important formulas given in the previous section<\/li>\n<\/ul>\n<h2>Hypotheses<\/h2>\n<p>H<sub>0<\/sub>: [latex]p_1 = p_2[\/latex], or [latex]p_1 - p_2 = 0[\/latex]<\/p>\n<p>H<sub>A<\/sub>: [latex]p_1 - p_2 < 0[\/latex] (left-tailed),\u00a0 [latex]p_1 - p_2 > 0[\/latex] (right-tailed),\u00a0 [latex]p_1 - p_2 \\neq 0[\/latex] (two-tailed)<\/p>\n<h2>Test Statistic<\/h2>\n<p>The test statistic formula is the same, regardless of what tailed test we are performing:<\/p>\n<p>\\[z_{test} = \\frac{\\bar{p_1}-\\bar{p_2}}{\\sqrt{\\bar{p}(1-\\bar{p})\\left(\\frac{1}{n_1}+\\frac{1}{n_2}\\right)}}\\]<\/p>\n<h2>P-Values<\/h2>\n<p>Use Excel&#8217;s <a href=\"https:\/\/support.microsoft.com\/en-us\/office\/norm-s-dist-function-1e787282-3832-4520-a9ae-bd2a8d99ba88\">NORM.S.DIST<\/a>() function to calculate all p-values (see the <a href=\"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/chapter\/steps-for-testing-for-differences-in-proportions\/\">previous section<\/a> for all the formulas).<\/p>\n<h1>left-tailed Test (VIDEO)<\/h1>\n<p>Let us start by revisiting the click-through rate (CTR) \u00a0<a href=\"https:\/\/supersede.media\/blog\/topic\/pay-per-click\/search-network-vs-display-network\">Google Ads Search Network<\/a> campaign example.<\/p>\n<figure id=\"attachment_2622\" aria-describedby=\"caption-attachment-2622\" style=\"width: 434px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/GoogleAds-scaled-e1720810262343.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-2622\" src=\"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/GoogleAds-scaled-e1720810262343.jpg\" alt=\"Photo of Google's search page and &quot;Pexels' is typed in the search bar. Suggested searches show up below the typed word.\" width=\"434\" height=\"398\" srcset=\"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/GoogleAds-scaled-e1720810262343.jpg 1920w, https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/GoogleAds-scaled-e1720810262343-300x275.jpg 300w, https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/GoogleAds-scaled-e1720810262343-1024x940.jpg 1024w, https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/GoogleAds-scaled-e1720810262343-768x705.jpg 768w, https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/GoogleAds-scaled-e1720810262343-1536x1410.jpg 1536w, https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/GoogleAds-scaled-e1720810262343-65x60.jpg 65w, https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/GoogleAds-scaled-e1720810262343-225x206.jpg 225w, https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/GoogleAds-scaled-e1720810262343-350x321.jpg 350w\" sizes=\"auto, (max-width: 434px) 100vw, 434px\" \/><\/a><figcaption id=\"caption-attachment-2622\" class=\"wp-caption-text\">Figure 61.1 Google search suggestions in search dropdown menu<\/figcaption><\/figure>\n<p>In the example, we will examine the following:<\/p>\n<ul>\n<li>The differences between the test in this section and the <a href=\"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/chapter\/hypothesis-testing-for-proportions-examples\/\">one proportion hypothesis test<\/a> in the previous chapter.<\/li>\n<li>How this problem can be performed as both a right and left-tailed hypothesis test.<\/li>\n<\/ul>\n<h2>Example 61.1<\/h2>\n<p><strong><span style=\"color: #003366\">Problem Setup<\/span><\/strong>: You and your marketing team are running an ad on Google Ad\u2019s Search Network. You examine the Click-Through Rate before and enabling the Google\u2019s search partners feature. Before enabling this feature, you had recorded 56 clicks on 2,946 impressions. After enabling this feature, you recorded 77 clicks-through on 3,054 impressions.<\/p>\n<p><strong><span style=\"color: #003366\">Questions<\/span><\/strong>: Is there sufficient evidence, at the 5% level of significance, that the click-through rate is higher when your ad can also be seen via Google&#8217;s search partners?<\/p>\n<p><iframe loading=\"lazy\" id=\"oembed-1\" title=\"Hypothesis test for difference in click-through rates (two proportions)\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/3_DMjb0v1MU?feature=oembed&#38;rel=0\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<p><span style=\"color: #003366\"><strong>Solutions<\/strong><\/span>: <a href=\"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/Example61-1_Solutions.xlsx\">Click here<\/a>\u00a0to download the Excel solutions and click on the sections below to reveal the written solutions to each part of the above exercise.<\/p>\n<div>\n<h1>Assumptions<\/h1>\n<ul>\n<li>The sample size is large enough to ensure that [latex]np>5[\/latex] and [latex]n(1-p)>5[\/latex].<\/li>\n<li>The other conditions for before and after the feature is turned on are similar<\/li>\n<li>The are data from the samples before and after are independent of one another<\/li>\n<li>The samples are random, representative and non-bias.<\/li>\n<\/ul>\n<h1>Hypotheses<\/h1>\n<ul>\n<li>H<sub>0<\/sub>: p<sub>1<\/sub>\u2212 p<sub>2<\/sub> = 0<\/li>\n<li>H<sub>A<\/sub>: p<sub>1<\/sub>\u2212 p<sub>2<\/sub> &lt; 0<\/li>\n<\/ul>\n<h1>Rejection Region<\/h1>\n<p>To determine which tail we are working with (left or right), we need to think about what we are looking to prove: the click-through with the feature enabled (p<sub>2<\/sub>) is higher than the click-through rate without the feature enabled (p<sub>1<\/sub>). This gives the following:<\/p>\n<ul>\n<li>Click-through with feature (p<sub>2<\/sub>) is higher than the rate without the feature (p<sub>1<\/sub>)<\/li>\n<li>This gives: p<sub>2<\/sub> &gt; p<sub>1<\/sub><\/li>\n<li>Moving p<sub>2<\/sub> to the right side gives: 0 &gt; p<sub>1<\/sub>\u2212 p<sub>2<\/sub><\/li>\n<li>Flipping the inequality (read it right to left) gives: p<sub>1<\/sub>\u2212p<sub>2<\/sub> &lt; 0<\/li>\n<li>If we want to prove that p<sub>1<\/sub>\u2212p<sub>2<\/sub> &lt; 0, we are performing a left-tailed test.<\/li>\n<\/ul>\n<h1>Type of Test<\/h1>\n<p>This is a left-tailed test. If p<sub>1<\/sub> is much lower than p<sub>2<\/sub>, then their difference will be negative and the test statistic (z<sub>test<\/sub>) will be low enough to be in the rejection region on the far left of the graph:<\/p>\n<figure id=\"attachment_2768\" aria-describedby=\"caption-attachment-2768\" style=\"width: 592px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/Lower5_w_Zcrit_and_Ztests.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-2768\" src=\"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/Lower5_w_Zcrit_and_Ztests.jpg\" alt=\"Bell shaped curve with lowest 5% highlighted. At the start of that region is written z critical. Two red lines are indicated, one on either side of z critical. Beside both lines is marked z test ?\" width=\"592\" height=\"278\" srcset=\"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/Lower5_w_Zcrit_and_Ztests.jpg 592w, https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/Lower5_w_Zcrit_and_Ztests-300x141.jpg 300w, https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/Lower5_w_Zcrit_and_Ztests-65x31.jpg 65w, https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/Lower5_w_Zcrit_and_Ztests-225x106.jpg 225w, https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/Lower5_w_Zcrit_and_Ztests-350x164.jpg 350w\" sizes=\"auto, (max-width: 592px) 100vw, 592px\" \/><\/a><figcaption id=\"caption-attachment-2768\" class=\"wp-caption-text\">Figure 61.2 Will the test statistic (z<sub>test<\/sub>) land in the rejection region?<\/figcaption><\/figure>\n<h1>Test Statistic<\/h1>\n<p>First, let us calculate the sample proportions:<\/p>\n<ul>\n<li>[latex]x_1 = 56[\/latex] and [latex]n_1 = 2946[\/latex] gives [latex]\\bar{p_1} = \\frac{56}{2946}= 0.0190[\/latex]<\/li>\n<li>[latex]x_2 = 77[\/latex] and [latex]n_2 = 3054[\/latex] gives [latex]\\bar{p_2} = \\frac{77}{3054}= 0.0252[\/latex]<\/li>\n<li>[latex]\\bar{p} = \\frac{x_1+x_2}{n_1+n_2} = \\frac{56+77}{2946+3054} = 0.02217[\/latex]<\/li>\n<\/ul>\n<p>We can now calculate the test statistic:<\/p>\n<p>[latex]z_{test} = \\frac{\\bar{p_1}-\\bar{p_2}}{\\sqrt{\\bar{p}(1-\\bar{p})\\left(\\frac{1}{n_1}+\\frac{1}{n_2}\\right)}} = \\frac{0.0191-0.0252}{\\sqrt{0.02217(1-0.02217)\\left(\\frac{1}{2946}+\\frac{1}{3054}\\right)}} = -1.6318[\/latex]<\/p>\n<h1>P-value<\/h1>\n<p>We are performing a left-tailed and use Excel&#8217;s <a href=\"https:\/\/support.microsoft.com\/en-us\/office\/norm-s-dist-function-1e787282-3832-4520-a9ae-bd2a8d99ba88\">NORM.S.DIST<\/a>\u00a0function:<\/p>\n<p>[latex]p\\text{-value}=\\text{NORM.S.DIST}(-1.6318, 1) = 0.0514[\/latex]<\/p>\n<h1>Decision<\/h1>\n<p>Because the p-value = 0.0514 (5.14%) is greater than (&gt;) the level of significance of 5% (0.05), we fail to reject H<sub>0<\/sub>.<\/p>\n<h1>Conclusion<\/h1>\n<p>Because we failed to reject H<sub>0<\/sub>, there is not sufficient evidence to conclude that the click-through rate is higher when the feature is turned on than when it&#8217;s turned off.<\/p>\n<\/div>\n<h1>RIGHT-tailed Test (Exercise)<\/h1>\n<p>What if, instead, we wanted to define the test as a right-tailed test. What would be different? Complete the exercise in the example below to determine the difference. In addition, let us reflect on how this example is different than the one sample proportion test from the previous chapter.<\/p>\n<h2>Example 61.2<\/h2>\n<p><span style=\"color: #003366\"><strong>Problem Setup:<\/strong><\/span> Let us redo the problem in Example 61.1 but solve it using a right-tailed hypothesis test.<\/p>\n<p><strong><span style=\"color: #003366\">You Try<\/span><\/strong>: Answer the questions in the exercise below to solve this problem:<\/p>\n<div class=\"textbox textbox--exercises\">\n<div class=\"textbox__content\">\n<div id=\"h5p-185\">\n<div class=\"h5p-iframe-wrapper\"><iframe id=\"h5p-iframe-185\" class=\"h5p-iframe\" data-content-id=\"185\" style=\"height:1px\" src=\"about:blank\" frameBorder=\"0\" scrolling=\"no\" title=\"Example 61.2 Right-Tailed Hypothesis Test for Difference in Proportions\"><\/iframe><\/div>\n<\/div>\n<\/div>\n<\/div>\n<p><span style=\"color: #003366\"><strong>Solutions<\/strong><\/span>: <a href=\"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/Example61-2_Solutions.xlsx\">Click here<\/a> to download the Excel solutions or click the sections below to reveal their solutions.<\/p>\n<div>\n<h1>How One-Sample and Two-Sample Tests Are Different<\/h1>\n<p>In differences between Two Proportions testing (this example):<\/p>\n<ul>\n<li>We are testing if the two populations are different (before and after the feature is enabled).<\/li>\n<li>We are assuming that we don&#8217;t know the &#8216;true&#8217; proportion but have two different sample proportions (with and without the feature enabled) recorded.<\/li>\n<li>We use both sample proportions to come up with a &#8216;best guess&#8217; for the population proportion, which we call the pooled sample proportion (p\u0304).<\/li>\n<\/ul>\n<p>In One-Sample Proportion Hypothesis Testing (Example 58.1):<\/p>\n<ul>\n<li>We are testing the true proportion (the click-through rate) has changed from its historical value (the rate before the feature was enabled)<\/li>\n<li>We treat the historical value as our population proportion<\/li>\n<li>We compare to this amount to see if there is any difference<\/li>\n<\/ul>\n<h1>Setting Up the Problem as Right-Tailed<\/h1>\n<p>We want to prove that the rate after the feature is enabled is higher than without the feature being enabled. If we set the following to be true:<\/p>\n<ul>\n<li>p<sub>1<\/sub> = the true click-through rate after the feature is enabled<\/li>\n<li>p<sub>2<\/sub> = the true click-through rate after the feature is enabled<\/li>\n<\/ul>\n<p>Then, when proving that the click-through rate is higher with the feature enabled, we get:<\/p>\n<ul>\n<li>H<sub>A<\/sub>: p<sub>1<\/sub> &gt; p<sub>2<\/sub> or H<sub>A<\/sub>: p<sub>1<\/sub> \u2212 p<sub>2<\/sub> &gt; 0<\/li>\n<li>This is a right-tailed test<\/li>\n<\/ul>\n<h1>The Null and Alternate Hypotheses<\/h1>\n<p>From the previous section, we can determine the null and alternate hypotheses:<\/p>\n<ul>\n<li>H<sub>0<\/sub>: p<sub>1<\/sub> = p<sub>2<\/sub> or H<sub>A<\/sub>: p<sub>1<\/sub> \u2212 p<sub>2<\/sub> = 0<\/li>\n<li>H<sub>A<\/sub>: p<sub>1<\/sub> &gt; p<sub>2<\/sub> or H<sub>A<\/sub>: p<sub>1<\/sub> \u2212 p<sub>2<\/sub> &gt; 0<\/li>\n<\/ul>\n<h1>The Test Statistic<\/h1>\n<p>Let us first calculate the sample proportions:<\/p>\n<ul>\n<li>[latex]x_1 = 77[\/latex],\u00a0[latex]n_1 = 3054[\/latex],\u00a0[latex]p_1 = \\frac{77}{3054}=0.0252[\/latex]<\/li>\n<li>[latex]x_2 = 56[\/latex], [latex]n_2 = 2946[\/latex], [latex]p_2 = \\frac{56}{2946}=0.0190[\/latex]<\/li>\n<li>[latex]\\bar{p}=\\frac{x_1+x_2}{n_1+n_2}=\\frac{77+56}{3054+2946} = 0.02217[\/latex]<\/li>\n<\/ul>\n<p>We can now use those proportions to calculate the test statistic:<\/p>\n<p>[latex]z_{test} = \\frac{\\bar{p_1}-\\bar{p_2}}{\\sqrt{\\bar{p}(1-\\bar{p})\\left(\\frac{1}{n_1}+\\frac{1}{n_2}\\right)}} = \\frac{0.0252-0.0191}{\\sqrt{0.02217(1-0.02217)\\left(\\frac{1}{3054}+\\frac{1}{2946}\\right)}} = 1.6318[\/latex]<\/p>\n<h1>P-value<\/h1>\n<p>We are performing a right-tailed and use Excel&#8217;s <a href=\"https:\/\/support.microsoft.com\/en-us\/office\/norm-s-dist-function-1e787282-3832-4520-a9ae-bd2a8d99ba88\">NORM.S.DIST<\/a>\u00a0function:<\/p>\n<p>[latex]p\\text{-value}=1-\\text{NORM.S.DIST}(1.6318, 1) = 0.0514[\/latex]<\/p>\n<h1>Decision<\/h1>\n<p>Because the p-value = 0.0514 (5.14%) is greater than (&gt;) the level of significance of 5% (0.05), we fail to reject H<sub>0<\/sub>.<\/p>\n<h1>Conclusion<\/h1>\n<p>Because we failed to reject H<sub>0<\/sub>, there is not sufficient evidence to conclude that the click-through rate is higher when the feature is turned on than when it&#8217;s turned off.<\/p>\n<\/div>\n<h1>TWO-tailed Test (Video of Written Solutions)<\/h1>\n<p>In this example, we will perform a two-tailed hypothesis test to test if there is a difference in proportions between two populations. In this case, we will look at sentiment surrounding the <a href=\"https:\/\/www.coastalgaslink.com\/\">LNG<\/a> pipeline in British Columbia.<\/p>\n<h2>Example 61.3<\/h2>\n<p><strong><span style=\"color: #003366\">Problem Setup<\/span><\/strong>: The BC Government is conducting a survey on people&#8217;s sentiments toward the natural gas pipeline being built.<\/p>\n<figure id=\"attachment_2786\" aria-describedby=\"caption-attachment-2786\" style=\"width: 575px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/alaska-5004758_1280.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-2786\" src=\"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/alaska-5004758_1280.jpg\" alt=\"Image of pipeline spanning across winter landscape.\" width=\"575\" height=\"383\" srcset=\"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/alaska-5004758_1280.jpg 1280w, https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/alaska-5004758_1280-300x200.jpg 300w, https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/alaska-5004758_1280-1024x682.jpg 1024w, https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/alaska-5004758_1280-768x512.jpg 768w, https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/alaska-5004758_1280-65x43.jpg 65w, https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/alaska-5004758_1280-225x150.jpg 225w, https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/alaska-5004758_1280-350x233.jpg 350w\" sizes=\"auto, (max-width: 575px) 100vw, 575px\" \/><\/a><figcaption id=\"caption-attachment-2786\" class=\"wp-caption-text\">Figure 61.3 Natural gas pipeline running through countryside<\/figcaption><\/figure>\n<p>They have sampled two different groups &#8211; those who voted for the <a href=\"https:\/\/en.wikipedia.org\/wiki\/British_Columbia_New_Democratic_Party\">NDP<\/a> in the previous election and those who voted for the <a href=\"https:\/\/en.wikipedia.org\/wiki\/BC_United\">Liberals<\/a>. They found the following to be true:<\/p>\n<ul>\n<li>Out of 224 NPD supporters sampled, 98 were in favor of the LNG pipeline.<\/li>\n<li>Out of 206 Liberal supporters sampled, 115 were in favor of the LNG pipeline.<\/li>\n<\/ul>\n<p><span style=\"color: #003366\"><strong>Question<\/strong><\/span>: Is there sufficient evidence to conclude, at the 2% level of significance, that there is a difference in the proportion of people who support the pipeline between the two groups?<\/p>\n<p><span style=\"color: #003366\"><strong>Solution<\/strong><\/span>: Click <a href=\"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/Example61-3_Solutions.xlsx\">here to download the Excel<\/a> solutions, or <a href=\"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/Example-61.3_Solution.pdf\">here for the PDF solutions<\/a>. Finally, click below to reveal the solutions.<\/p>\n<p><iframe loading=\"lazy\" id=\"oembed-2\" title=\"Testing for a difference in response rates between two groups\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/g0lJqQqwrlM?feature=oembed&#38;rel=0\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<div>\n<h1>Click here to reveal the written solutions<\/h1>\n<p><a href=\"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/Example61-3_Written_Solution.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-2798 aligncenter\" src=\"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/Example61-3_Written_Solution.jpg\" alt=\"Written solutions stepped through in above video\" width=\"657\" height=\"742\" srcset=\"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/Example61-3_Written_Solution.jpg 620w, https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/Example61-3_Written_Solution-266x300.jpg 266w, https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/Example61-3_Written_Solution-65x73.jpg 65w, https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/Example61-3_Written_Solution-225x254.jpg 225w, https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-content\/uploads\/sites\/2128\/2024\/07\/Example61-3_Written_Solution-350x395.jpg 350w\" sizes=\"auto, (max-width: 657px) 100vw, 657px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<\/div>\n","protected":false},"author":865,"menu_order":2,"template":"","meta":{"pb_show_title":"on","pb_short_title":"","pb_subtitle":"","pb_authors":[],"pb_section_license":""},"chapter-type":[],"contributor":[],"license":[],"class_list":["post-2706","chapter","type-chapter","status-publish","hentry"],"part":2684,"_links":{"self":[{"href":"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-json\/pressbooks\/v2\/chapters\/2706","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-json\/pressbooks\/v2\/chapters"}],"about":[{"href":"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-json\/wp\/v2\/types\/chapter"}],"author":[{"embeddable":true,"href":"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-json\/wp\/v2\/users\/865"}],"version-history":[{"count":25,"href":"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-json\/pressbooks\/v2\/chapters\/2706\/revisions"}],"predecessor-version":[{"id":2801,"href":"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-json\/pressbooks\/v2\/chapters\/2706\/revisions\/2801"}],"part":[{"href":"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-json\/pressbooks\/v2\/parts\/2684"}],"metadata":[{"href":"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-json\/pressbooks\/v2\/chapters\/2706\/metadata\/"}],"wp:attachment":[{"href":"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-json\/wp\/v2\/media?parent=2706"}],"wp:term":[{"taxonomy":"chapter-type","embeddable":true,"href":"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-json\/pressbooks\/v2\/chapter-type?post=2706"},{"taxonomy":"contributor","embeddable":true,"href":"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-json\/wp\/v2\/contributor?post=2706"},{"taxonomy":"license","embeddable":true,"href":"https:\/\/pressbooks.bccampus.ca\/1130sandbox\/wp-json\/wp\/v2\/license?post=2706"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}