9.1.2 - Hypothesis Testing

9.1.2 - Hypothesis Testing

Here we will walk through the five-step hypothesis testing procedure for comparing the proportions from two independent groups. In order to use the normal approximation method there must be at least 10 "successes" and at least 10 "failures" in each group. In other words, \(n p \geq 10\) and \(n (1-p) \geq 10\) for both groups.

If this assumption is not met you should use Fisher's exact method in Minitab Express or bootstrapping methods in StatKey.


9.1.2.1 - Normal Approximation Method Formulas

9.1.2.1 - Normal Approximation Method Formulas

1. Check any necessary assumptions and write null and alternative hypotheses.

To use the normal approximation method a minimum of 10 successes and 10 failures in each group are necessary (i.e., \(n p \geq 10\) and \(n (1-p) \geq 10\)).

The two groups that are being compared must be unpaired and unrelated (i.e., independent).

Below are the possible null and alternative hypothesis pairs:

Research Question Are the proportions of group 1 and group 2 different? Is the proportion of group 1 greater than the proportion of group 2? Is the proportion of group 1 less than the proportion of group 2?
Null Hypothesis, \(H_{0}\) \(p_1 - p_2=0\) \(p_1 - p_2=0\) \(p_1 - p_2=0\)
Alternative Hypothesis, \(H_{a}\) \(p_1 - p_2 \neq 0\) \(p_1 - p_2> 0\) \(p_1 - p_2<0\)
Type of Hypothesis Test Two-tailed, non-directional Right-tailed, directional Left-tailed, directional
2. Calculate an appropriate test statistic.

The null hypothesis is that there is not a difference between the two proportions (i.e., \(p_1 = p_2\)). If the null hypothesis is true then the population proportions are equal. When computing the standard error for the difference between the two proportions a pooled proportion is used as opposed to the two proportions separately (i.e., unpooled). This pooled estimate will be symbolized by \(\widehat{p}\). This is similar to a weighted mean, but with two proportions. 

Pooled Estimate of \(p\)
\(\widehat{p}=\frac{\widehat{p}_1n_1+\widehat{p}_2n_2}{n_1+n_2}\)

The standard error for the difference between two proportions is symbolized by \(SE_{0}\). The subscript 0 tells us that this standard error is computed under the null hypothesis (\(H_0: p_1-p_2=0\)).

Standard Error

\(SE_0={\sqrt{\frac{\widehat{p} (1-\widehat{p})}{n_1}+\frac{\widehat{p}(1-\widehat{p})}{n_2}}}=\sqrt{\widehat{p}(1-\widehat{p})\left ( \frac{1}{n_1}+\frac{1}{n_2} \right )}\)

Note that the default in many statistical programs, including Minitab Express, is to estimate the two proportions separately (i.e., unpooled). In order to obtain results using the pooled estimate of the proportion you will need to change the method.

Also note that this standard error is different from the one that you used when constructing a confidence interval for \(p_1-p_2\). While the hypothesis testing procedure is based on the null hypothesis that \(p_1-p_2=0\), the confidence interval approach is not based on this premise. The hypothesis testing approach uses the pooled estimate of \(p\) while the confidence interval approach will use an unpooled method. 

Test Statistic for Two Independent Proportions
\(z=\frac{\widehat{p}_1-\widehat{p}_2}{SE_0}\)
3. Determine the p value associated with the test statistic.

The \(z\) test statistic found in Step 2 is used to determine the \(p\) value. The \(p\) value is the proportion of the \(z\) distribution (normal distribution with a mean of 0 and standard deviation of 1) that is more extreme than the test statistic in the direction of the alternative hypothesis. 

4. Decide between the null and alternative hypotheses.

If \(p \leq \alpha\) reject the null hypothesis. If \(p>\alpha\) fail to reject the null hypothesis.

5. State a "real world" conclusion.

Based on your decision in Step 4, write a conclusion in terms of the original research question.


9.1.2.1.1 – Example: Ice Cream

9.1.2.1.1 – Example: Ice Cream

