Contents

Chapter 12: Inferences for Population Proportions

Estimating & Testing $p$ and $(p_1 - p_2)$

One Proportion • Margin of Error•Two Proportions • Sample Sizes

The Final Third of the Semester

Welcome to the home stretch! We aren't learning fundamentally "new" math theories anymore. Instead, we are executing what we know (Hypothesis Tests & CIs) for different scenarios using RStudio as our primary tool.

Remaining Schedule

  • Week 12 (Apr 6): Ch.12 — Proportions
  • Week 13 (Apr 13): Ch.13 — Chi-Square Procedures
  • Week 14 (Apr 20): Ch.14 — Regression
  • Week 15 (Apr 27): Ch.16 — ANOVA
  • Week 16: Exam 3 + Final Project Meetings
  • Week 17: FINALS WEEK + Project Due
RStudio & Final Project

This phase of the course directly ties into your Final Project! The tools you learn here(prop.test, chisq.test, linear models) are the exact techniques you will use in RStudio to extract meaning from your chosen datasets.

Focus heavily on interpreting outputs and checking assumptions.

12.1 One Population Proportion

Consider a population where each member either has or does not have a specified attribute (e.g., "voted", "defective").

Definition 12.1

  • Population proportion, $p$: The true proportion of the entire population that has the specified attribute.
  • Sample proportion, $\hat{p}$: The proportion of a sample from the population that has the specified attribute.

Formula 12.1: $\hat{p} = \frac{x}{n}$

$x = \text{successes}$, $n= \text{sample size}$

Visualizing a Proportion

Change the number of "successes" ($x$) out of$n=25$.

Why strictly the $z$-table? (Means vs. Proportions)

Means ($\mu, \bar{x}$)

  • Data: Quantitative (e.g., height, temperature)
  • Std. Error: Uses $s/\sqrt{n}$
  • Distribution: Requires the $t$-distribution because the sample standard deviation ($s$) must be estimated from data independently of the mean.

Proportions ($p, \hat{p}$)

  • Data: Categorical (Success/Failure, Yes/No)
  • Std. Error: Uses $\sqrt{p(1-p)/n}$
  • Distribution:Always$z$-distribution! The variance is perfectly locked to the proportion itself, so there is no independent $s$ to estimate.
Golden Rule for Chapter 12: We never use the $t$-table! Proportions always use the$z$-table.
Just remember your checks: $np \geq 5$ and $n(1-p) \geq 5$.

Concept Check: Scenario 1

As part of an independent quality control audit, a regional consumer advocacy group receives multiple formal complaints regarding the 'Ultra-Glow'smart LED system. The packaging advertises that their custom filaments endure a baseline operational lifespan averaging 15,000 hours. Suspecting deceptive marketing practices, the audit team secures a random sample of $n=50$ retail units, runs them under standard laboratory conditions to failure, and analyzes the data to determine if they should file a false advertising claim against the manufacturer for delivering a fundamentally inferior product.

1. Proportions or Mean?

Mean!
(Quantitative data: "hours","average")

2. Which Tail?

Left-Tailed
($H_a: \mu < 15,000$)

Concept Check: Scenario 2

Following a contentious municipal debate regarding the reallocation of public infrastructure funding, historically established polls from a prior cycle indicated that exactly 48% of registered district voters supported the overarching tax overhaul.Given a recent influx of contradictory socio-economic editorials and massive neighborhood campaigning, an independent civic databank is commissioned to randomly sample 1,200 active municipal residents. Their primary directive is to definitively ascertain whether the community's fundamental stance on the proposal has systematically shifted in any direction since the benchmark was established.

1. Proportions or Mean?

Proportions!
(Categorical data: "percentage",Yes/No)

2. Which Tail?

Two-Tailed
($H_a: p \neq 0.48$)

Concept Check: Scenario 3

A global biotechnology firm has recently rushed a proprietary antiviral compound through phase II clinical trials, issuing a press release that establishes a baseline efficacy benchmark of an exact 90% clearance rate across standard viral loads. Suspicious of the in-house testing methodology, a coalition of competing university virologists randomly synthesize the identical compound and administer it to a double-blind sample of severe symptomatic profiles. The university team is attempting to establish statistically significant clinical proof that the corporation's highly touted baseline clearance rate is a drastic underestimation of the drug's true therapeutic dominance.

1. Proportions or Mean?

Proportions!
(Categorical data: "success rate")

2. Which Tail?

