Contents

Chapter 9: Hypothesis Tests

For One Population Mean ($\mu$)

Weighing Evidence • Critical Values• P-Values • Error Types

The Trial Begins!

Welcome to Hypothesis Testing.

In Chapter 8, we simply estimated parameters.
Now, the stakes are higher: We are formally testing claims about reality against hard data.
Expect rigorous logic, new terminology (P-values, Alpha, Beta), and structured decision making.

Weighing Evidence

Making Decisions

Managing Errors

The Inference Roadmap

Tracking our progression through Inferential Statistics.

INFERENCE

Confidence Intervals

  • 1-Mean (Ch.8)
  • 2-Mean
  • Proportions
We are here!

Hypothesis Testing

1-Mean(Ch.9)2-MeanProportionsChi-SquareANOVA

9.1 The Logic of Hypothesis Testing

Def 9.1: Competing Claims

  • Null hypothesis $H_0$: The default assumption or status quo to be tested. (Usually "no effect" or "equality").
  • Alternative hypothesis $H_a$: The competing claim we seek to find evidence for.
  • Hypothesis test: The process of deciding whether to reject $H_0$ in favor of $H_a$.
The "Trial" Analogy

In a courtroom, you are "Innocent until proven guilty." Data is the evidence.

$H_0$ (Innocent)$H_a$ (Guilty via Evidence)

9.1 Type I vs Type II Errors

The Medical Test Analogy

$H_0$: You are perfectly Healthy.
Type I Error (False Alarm, $\alpha$): The doctor says you are sick, but you are actually healthy. (Unnecessary stress & meds).
Type II Error (Missed Danger, $\beta$): The doctor says you are healthy, but you are actually sick. (The illness progresses untreated).

When making a statistical decision, there are exactly four possible outcomes:

Actual Reality (Truth)
Our Decision$H_0$ is TRUE$H_0$ is FALSE ($H_a$ True)
Do Not Reject $H_0$ Correct Decision Type II Error ($\beta$)
(Missed a real effect)
Reject $H_0$ Type I Error ($\alpha$)
(False alarm)
Correct Decision
Key Fact 9.2 ($\alpha$ vs $\beta$): For a fixed sample size, reducing the significance level $\alpha$ (making it harder to trigger a false alarm) increasesthe probability $\beta$ of a Type II error (missing a real effect).

9.2 Critical-Value Approach

Definition 9.4: Rejection Regions

We set a "boundary" based on $\alpha$. If our sample statistic crosses that boundary, we reject the null hypothesis.

Left-Tailed

Reject if $z \le -z_{\alpha}$

Two-Tailed

Reject if $z \le -z_{\alpha/2}$ or $z \ge z_{\alpha/2}$

Right-Tailed

Reject if $z \ge z_{\alpha}$

9.3 P-Value Approach & Rules

Definition 9.5: What is a P-Value?

Assuming $H_0$ is true, the P-Value is the probability of obtaining sample dataat least as inconsistent with $H_0$ as the actual data we observed.

It is the "Observed Significance Level." The smaller the P-value, the stronger the evidence against $H_0$.

The Decision Rule
"If P is low,
the null must go!"
  • If $P \le \alpha$, REJECT$H_0$. (The data is too weird to be chance).
  • If $P > \alpha$, DO NOT REJECT $H_0$. (The data is totally normal under $H_0$).
P-Value Visualized (Left-Tail)

Because P-value Area < $\alpha$Area, we Reject $H_0$.

The Two Approaches are Twins!

Whether you use the Critical Value or the P-Value, you will always reach the exact same decision.

Critical-Value Approach

Compares distances on the x-axis.

  • Find the threshold score ($z_\alpha$).
  • Find our score ($z_{obs}$).
  • Decision: Reject if our score is further out than the threshold.

P-Value Approach

Compares areas under the curve.

  • Find the threshold area ($\alpha$).
  • Find our area ($P$).
  • Decision: Reject if our area issmaller than the threshold area.
If your test statistic crosses the critical boundary, its tail area (P) is mathematically guaranteed to be smaller than $\alpha$.

Visual Inference Tool

A dynamic visualization of the Normal Distribution, the critical threshold($\alpha$), and where observed sample data falls to infer population behavior.

Tables 9.7 & 9.8: Steps and Interpretation

The 6 Steps (Translated)