Example: Ice Cream

The Creamery wants to compare men and women in terms of preference for eating their ice cream out of a cone to determine if there is a gender difference. They take a sample of 500 customers (240 men and 260 women) and ask if they prefer cones over bowls. They found that 124 men preferred cones and 90 women preferred cones.

1. Check any necessary assumptions and write hypotheses.

\(H_0: p_m - p_f = 0\)

\(H_a:p_m - p_f \ne 0\)
 

\(n_m \widehat p_m = 124\)

\(n_m (1-\widehat p_m) = 240 - 124 = 116\)

\(n_f \widehat p_f = 90\)

\(n_f (1-\widehat p_f) = 260-90 = 170\)

These counts are all at least 10 so we can use the normal approximation method.

2. Calculate an appropriate test statistic.
Pooled Estimate of \(p\)
\(\widehat{p}=\frac{\widehat{p}_1n_1+\widehat{p}_2n_2}{n_1+n_2}\)

\(\widehat{p}=\frac{124+90}{240+260}=\frac{214}{500}=0.428\)

Standard Error of \(\widehat{p}\)
\(SE_{0}={\sqrt{\frac{\widehat{p} (1-\widehat{p})}{n_1}+\frac{\widehat{p}(1-\widehat{p})}{n_2}}}=\sqrt{\widehat{p}(1-\widehat{p})\left ( \frac{1}{n_1}+\frac{1}{n_2} \right )}\)

\(SE_{0}=\sqrt{0.428(1-0.428)\left ( \frac{1}{240}+\frac{1}{260} \right )}=0.04429\)

Test Statistic for Two Independent Proportions
\(z=\frac{\widehat{p}_1-\widehat{p}_2}{SE_0}\)

\(z=\frac{\frac{124}{240}-\frac{90}{260}}{0.04429}=3.850\)

3. Determine the p-value associated with the test statistic.

This is a two-tailed test. Our p-value will be the area of the \(z\) distribution more extreme than \(3.850\).

Standard normal distribution showing the p-value given z=3.850 for a two-tailed test

\(p = 0.0000591 \times 2 = 0.0001182\)

4. Decide between the null and alternative hypotheses.

\(p \le 0.05\)

Reject the null hypothesis

5. State a "real world" conclusion.

There is evidence that the proportion of men who prefer cones is different from the proportion of women who prefer cones in the population.


9.1.2.1.2 – Example: Same Sex Marriage

9.1.2.1.2 – Example: Same Sex Marriage

Example: Same Sex Marriage

A survey was given to a random sample of college students. They were asked whether they think same sex marriage should be legal. We'll compare the proportion of males and females who responded "yes." Of the 251 females in the sample, 185 said "yes." Of the 199 males in the sample, 107 said "yes."

1. Check any necessary assumptions and write null and alternative hypotheses.

For females, there were 185 who said "yes" and 66 who said "no." For males, there were 107 who said "yes" and 92 who said "no." There are at least 10 successes and failures in each group so the normal approximation method can be used.

  • \(\widehat{p}_{f}=\frac{185}{251}\)
  • \(\widehat{p}_{m}=\frac{107}{199}\)

This is a two-tailed test because we are looking for a difference between males and females, we were not given a specific direction. 

  • \( H_{0} : p_{f}- p_{m}=0 \)
  • \( H_{a} : p_{f}- p_{m}\neq 0 \)
2. Calculate an appropriate test statistic.

\(\widehat{p}=\frac{185+107}{251+199}=\frac{292}{450}=0.6489\)

\(SE_0=\sqrt{\frac{292}{450}\left ( 1-\frac{292}{450} \right )\left ( \frac{1}{251}+\frac{1}{199} \right )}=0.0453\)

\(z=\frac{\frac{185}{251}-\frac{107}{199}}{0.0453}=4.400\)

Our test statistic is \(z=4.400\)

3. Determine a p value associated with the test statistic.

Distribution Plot of Density vs X - Normal, Mean=0, StDev=1