Right-Tailed
($H_a: p > 0.90$)

Procedure 12.1: One-Proportion z-Interval

Assumptions

  • Simple random sample
  • The number of successes, $x$, and failures, $n-x$, are both 5 or greater.

Margin of Error (Formula 12.2)

$$E = z_{\alpha/2} \cdot \sqrt{\frac{\hat{p}(1-\hat{p})}{n}}$$

The Procedure

  1. Find $z_{\alpha/2}$ for confidence level $1-\alpha$ using the normal table.
  2. The interval bounds for $p$ are:
    $\hat{p} \pm z_{\alpha/2} \cdot \sqrt{\frac{\hat{p}(1-\hat{p})}{n}}$
  3. Interpret the interval in context.

Formula 12.3: Finding the Required Sample Size

How large a sample do we need to estimate a population proportion within a chosen margin of error $E$?

Scenario 1: No Guess Available

If we have no prior idea what $p$ might be, we assume the worst-case scenario ($p = 0.5$) to ensure the sample is large enough:

$$n = 0.25 \left( \frac{z_{\alpha/2}}{E} \right)^2$$

Always round UP to the nearest whole number.

Scenario 2: Educated Guess

If we have a prior estimate $\hat{p}_g$ (e.g., from a past study):

$$n = \hat{p}_g (1-\hat{p}_g) \left( \frac{z_{\alpha/2}}{E} \right)^2$$

Always round UP to the nearest whole number.

Procedure 12.2: One-Proportion z-Test

Seamless Continuation from Ch 10: The 5 core steps of Hypothesis Testing (Hypotheses $\rightarrow$ Critical Value $\rightarrow$ Test Statistic$\rightarrow$ P-Value $\rightarrow$ Conclusion) are IDENTICAL to everything we've done! The only difference is the standard error formula we use for the test statistic.

Setup & Assumptions

  • Simple random sample
  • $n p_0 \geq 5$ and $n(1-p_0) \geq 5$
  • Null Hypothesis: $H_0: p = p_0$
  • Alt Hypothesis: $H_a: p \neq p_0$ or $p < p_0$ or $p> p_0$

Test Statistic

Compute the observed test statistic $z_0$:
(Notice it is just [Observed - Null] / SE!)

$$z_0 = \frac{\hat{p}-p_{0}}{\sqrt{p_{0}(1-p_{0})/n}}$$

Use the normal table to find P-value/CV, then conclude.

Class Activity: Extract & Execute

The Scenario: A popular streaming service wants to evaluate mobile app usage. The marketing team publishes a bold claim stating that more than 55% of all current subscribers primarily use the mobile app to watch content. To investigate this internally, a data analyst takes a random sample of 850 active subscribers and finds that precisely 510 of them use the mobile app. At the $\alpha = 0.05$ significance level, does the data support the marketing team's claim?

Step 1: Read carefully. What kind of data is this? Are we dealing with means or averages? No, we are dealing with proportions (percentages)!

Extraction &Setup

  • Null Proportion($p_0$): $0.55$
    $\rightarrow H_0: p = 0.55 \quad H_a: p >0.55$ (Right-tailed)
  • Sample Size ($n$):$850$
  • Successes ($x$):$510$
    $\rightarrow \hat{p} = 510 / 850 = 0.60$

Execution & Decision

$z_0 = \frac{0.60 - 0.55}{\sqrt{0.55(0.45)/850}} \approx 2.93$

$2.93 > 1.645$ (CV) $\rightarrow$ Reject $H_0$

There is sufficient evidence to support the claim.

Interactive Sandbox: The Concept of Pooling

Sample 1 vs Sample 2

Change the number of "Successes" out of 50 trials.


$\hat{p}_1$:24%
$\hat{p}_2$:70%
Pooled $\hat{p}_p$: 47%

Pooling = Combining Successes and Trials

Under $H_0: p_1 = p_2$, we assume both come from the same true proportion. So we just combine all the categorical dots into one big bucket!

Sample 1 ($n_1=50$)
+
Sample 2 ($n_2=50$)
=
Pooled Data ($n=100$)

12.3 Inferences for Two Population Proportions


Pop 1 ($p_1$)
vs

Pop 2 ($p_2$)

Key Fact 12.2: Sampling Dist of $(\hat{p}_1 - \hat{p}_2)$