Formal Statistical StepPlain-English Translator
1State $H_0$ and $H_a$.What are the opposing claims?
2Choose significance level $\alpha$.Where is the "bullshit" threshold?
3Compute test statistic(e.g., $z$).How many standard deviations away is our data from the claim?
4Determine P-value($P$).What's the probability of seeing this data by pure chance?
5If$P \le \alpha$, reject $H_0$.Is $P$ lower than $\alpha$? If yes, the Null must go!
6Interpret the result.State conclusion in context of the original problem.

Interpreting Evidence Against $H_0$

If we don't fix $\alpha$, what does the $P$-value itself tell us about the strength of evidence?

P-ValueEvidence
$P > 0.10$Weak / None
$0.05 < P \le 0.10$Moderate
$0.01 < P \le 0.05$Strong
$P \le 0.01$Very Strong

9.4 Tests when $\sigma$ Is Known ($z$-Test)

Procedure 9.1: Parameters & Equations

Assumptions: 1) Simple random sample. 2) Normal population OR large sample. 3)Standard Deviation ($\sigma$) is KNOWN.

Step 1: State hypotheses: $H_0: \mu = \mu_0$ against $H_a$: ($\ne$, $<$, or $>$)
Step 2: Choose $\alpha$
Step 3 (Calculate Statistic):
$$ z = \frac{\bar{x}-\mu_0}{\sigma/\sqrt{n}} $$
4 Determine P-value (via Software or Table II Normal Distribution).

5 Compare $P$ to $\alpha$.

6 Document Conclusion.

Key Fact 9.7: When to Use the One-Mean Test

The test logic relies on the Central Limit Theorem. Sample size matters heavily if the underlying biology/process is not normal.

Sample Size ($n$)Condition for Use
Small ($n < 15$)Use only if the target variable acts strictly normally.
Moderate ($15 \le n < 30$)Use unless extreme outliers exist or data is heavily skewed.
Large ($n \ge 30$)Can be used essentially without restriction!
Outlier Protocol: If outliers exist but aren't measurement errors, run the test twice (with and without them) to assess their impact on the final decision.

9.5 Tests when $\sigma$ Is Unknown ($t$-Test)

We don't know the population $\sigma$, so we substitute the sample $s$. This adds uncertainty, requiring the "fatter-tailed" student distribution.

Figure 9.19

Left-tailed $t$-test example where $n=12$($df=11$), testing boundary $\alpha = 0.05$

  • $t_{0.05} = -1.796$ (from Table IV)
  • Calculated $t = -1.938$
  • Result: Falls into the rejection region!
Figure 9.20

Two-tailed $t$-test example where $n=25$($df=24$).

  • $t_{\alpha/2} = \pm 2.064$ (implied boundaries)
  • Calculated $t = -0.895$
  • Result: Falls in non-rejection region.

Procedure 9.2: The $t$-Test

Assumptions: 1) Simple random sample. 2) Normal pop OR large sample. 3)Standard Deviation ($\sigma$) UNKNOWN.

Step 1-2: State hypotheses, choose $\alpha$.

Step 3 (Calculate Statistic):
$$ t = \frac{\bar{x}-\mu_0}{s/\sqrt{n}} $$
4 Calculate P-value using Table IV and Degrees of Freedom ($df = n-1$).

5 Compare $P$ to$\alpha$.

6 Document conclusion.

9.6 The Wilcoxon Signed-Rank Test

What if the sample size is small ($n<15$) and the data plot looks completely weird(not normal)?

Key Fact 9.8 (Wilcoxon vs t-Test):
If the variable is reasonably normal, use the t-test. If the variable is not normal but is symmetric, use the non-parametric Wilcoxon signed-rank test.

Procedure 9.3: Steps for Ranking

Instead of analyzing the raw numbers (which are warped), we analyze their order/rank.

  1. Compute Differences: $D = x - \mu_0$.
  2. Strip signs: Absolute values $|D|$.
  3. Rank the strictly positive absolute values from smallest (1) to largest.
  4. Restore signs: Multiply rank by sign of original $D$.
  5. Test Statistic: $W = \text{sum of positive ranks}$

9.6 Wilcoxon Execution Example

Hypothesis: Are weekly food costs$\ne \mu_0=157$?

Cost ($x$)$D = x - 157$Absolute $|D|$Rank of $|D|$Signed Rank ($R$)
143-14147-7
138-19199-9
16912126+6
...............
159221+1

Sum the positive ranks to get $W$.Look up P-value in Wilcoxon Table V (or use software!).

9.7 Type II Error Probabilities ($\beta$)