\(P(z>4.400)=0.0000054\), this is a two-tailed test, so this value must be multiplied by two: \(0.0000054\times 2= 0.0000108\)

\(p<0.0001\)

4. Decide between the null and alternative hypotheses.

\(p\leq0.05\), therefore we reject the null hypothesis.

5. State a "real world" conclusion.

There is evidence that there is a difference between the proportion of females and males who think that same sex marriage should be legal.


9.1.2.2 - Minitab Express: Difference Between 2 Independent Proportions

9.1.2.2 - Minitab Express: Difference Between 2 Independent Proportions

When conducting a hypothesis test comparing the proportions of two independent proportions in Minitab Express two p-values are provided. If \(np \ge 10\) and \(n(1-p) \ge 10\), use the p-value associated with the normal approximation method. If this assumption is not met, use the p-value associated with Fisher's exact method.

When conducting a hypothesis test for a difference between two independent proportions in Minitab Express you need to remember to change the "test method" to "use the pooled estimate of the proportion." This is because the null hypothesis is that the two proportions are equal.

MinitabExpress  – Testing Two Independent Proportions using Raw Data

Let's compare the proportion of females who have tried weed to the proportion of males who have tried weed. 

  1. Open Minitab Express file:
  2. On a PC: In the menu bar select STATISTICS > Two Samples > Proportions
  3. On a Mac: In the menu bar select Statistics > 2-Sample Inference > Proportions
  4. Double click the variable Try Weed in the box on the left to insert the variable into the Samples box
  5. Double click the variable Biological Sex in the box on the left to insert the variable into the Sample IDs box
  6. Under the Options tab change the Test method to Use the pooled estimate of the proportion
  7. Click OK

This should result in the following output:

2-Sample Proportions: Try Weed by Biological Sex
Method
Event: Try Weed = Yes
\(p_1\): proportion where Try Weed = Yes and Biological Sex = Female
\(p_2\): proportion where Try Weed = Yes and Biological Sex = Male
Difference: \(p_1-p_2\)
Descriptive Statistics: Try Weed
Biological Sex N Event Sample p
Female 127 56 0.440945
Male 99 62 0.626263
Estimation for Difference
Difference 95% CI for Difference
-0.185318 (-0.313920, -0.056716)
Test
Null hypothesis \(H_0\): \(p_1-p_2=0\)
Alternative hypothesis \(H_1\): \(p_1-p_2\neq0\)
Method Z-Value P-Value
Fisher's exact   0.0072
Normal approximation -2.77 0.0057

The pooled estimate of the proportion (0.522124) is used for the tests.

Video Walkthrough

Select your operating system below to see a step-by-step guide for this example.

Five Step Hypothesis Testing Procedure

Step 1:
\(H_0 : p_f - p_m =0\)
\(H_a : p_f - p_m \neq 0\)

\(n_f p_f = 56\)
\(n_f (1-p_f) = 127-56 = 71\)
\(n_m p_m = 62\)
\(n_m (1-p_m) = 99-62 = 37\)

All \(np\) and \(n(1-p)\) are at least ten, therefore we can use the normal approximation method.

Step 2:
From output, \(z=-2.77\)

Step 3:
From output, \(p=0.0057\)

Step 4:
\(p \leq \alpha\), reject the null hypothesis

Step 5:
There is evidence that in the population the proportion of females who have tried weed is different from the proportion of males who have tried weed.

MinitabExpress  – Testing Two Independent Proportions using Summarized Data

Let's compare the proportion of Penn State World Campus graduate students who have children to the proportion of Penn State University Park graduate students who have children.  In a representative sample there were 120 World Campus graduate students; 92 had children.  There were 160 University Park graduate students; 23 had children.

  1. Open Minitab Express without data
  2. On a PC: In the menu bar select STATISTICS > Two Samples > Proportions
  3. On a Mac: In the menu bar select Statistics > 2-Sample Inference > Proportions
  4. Change Both samples are in one column to Summarized data
  5. For Sample 1 next to Number of events enter 92 and next to Number of trials enter 120
  6. For Sample 2 next to Number of events enter 23 and next to Number of trials enter 160
  7. Under the Options tab change the Test method to Use the pooled estimate of the proportion
  8. Click OK