For independent samples we take from each population (sizes $n_1$ and$n_2$):

  • Mean: $\mu_{\hat{p}_1 - \hat{p}_2} = p_1 - p_2$
  • Standard Deviation:
    $\sigma_{\hat{p}_1 - \hat{p}_2} = \sqrt{\frac{p_1(1-p_1)}{n_1} +\frac{p_2(1-p_2)}{n_2}}$
  • Shape: Normally distributed for large $n_1$ and $n_2$.

Procedure 12.3: Two-Proportions z-Test

Hypotheses & Assumptions

  • $H_0: p_1 = p_2$
  • $H_a:$ $p_1 \neq p_2$, or $p_1 < p_2$, or $p_1> p_2$
  • Independent random samples.
  • All observed counts ($x_1$, $n_1-x_1$, $x_2$, $n_2-x_2$) $\geq 5$.

Pooled Sample Proportion

Because $H_0$ states $p_1 = p_2$, we pool the samples to estimate the common proportion:

$\hat{p}_p = \frac{x_1 + x_2}{n_1 + n_2}$

Test Statistic:

$z = \frac{\hat{p}_1 - \hat{p}_2}{\sqrt{\hat{p}_p(1-\hat{p}_p)} \sqrt{\frac{1}{n_1} +\frac{1}{n_2}}}$

Procedure 12.4: Two-Proportions z-Interval

Confidence Interval Endpoints

To estimate the difference $(p_1 - p_2)$ with confidence level $1-\alpha$:

$$(\hat{p}_1 - \hat{p}_2) \pm z_{\alpha/2} \cdot \sqrt{\frac{\hat{p}_1(1-\hat{p}_1)}{n_1} +\frac{\hat{p}_2(1-\hat{p}_2)}{n_2}}$$
Notice the difference: For the confidence interval, we do not pool the sample proportions. We use the individual $\hat{p}_1$ and $\hat{p}_2$ in the standard error, because we are no longer assuming $p_1 = p_2$ (which was the assumption under the null hypothesis).

R Code: Testing Proportions in RStudio

R handles proportion tests easily using `prop.test()` and estimating confidence intervals at the same time.

Proportion Tests
# --- ONE POPULATION PROPORTION ---
# x: number of successes, n: sample size, p: null proportion
# correct = FALSE turns off continuity correction (matches textbook z-test)
prop.test(x = 42, n = 100, p = 0.50, alternative = "greater", conf.level = 0.95, correct = FALSE)

# --- TWO POPULATION PROPORTIONS ---
# Supply successes as a vector: c(x1, x2)
# Supply sample sizes as a vector: c(n1, n2)
successes <- c(45, 30)
trials    <- c(100, 80)

# Two-tailed test comparing p1 and p2
prop.test(x = successes, n = trials, alternative = "two.sided", conf.level = 0.95, correct = FALSE)

Practice Sprint: Problem 1

10 Minute Challenge:
A poll asked whether states should be allowed to conduct random drug tests on elected officials. Of 16,195 respondents, 65% said "yes".
a. Determine the margin of error for a 99% confidence interval.
b. Without doing any calculations, indicate whether the margin of error is larger or smaller for a 90% confidence interval. Explain your answer.

Practice Sprint: Problem 2

10 Minute Challenge:
For a margin of error of 0.04, a 95% confidence level, and an educated guess of 0.4 for the sample proportion,obtain a sample size that will ensure a margin of error of at most the one specified.

Practice Sprint: Problem 3

10 Minute Challenge:
Perform a hypothesis test for $x=35$, $n=50$, $H_0: p=0.6$, $H_a: p < 0.6$, and $\alpha=0.05$.
a. Determine the sample proportion.
b. Decide if the one-proportion z-test is appropriate.
c. If appropriate, determine the test statistic, critical value(s), and conclusion.

Practice Sprint: Problem 4

10 Minute Challenge:
For independent samples $x_1=21$, $n_1=40$ and $x_2=25$, $n_2=30$ with $\alpha=0.10$:
a. Determine sample proportions $\hat{p}_1, \hat{p}_2,$ and pooled proportion$\hat{p}_p$.
b. Decide if two-proportions z-procedures are appropriate.

Practice Sprint: Problem 5

10 Minute Challenge:
Using the identical dataset mapping to the previous question ($x_1=21$, $n_1=40$, $x_2=25$, $n_2=30$,$\alpha=0.10$):
c. Conduct a left-tailed hypothesis test (find the test statistic, critical value, and conclusion).
d. Find an 80% confidence interval for $p_1 - p_2$.