November 14
1. Confidence Intervals (CIs)
A confidence interval (CI) provides a range of plausible values for an unknown population parameter (such as the population mean $\mu$ or proportion $p$) based on data from a sample.
The basic structure for most confidence intervals is:
\(\text{Point Estimate} \pm \text{Margin of Error}\)
\(\text{Point Estimate} \pm (\text{Critical Value}) \times (\text{Standard Error})\)
CIs for a Population Mean ($\mu$)
🔹 Case 1: Population SD ($\sigma$) is Known (Rare)
When you know the true population standard deviation $\sigma$, you use the Z-distribution (standard normal).
\(\bar{x} \pm z_{\alpha/2} \left(\frac{\sigma}{\sqrt{n}}\right)\)
- $\bar{x}$ = sample mean
- $z_{\alpha/2}$ = Z critical value (e.g., $1.96$ for 95% confidence)
- $\sigma$ = population standard deviation
- $n$ = sample size
🔹 Case 2: Population SD ($\sigma$) is Unknown (Common)
When $\sigma$ is unknown, you must estimate it using the sample standard deviation ($s$). This introduces more uncertainty, so we use the t-distribution.
\(\bar{x} \pm t_{\alpha/2, \nu} \left(\frac{s}{\sqrt{n}}\right)\)
- $\bar{x}$ = sample mean
- $s$ = sample standard deviation
- $n$ = sample size
- $\nu = n-1$ = degrees of freedom
- $t_{\alpha/2, \nu}$ = t critical value from the t-distribution with $\nu$ degrees of freedom.
Interpretation of a 95% CI
This is a critical concept and a common point of confusion.
- Correct Interpretation: “We are 95% confident that the interval ($A$, $B$) contains the true population mean $\mu$.”
- What this means: If we were to repeat our sampling procedure 100 times, and construct a 95% CI for each sample, we would expect about 95 of those intervals to successfully capture the true, fixed value of $\mu$.
- Common Misinterpretation (Incorrect!): “There is a 95% probability that the true mean $\mu$ falls within our specific interval ($A$, $B$).”
Why is this wrong? The true parameter $\mu$ is a fixed, unknown constant. It is either in your interval (probability 1) or it is not (probability 0). The “95%” refers to the long-run success rate of the method, not the probability of a single interval being correct.
Steps to Construct a CI for $\mu$ ($\sigma$ unknown)
- Check Conditions:
- Random: The data comes from a random, representative sample.
- Independent: Observations are independent (or $n < 10\%$ of the population).
- Normal/Large: The population is approximately normal, OR the sample size is large ($n \ge 30$) so the Central Limit Theorem (CLT) applies.
- Compute Statistics: Calculate the sample mean $\bar{x}$ and sample standard deviation $s$.
- Find Critical Value: Determine the confidence level (e.g., 95% $\rightarrow \alpha=0.05 \rightarrow \alpha/2 = 0.025$). Find $t_{\alpha/2, \nu}$ using degrees of freedom $\nu = n-1$.
- Calculate & Conclude:
- Compute Standard Error (SE): $SE = \frac{s}{\sqrt{n}}$
- Compute Margin of Error (ME): $ME = t_{\alpha/2, \nu} \times SE$
- Form the interval: $\bar{x} \pm ME$
- State the conclusion in context.
Single-Sided vs. Double-Sided CIs
-
Double-Sided CI (Standard): This is what we’ve discussed. It’s an interval $(A, B)$ that bounds the parameter from both above and below. It uses $t_{\alpha/2}$ because the $\alpha$ probability of error is split into two tails ($\alpha/2$ in each).
-
Single-Sided CIs (Confidence Bounds): Sometimes you only care about an upper or lower bound.
- 95% Lower Bound: “We are 95% confident that $\mu$ is at least $A$.” You put all $\alpha=0.05$ in the left tail.
\(\left(\bar{x} - t_{\alpha, \nu} \left(\frac{s}{\sqrt{n}}\right), \infty\right)\)
- 95% Upper Bound: “We are 95% confident that $\mu$ is at most $B$.” You put all $\alpha=0.05$ in the right tail.
\(\left(-\infty, \bar{x} + t_{\alpha, \nu} \left(\frac{s}{\sqrt{n}}\right)\right)\)
- Note: We use $t_{\alpha}$ (e.g., $t_{0.05}$) for a one-sided 95% CI, not $t_{\alpha/2}$ (e.g., $t_{0.025}$).
2. Hypothesis Testing
A hypothesis test is a formal procedure to assess the validity of a claim (hypothesis) about a population parameter using sample data.
The Setup
- Null Hypothesis ($H_0$): The “status quo” or “no effect” hypothesis. It always contains an equality sign (e.g., $\mu = \mu_0$, $\mu \le \mu_0$). We assume this is true to begin the test.
- Alternative Hypothesis ($H_a$): The claim we are looking for evidence for. It never contains equality (e.g., $\mu \neq \mu_0$, $\mu > \mu_0$, or $\mu < \mu_0$).
- Significance Level ($\alpha$): The threshold for “unlikely.” It’s the probability of a Type I Error (rejecting $H_0$ when it is actually true) that we are willing to accept. Common choices are $0.05$, $0.01$.
The Test Statistic
The test statistic measures how far our sample estimate is from the null hypothesis value, in units of standard error. For a mean ($\sigma$ unknown):
\(t = \frac{\bar{x}-\mu_0}{s/\sqrt{n}}\)
This value follows a t-distribution with $\nu = n-1$ degrees of freedom (assuming $H_0$ is true).
The p-value
The p-value is the single most important concept in hypothesis testing.
Definition: The p-value is the probability, assuming the null hypothesis ($H_0$) is true, of observing a test statistic as extreme (or more extreme) than the one computed from the sample.
- Small p-value (e.g., 0.01): “This is really unlikely to happen by chance if $H_0$ were true.” This provides strong evidence against $H_0$.
- Large p-value (e.g., 0.30): “This is a very plausible result if $H_0$ were true.” This provides no evidence against $H_0$.
The Decision
We compare the p-value to our significance level $\alpha$.
- If $p \le \alpha$: Reject $H_0$. (The result is statistically significant). We have sufficient evidence to support $H_a$.
- If $p > \alpha$: Fail to reject $H_0$. (The result is not statistically significant). We have insufficient evidence to support $H_a$.
Note: We never “accept $H_0$.” We only find that we don’t have enough evidence to throw it out.
3. t vs. Z — When to Use Each
This is a common source of confusion. The key is to know what parameter you’re testing (mean or proportion) and whether the population standard deviation ($\sigma$) is known.
| Parameter |
Population SD ($\sigma$) |
Sample Size ($n$) |
Test Statistic |
Notes |
| Mean ($\mu$) |
Known |
Any |
Z |
(Very rare in practice) |
| Mean ($\mu$) |
Unknown |
Small ($n < 30$) |
t |
(Requires population to be approx. normal) |
| Mean ($\mu$) |
Unknown |
Large ($n \ge 30$) |
t |
(CLT applies. $t$ is always correct.) |
| |
|
Alternatively |
Z |
(Many texts use Z as an approximation since $t \to Z$ as $n \to \infty$. $t$ is safer.) |
| Proportion ($p$) |
(N/A) |
Large |
Z |
(Requires $np \ge 10$ and $n(1-p) \ge 10$. SE = $\sqrt{\frac{\hat{p}(1-\hat{p})}{n}}$) |
Key Takeaway: The t-distribution is used when we estimate $\sigma$ with $s$. It has “heavier tails” than the Z-distribution to account for the extra uncertainty from this estimation. As $n$ gets large, this extra uncertainty becomes negligible, and the $t$-distribution becomes virtually identical to the Z-distribution.
4. Worked Examples
Example 1: 95% CI for a Mean ($\sigma$ unknown)
- Problem: Construct a 95% CI for the population mean.
- Given: Sample size $n = 16$, sample mean $\bar{x} = 10.2$, sample SD $s = 2.1$.
- Setup:
- Confidence = 95%, so $\alpha = 0.05$ and $\alpha/2 = 0.025$.
- $\sigma$ is unknown, so we use the t-distribution.
- Degrees of freedom $\nu = n-1 = 16-1 = 15$.
- Step 1 (Critical Value): Find $t_{\alpha/2, \nu} = t_{0.025, 15}$. From a t-table, $t^* = 2.131$.
- Step 2 (Standard Error): $SE = \frac{s}{\sqrt{n}} = \frac{2.1}{\sqrt{16}} = \frac{2.1}{4} = 0.525$.
- Step 3 (Margin of Error): $ME = t^* \times SE = 2.131 \times 0.525 \approx 1.119$.
- Step 4 (CI): $\bar{x} \pm ME \rightarrow 10.2 \pm 1.119$.
- Conclusion: The 95% CI is (9.081, 11.319).
- Interpretation: “We are 95% confident that the true population mean $\mu$ lies between 9.081 and 11.319.”
Example 2: One-Sample t-Test (Two-Sided)
- Problem: Test if the true mean $\mu$ is different from 100, using $\alpha = 0.05$.
- Given: $n = 9$, $\bar{x} = 104$, $s = 6$.
- Setup (Hypotheses):
- $H_0: \mu = 100$ (The true mean is 100)
- $H_a: \mu \neq 100$ (The true mean is not 100)
- $\alpha = 0.05$. Degrees of freedom $\nu = n-1 = 8$.
- Test Statistic:
\(t = \frac{\bar{x}-\mu_0}{s/\sqrt{n}} = \frac{104-100}{6/\sqrt{9}} = \frac{4}{6/3} = \frac{4}{2} = 2.0\)
- p-value:
- We need the two-sided p-value: $p = 2 \times P(T_8 \ge 2.0)$.
- Using software or a t-table for $\nu=8$, we find $P(T_8 \ge 2.0)$ is $\approx 0.0396$.
- $p \approx 2 \times 0.0396 = 0.0792$.
- Decision:
- We compare $p \approx 0.0792$ to $\alpha = 0.05$.
- Since $p > \alpha$ ($0.0792 > 0.05$), we fail to reject $H_0$.
- Conclusion: “At the 5% significance level, there is insufficient statistical evidence to conclude that the true population mean is different from 100.”
Example 3: Sample Size Planning
- Problem: Find the sample size $n$ needed for a 95% CI for $\mu$ to have a margin of error (ME) no more than $0.5$. A pilot study suggests $s \approx 2.1$.
- Formula: $ME = t_{\alpha/2, n-1}^* \left(\frac{s}{\sqrt{n}}\right)$. We need to solve $n \ge \left( \frac{t^* \cdot s}{ME} \right)^2$.
- Dilemma: $t^*$ depends on $n$, which we don’t know!
- Solution (Approximate): Since we expect $n$ to be large, $t^$ will be close to $Z^$. We use $Z_{0.025} = 1.96$ as a good approximation.
- Calculation:
\(n \approx \left( \frac{Z^* \cdot s}{ME} \right)^2 = \left( \frac{1.96 \times 2.1}{0.5} \right)^2 = (8.232)^2 \approx 67.76\)
- Conclusion: We must always round up to ensure the ME is at most 0.5.
- Final Answer: “We would need a sample size of $n=68$.”
Example 4: Two-Sample CI (Independent, Equal Variances Assumed)
- Problem: Find a 95% CI for the difference in means $\mu_1 - \mu_2$.
- Given:
- Group 1: $n_1 = 12$, $\bar{x}_1 = 15.4$, $s_1 = 2.0$
- Group 2: $n_2 = 10$, $\bar{x}_2 = 13.1$, $s_2 = 1.8$
- Setup:
- Point Estimate: $\bar{x}_1 - \bar{x}_2 = 15.4 - 13.1 = 2.3$.
- Degrees of Freedom: $\nu = n_1 + n_2 - 2 = 12 + 10 - 2 = 20$.
- Critical Value: $t_{\alpha/2, \nu} = t_{0.025, 20} = 2.086$.
- Step 1 (Pooled Variance): We average the variance, weighted by df.
\(s_p^2 = \frac{(n_1-1)s_1^2 + (n_2-1)s_2^2}{n_1+n_2-2} = \frac{(11)(2.0^2) + (9)(1.8^2)}{20}\)
\(s_p^2 = \frac{44 + 29.16}{20} = \frac{73.16}{20} = 3.658 \implies s_p = \sqrt{3.658} \approx 1.913\)
- Step 2 (Standard Error):
\(SE = s_p \sqrt{\frac{1}{n_1} + \frac{1}{n_2}} = 1.913 \sqrt{\frac{1}{12} + \frac{1}{10}} = 1.913 \sqrt{0.1833...} \approx 0.820\)
- Step 3 (Margin of Error): $ME = t^* \times SE = 2.086 \times 0.820 \approx 1.711$.
- Step 4 (CI): $(\bar{x}_1 - \bar{x}_2) \pm ME \rightarrow 2.3 \pm 1.711$.
- Conclusion: The 95% CI is (0.589, 4.011).
- Interpretation: “We are 95% confident that the true difference in means, $\mu_1 - \mu_2$, is between 0.589 and 4.011. Since 0 is not in this interval, we have statistically significant evidence (at $\alpha=0.05$) that $\mu_1$ is greater than $\mu_2$.”
Example 5: Quick Checklist for Exam Answers
When writing up a hypothesis test:
- Hypotheses: State $H_0$ and $H_a$ clearly in symbols (e.g., $H_0: \mu = 100$).
- Test: State the name of the test (e.g., “one-sample t-test”).
- Significance: State the significance level $\alpha$.
- Test Statistic: Compute the test statistic (e.g., $t = 2.0$) and degrees of freedom ($\nu = 8$).
- p-value: Report the p-value (e.g., $p \approx 0.0792$).
- Decision: Make a clear decision by comparing $p$ and $\alpha$ (e.g., “Since $p=0.0792 > \alpha=0.05$, we fail to reject $H_0$”).
- Conclusion: Write a final conclusion in the context of the problem (e.g., “There is insufficient evidence…”).