This should result in the following output:

2-Sample Proportions
Method
\(p_1\): proportion where Sample 1 = Event
\(p_2\): proportion where Sample 2 = Event
Difference: \(p_1-p_2\)
Descriptive Statistics
Sample N Event Sample p
Sample 1 120 92 0.766667
Sample 2 160 23 0.143750
Estimation for Difference
Difference 95% CI for Difference
0.622917 (0.529740, 0.716093)
Test
Null hypothesis \(H_0\): \(p_1-p_2=0\)
Alternative hypothesis \(H_1\): \(p_1-p_2\neq0\)
Method Z-Value P-Value
Fisher's exact   <0.0001
Normal approximation 10.49 <0.0001

The pooled estimate of the proportion (0.410714) is used for the tests.

Video Walkthrough

Select your operating system below to see a step-by-step guide for this example.

Five Step Hypothesis Testing Procedure

Step 1:
\(H_0 : p_W - p_U =0\)
\(H_a : p_W - p_U \neq 0\)

\(n_W p_W = 92\)
\(n_W (1-p_W) = 120-92 = 28\)
\(n_U p_U = 23\)
\(n_U (1-p_u) = 160-23 = 137\)

All \(np\) and \(n(1-p)\) are at least ten, therefore we can use the normal approximation method.

Step 2:
From output, \(z=10.49\)

Step 3:
From output, \(p<.0001\)

Step 4:
\(p \leq \alpha\), reject the null hypothesis

Step 5:
There is evidence that in the population the proportion of World Campus students who have children is different from the proportion of University Park students who have children.


9.1.2.2.1 - Example: Dating

9.1.2.2.1 - Example: Dating

Example: Dating

This example uses the course survey dataset:

A random sample of Penn State University Park undergraduate students were asked, "Would you date someone with a great personality even if you did not find them attractive?"  Let's compare the proportion of males and females who responded "yes" to determine if there is evidence of a difference.

1. Check any necessary assumptions and write hypotheses.

We are looking for a "difference," so this is a two-tailed test.

\(H_{0} : p_1 - p_2 =0\)
\( H_{a} :p_1 - p_2 \neq 0 \)

Method
Event: DatePerly = Yes
\(p_1\): proportion where DatePerly = Yes and Gender = Female
\(p_2\): proportion where DatePerly = Yes and Gender = Male
Difference: \(p_1-p_2\)
Descriptive Statistics: DatePerly
Gender N Event Sample p
Female 571 367 0.642732
Male 433 148 0.341801
Estimation for Difference
Difference 95% CI for Difference
0.300931 (0.241427, 0.360435)
Test
Null hypothesis \(H_0\): \(p_1-p_2=0\)
Alternative hypothesis \(H_1\): \(p_1-p_2\neq0\)
Method Z-Value P-Value
Fisher's exact   <0.0001
Normal approximation 9.45 <0.0001

The pooled estimate of the proportion (0.512948) is used for the tests.

\(n_f p_f = 367\)

\(n_f (1-p_f) = 571 - 367 = 204\)

\(n_m p_m = 148\)

\(n_m (1 - p_m) = 433 - 148 = 285\)

All of these counts are at least 10 so we will use the normal approximation method.

2. Calculate an appropriate test statistic.

From output, \(z=9.45\)

3. Determine the p-value associated with the test statistic.

From output, \(p<0.0001\)

4. Decide between the null and alternative hypotheses.

\(p \leq \alpha\), reject the null hypothesis

5. State a "real world" conclusion.

There is evidence that in the population of all Penn State University Park undergraduate students the proportion of men who would date someone with a great personality even if they did not find them attractive is different from the proportion of women who would date someone with a great personality even if they did not find them attractive.


Legend
[1]Link
Has Tooltip/Popover
 Toggleable Visibility