Calculating the exact chance that we missed a real change (Type II Error).

Figure 9.30 (The Baseline)
  • Let Null Mean $\mu_0 = 26.0$. Critical test boundary is calculated as $\bar{x}=25.6$based on our chosen $\alpha=0.05$.
  • If sample drops below 25.6, we Reject.
(Base Dist under $H_0$)
Figure 9.31 (True Shift)
  • Assume the secret reality is $\mu=25.8$. Since $25.8 \ne 26.0$, $H_0$ is false.
  • $\beta = P(\text{Failed to reject}) = P(\bar{x} > 25.6)$
  • Convert 25.6 to z-score against new mean 25.8.
  • Calculated $\beta = 0.7794$. High chance of missing it!

9.7 Power & Curves

Definition 9.6: Statistical Power

Power is the probability of properly rejecting a false null hypothesis:
Power = $1 -\beta$


Procedure 9.5: Power Curves (Fig 9.38 & Key Fact 9.9)
  1. Compute $\beta$ across a spectrum of assumed true means $\mu_a$.
  2. Compute power ($1-\beta$) for each.
  3. Plot $\mu$ vs power to create the "Power Curve."

Crucial Rule:For a fixed significance level, increasing sample size ($n$) vertically pushes up the power curve. Higher $n$ means fewer missed discoveries!

9.8 Which Test Do I Pick?

Synthesizing all tools into a single flowchart structure (Figure 9.39).

Normal Population?
YES: $\sigma$ Known? z-Test(else t-Test)
NO:Symmetric? Wilcoxon Test
if NOT symmetric, but $n \ge 30$, use CLT fallback (Go back to YES branch).

R Code: The $z$-Test

Writing code that precisely mirrors the math steps on the board.

Math Steps in R
# --- METHOD A: Using Summary Statistics (Word Problems) ---
sigma <- ?               # Known Pop SD
mu_0 <- ?                # Null Hypothesis Mean claim

x_bar <- ?               # Sample Mean
n <- ?                   # Sample Size

# --- METHOD B: Using Raw Data (Uncomment if needed) ---
# data <- c(...)
# x_bar <- mean(data)
# n <- length(data)

# 1. Compute Z-Statistic
z <- (x_bar - mu_0) / (sigma / sqrt(n))

# 2. Compute P-values
p_left <- pnorm(z)                        # Left-tailed (Ha: mu < mu0)
p_right <- 1 - pnorm(z)                   # Right-tailed (Ha: mu > mu0)
p_two <- 2 * (1 - pnorm(abs(z)))          # Two-tailed (Ha: mu != mu0)

# Output results
z
p_two  # (or p_left/p_right depending on your Ha)

R Code: The $t$-Test

When $\sigma$ is unknown, we use $s$ and the $t$-distribution.

Math Steps in R
# --- METHOD A: Using Summary Statistics (Word Problems) ---
s <- ?                   # Sample SD (Sigma unknown)
mu_0 <- ?                # Null Hypothesis Mean claim

x_bar <- ?               # Sample Mean
n <- ?                   # Sample Size
df <- n - 1              # Degrees of Freedom

# --- METHOD B: Using Raw Data (Uncomment if needed) ---
# data <- c(...)
# x_bar <- mean(data)
# s <- sd(data)
# n <- length(data)
# df <- n - 1

# 1. Compute T-Statistic
t_stat <- (x_bar - mu_0) / (s / sqrt(n))

# 2. Compute P-values
p_left <- pt(t_stat, df)                        # Left-tailed (Ha: mu < mu0)
p_right <- 1 - pt(t_stat, df)                   # Right-tailed (Ha: mu > mu0)
p_two <- 2 * (1 - pt(abs(t_stat), df))          # Two-tailed (Ha: mu != mu0)

# Output results
t_stat
p_two  # (or p_left/p_right depending on your Ha)

Simulator: Effect of Sample Size ($n$) on Power

Based on Figure 9.30 & 9.36 logic: manipulate the Sample Size parameter to see the orange $\beta$ Type II Error region change shape against the Null mean.

Questions?

Condensed Chapter Takeaways
  • Hypothesis testing evaluates $H_0$ against $H_a$.
  • Type I error prob is $\alpha$; Type II error prob is $\beta$.
  • Power is $1-\beta$, and larger samples ($n$) strictly increase power.
  • Use $z$-test ($\sigma$ known), $t$-test ($\sigma$ unknown), Wilcoxon (symmetric non-normal).