Test 2 Review (Chapters 13–24)

Math 215 — Inference with Simulation and Mathematical Models

The Big Picture

Every chapter in this unit answers one of two questions about a population parameter:

  • Hypothesis test: Is the observed statistic surprising if \(H_0\) is true? → compute a p-value.
  • Confidence interval: What values of the parameter are plausible? → compute an interval estimate.

Each question can be answered two ways:

Simulation (computational) Mathematical model (theoretical)
p-value Permutation test (or parametric bootstrap) builds the null distribution Standardize the statistic (\(Z\), \(T\), \(X^2\), \(F\)) and find a tail area of a named distribution
CI Bootstrap (percentile or SE method) \(\text{point estimate} \pm \text{critical value} \times SE\)
  • Permutation test: shuffle the response values across the explanatory groups to simulate a world where \(H_0\) is true. Each shuffle gives one simulated statistic; together they form the null distribution.
  • Simulated p-value: count the simulated statistics that are as extreme as or more extreme than the observed test statistic, in the direction of \(H_A\), and divide by the number of simulations. In the permutation pictures in each chapter, these outcomes are shaded red.
    • \(H_A\) with \(>\): count values \(\geq\) the observed statistic (right tail).
    • \(H_A\) with \(<\): count values \(\leq\) the observed statistic (left tail).
    • \(H_A\) with \(\neq\): count values at least as far from the null value as the observed statistic, on either side (both tails).
  • Bootstrap: resample the original data with replacement (same size \(n\)) to simulate sampling variability. A 95% percentile CI is the 2.5th to 97.5th percentiles of the bootstrap statistics (shaded region in the bootstrap pictures); a bootstrap SE CI is \(\text{estimate} \pm 1.96 \times SE_{boot}\).
  • Permutation distributions are centered at the null value (used for p-values); bootstrap distributions are centered at the observed statistic (used for CIs).

When the technical conditions are met, the simulation and theoretical approaches give very similar answers.

Technical (validity) conditions for theoretical methods

A mathematical model is only trustworthy when its conditions hold. If they fail, use simulation instead.

Independence (every test). Observations must be independent of one another. This is reasonable when data come from a simple random sample or a randomized experiment. With two or more groups, observations must be independent within and between groups (except paired data, where the pairs are independent of each other).

Large-sample / shape conditions (depend on the statistic):

Method (Ch) Distribution Validity conditions
One proportion (16) \(N(0,1)\) Success-failure: test uses expected counts \(np_0 \geq 10\) and \(n(1-p_0) \geq 10\); CI uses observed counts \(n\hat p \geq 10\) and \(n(1-\hat p) \geq 10\)
Two proportions (17) \(N(0,1)\) At least 10 successes and 10 failures in each group (test: expected counts using \(\hat p_{pool}\); CI: observed counts)
Two-way table (18) \(\chi^2_{(r-1)(c-1)}\) At least 5 expected counts in every cell
One mean (19) \(t_{n-1}\) Normality: if \(n < 30\), no clear outliers (data look nearly normal); if \(n \geq 30\), no particularly extreme outliers
Two independent means (20) \(t_{n_1+n_2-2}\) Normality check in each group, and equal population variances for the pooled test (otherwise use the unequal-variance version)
Paired means (21) \(t_{n_{diff}-1}\) Normality check applied to the differences
Many means / ANOVA (22) \(F_{k-1,\,n-k}\) Nearly normal data within each group (no extreme outliers) and roughly equal variability across groups (most important when group sizes differ a lot)
Regression slope (24) \(t_{n-2}\) LINE: Linear relationship, Independent observations, Normal residuals, Equal (constant) variability of residuals; check with a scatterplot and residual plot

Why these matter: the CLT says the statistic’s sampling distribution is approximately normal (or \(t\), \(\chi^2\), \(F\)) only when the sample is large enough and not dominated by skew or outliers. When a condition is violated, the theoretical tail area can be noticeably wrong.

How to find p-values using theoretical models

  1. Check the technical conditions above.
  2. Compute the standardized test statistic, generally \(\dfrac{\text{statistic} - \text{null value}}{SE}\) (or \(X^2\), \(F\)).
  3. Identify the null distribution: \(N(0,1)\), \(t_{df}\), \(\chi^2_{df}\), or \(F_{df_1, df_2}\).
  4. Find the tail area beyond the observed statistic in the direction(s) of \(H_A\).

R’s p functions (pnorm, pt, pchisq, pf) return the area to the left of a value. Use 1 - p...() for a right tail. For a two-sided test with a symmetric distribution (normal or \(t\)), double the area of one tail. The code for each worked example is in its chapter.

Model \(H_A\) direction p-value R code
Normal \(>\) (right tail) \(P(Z \geq z)\) 1 - pnorm(z)
Normal \(<\) (left tail) \(P(Z \leq z)\) pnorm(z)
Normal \(\neq\) (two-sided) \(2 \cdot P(Z \geq |z|)\) 2 * pnorm(-abs(z))
\(t\) \(>\) (right tail) \(P(T_{df} \geq t)\) 1 - pt(t, df)
\(t\) \(<\) (left tail) \(P(T_{df} \leq t)\) pt(t, df)
\(t\) \(\neq\) (two-sided) \(2 \cdot P(T_{df} \geq |t|)\) 2 * pt(-abs(t), df)
\(\chi^2\) always right tail \(P(\chi^2_{df} \geq X^2)\) 1 - pchisq(X2, df)
\(F\) always right tail \(P(F_{df_1, df_2} \geq F)\) 1 - pf(F, df1, df2)

Critical values for CIs come from the same distributions: \(z^* = 1.96\) for 95% (the 97.5th percentile of \(N(0,1)\)), and \(t^*_{df}\) is the 97.5th percentile of \(t_{df}\).

Chapter 13 — Inference with Mathematical Models

Outline

  • Permutation test → null distribution, p-value, and the standard error (SD of the null distribution).
  • Central Limit Theorem (CLT): a proportion or difference in proportions is approximately normal if observations are independent and there are at least 10 successes and 10 failures in each group.
  • Normal distributions \(N(\mu, \sigma)\), \(Z\) scores, the 68–95–99.7 rule.
  • Comparing \(Z\) scores: standardizing puts values from different normal distributions on the same scale (number of SDs above or below the mean), so they can be compared directly. Example: SAT ~ \(N(1500, 300)\) and ACT ~ \(N(21, 5)\); Nel scored 1800 on the SAT (\(Z = \frac{1800-1500}{300} = 1\)) and Sian scored 24 on the ACT (\(Z = \frac{24-21}{5} = 0.6\)), so Nel performed better.
  • p-values as areas under the normal curve; confidence intervals \(\text{estimate} \pm z^* \times SE\).

Key formulas

  • \(Z\) score (how many SDs/SEs a value is from the center): \[Z = \frac{x - \mu}{\sigma}\] If \(X \sim N(\mu, \sigma)\), then \(Z \sim N(0, 1)\) (standard normal).
  • Test statistic for a difference in proportions with null value 0: \[Z = \frac{(\hat p_T - \hat p_C) - 0}{SE}\]
  • Confidence interval: \[\text{point estimate} \pm z^{*} \times SE, \qquad z^* = 1.645, \ 1.96, \ 2.576 \text{ for } 90\%, 95\%, 99\%\]
  • Margin of error \(= z^* \times SE\).

Example: opportunity cost

Problem. Does reminding students of the opportunity cost change their purchase decision? 150 students were randomly assigned: control (75) saw “buy / not buy this video”; treatment (75) also saw “keep the $14.99 for other purchases.” Success = “not buy video.”

Data: 34 of 75 treatment and 19 of 75 control students chose not to buy. \(\hat p_T - \hat p_C = \dfrac{34}{75} - \dfrac{19}{75} = 0.2\)

Hypotheses: \(H_0: p_T - p_C = 0\) (opportunity cost reminder has no effect) vs. \(H_A: p_T - p_C > 0\) (a higher proportion will not buy when reminded).

Permutation test

Permutation null distribution. Red = permuted differences at least as large as 0.2 (direction of H_A: >).
count_extreme p_value SE
12 0.012 0.0796937

Permutation null distribution. Red = permuted differences at least as large as 0.2 (direction of H_A: >).

The p-value is the proportion of permuted differences \(\geq 0.2\) (red bars): about 6 out of 1,000, so p-value ≈ 0.006. The SD of the null distribution gives \(SE \approx 0.0791\).

Normal approximation of the null distribution

The conditions hold (random assignment; at least 10 successes and failures per group), so the null distribution is approximately \(N(0, 0.0791)\).

The permutation distribution (bars) is well approximated by N(0, 0.0791) (blue curve).

Computing probabilities from a normal model. For a density curve, the area under the curve is a probability. For example, under \(N(0, 0.0791)\), \(P(X \leq -0.03) = 0.352\) and \(P(X \geq -0.03) = 1 - 0.352 = 0.648\).

Theoretical p-value

\[Z = \frac{(\hat p_T - \hat p_C) - 0}{SE} = \frac{0.2 - 0}{0.0791} = 2.528\]

Since \(H_A\) uses \(>\), the p-value is the right-tail area: \(P(Z \geq 2.528) \approx 0.006\), matching the simulation.

p-value = area under N(0,1) to the right of Z = 2.528.
1 - pnorm(2.528)                  # right tail, H_A: p_T - p_C > 0
[1] 0.005735718

68–95–99.7 rule

About 68%, 95%, and 99.7% of a normal distribution lie within 1, 2, and 3 SDs of the mean.

Since \(Z = 2.528 > 1.96\), the observed value is outside the middle 95%, so the one-sided p-value is less than 0.025.

Confidence interval

95% CI for \(p_T - p_C\): \[0.2 \pm 1.96 \times 0.0791 = 0.2 \pm 0.155 \Rightarrow (0.045, \ 0.355)\] 99% CI: \(0.2 \pm 2.576 \times 0.0791 = 0.2 \pm 0.203\). Higher confidence gives a wider interval (larger margin of error).

\(z^*\) is the cutoff with area \(1 - (1-C)/2\) to its left for a \(C\%\) CI: \(z^* = 1.645\) (90%), \(1.96\) (95%), \(2.576\) (99%).

Chapter 14 — Decision Errors

Outline

  • One-sided vs. two-sided hypotheses. Use two-sided when there is no prior expectation of direction.
  • Type 1 and Type 2 errors, significance level \(\alpha\), and power.

Key formulas

  • \(P(\text{Type 1 error} \mid H_0 \text{ true}) = \alpha\)
  • \(P(\text{Type 2 error} \mid H_A \text{ true}) = 1 - \text{Power}\)
  • Two-sided p-value for a symmetric null distribution: \(2 \times\) (one-tail area beyond \(|Z|\)).

Example: CPR and blood thinners

Problem. Do blood thinners affect 24-hour survival of heart-attack patients who received CPR? Blood thinners can treat clots but may make CPR injuries harder to heal, so there is no expected direction. 90 patients randomly assigned (cpr, openintro): 40 treatment, 50 control. Success = “survived.”

Data: 14 of 40 treatment and 11 of 50 control patients survived. \(\hat p_T - \hat p_C = \dfrac{14}{40} - \dfrac{11}{50} = 0.13\)

Hypotheses (two-sided): \(H_0: p_T - p_C = 0\) vs. \(H_A: p_T - p_C \neq 0\)

Two-sided p-value

Conditions are met, \(SE \approx 0.0955\) (details in Ch. 17), so the null distribution is \(N(0, 0.0955)\). “At least as extreme” now means \(\geq 0.13\) or \(\leq -0.13\).

\[Z = \frac{(\hat p_T - \hat p_C) - 0}{SE} = \frac{0.13 - 0}{0.0955} = 1.36\]

Two-sided p-value: both tails of N(0,1) beyond ±1.36.
2 * pnorm(-abs(1.36))             # two-sided, H_A: p_T - p_C != 0
[1] 0.1738299

The p-value is about 0.17 > \(\alpha = 0.05\), so we fail to reject \(H_0\); it is plausible survival rates are the same.

Decision errors

\(H_0\) true \(H_A\) true
Reject \(H_0\) Type 1 error (false alarm) Correct decision (power)
Fail to reject \(H_0\) Correct decision Type 2 error (missed opportunity)
  • Lowering \(\alpha\) makes Type 1 errors less likely but Type 2 errors more likely (trade-off).
  • Power \(= P(\text{reject } H_0 \mid H_A \text{ true})\). Power increases with larger effect sizes and larger samples.
  • In the CPR study we failed to reject, so the only possible error is a Type 2 error. Once a decision is made, only one type of error is possible.

Chapter 16 — Inference for a Single Proportion

Outline

  • CLT for \(\hat p\); the success-failure condition.
  • Mathematical model example (payday loans).
  • When the success-failure condition fails, use simulation instead: a parametric bootstrap (draw samples from a population with \(p = p_0\)) for the test and a bootstrap for the CI.

Key formulas

  • Sampling distribution: \(\hat p \approx N\left(p, \sqrt{\dfrac{p(1-p)}{n}}\right)\) if observations are independent and \(np \geq 10\) and \(n(1-p) \geq 10\).
  • Hypothesis test (use the null value \(p_0\)): \[SE(\hat p) = \sqrt{\frac{p_0(1-p_0)}{n}}, \qquad Z = \frac{\hat p - p_0}{\sqrt{p_0(1-p_0)/n}}\] Check \(np_0 \geq 10\) and \(n(1-p_0) \geq 10\) (expected counts).
  • Confidence interval (use \(\hat p\)): \[\hat p \pm z^* \sqrt{\frac{\hat p(1-\hat p)}{n}}\] Check observed successes and failures \(\geq 10\).

Example: payday loan regulation (mathematical model)

Problem. Do a majority of Michigan payday borrowers support a new regulation requiring lenders to do a credit check? Let \(p\) = proportion of all MI payday borrowers who support it.

Data: random sample of \(n = 826\) borrowers; 424 support. \(\hat p = 424/826 = 0.513\)

Hypotheses: \(H_0: p = 0.5\) vs. \(H_A: p > 0.5\)

Conditions: random sample (independent); expected counts \(826 \times 0.5 = 413\) successes and 413 failures, both \(\geq 10\).

\[SE(\hat p) = \sqrt{\frac{p_0(1-p_0)}{n}} = \sqrt{\frac{0.5(1-0.5)}{826}} = 0.0174\] \[Z = \frac{\hat p - p_0}{SE(\hat p)} = \frac{0.513 - 0.5}{0.0174} = 0.765\]

p-value = area under N(0,1) to the right of Z = 0.765.
1 - pnorm(0.765)                  # right tail, H_A: p > 0.5
[1] 0.2221358

p-value ≈ 0.22, so we fail to reject \(H_0\); 50% is a plausible value. (We do not “accept” \(H_0\).)

95% CI (observed counts 424 and 402 are both \(\geq 10\)): \[SE \approx \sqrt{\frac{\hat p(1-\hat p)}{n}} = \sqrt{\frac{0.513(1-0.513)}{826}} = 0.0174\] \[0.513 \pm 1.96 \times 0.0174 = 0.513 \pm 0.034 \Rightarrow (0.479, \ 0.547)\]

The CI contains 0.5, consistent with the test.

Chapter 17 — Inference for Comparing Two Proportions

Outline

  • Permutation test, then the mathematical model with a pooled proportion.
  • Bootstrap percentile CI, bootstrap SE CI, and normal-approximation CI. All three agree when conditions hold.

Key formulas

  • Sampling distribution: \(\hat p_1 - \hat p_2\) is approximately normal with mean \(p_1 - p_2\) and \[SE(\hat p_1 - \hat p_2) = \sqrt{\frac{p_1(1-p_1)}{n_1} + \frac{p_2(1-p_2)}{n_2}}\] if data are independent within and between groups and there are at least 10 (expected) successes and failures in each group.
  • Hypothesis test (assumes \(p_1 = p_2\), so pool): \[\hat p_{pool} = \frac{\text{total successes}}{\text{total cases}} = \frac{\hat p_1 n_1 + \hat p_2 n_2}{n_1 + n_2}\] \[Z = \frac{(\hat p_1 - \hat p_2) - 0}{\sqrt{\hat p_{pool}(1-\hat p_{pool})\left(\frac{1}{n_1} + \frac{1}{n_2}\right)}}\] Expected counts for the condition check: \(n_i \hat p_{pool}\) and \(n_i(1-\hat p_{pool})\).
  • Confidence interval (unpooled): \[(\hat p_1 - \hat p_2) \pm z^* \sqrt{\frac{\hat p_1(1-\hat p_1)}{n_1} + \frac{\hat p_2(1-\hat p_2)}{n_2}}\]

Example: CPR study revisited

Problem. Do blood thinners affect survival of CPR patients? (cpr; 40 treatment, 50 control, randomly assigned.)

group died survived total
control 39 11 50
treatment 26 14 40
total 65 25 90

\(\hat p_T - \hat p_C = \dfrac{14}{40} - \dfrac{11}{50} = 0.13\)

Hypotheses: \(H_0: p_T - p_C = 0\) vs. \(H_A: p_T - p_C \neq 0\)

Permutation test

Permutation null distribution for the CPR study. Red = permuted differences at least as extreme as the observed 0.13 in either direction (H_A: ≠).
count_extreme p_value
245 0.245

Permutation null distribution for the CPR study. Red = permuted differences at least as extreme as the observed 0.13 in either direction (H_A: ≠).

The p-value is the proportion of permuted differences \(\geq 0.13\) or \(\leq -0.13\) (red bars): about 0.17.

Mathematical model

Pooled proportion: \(\hat p_{pool} = \dfrac{25}{90} = 0.278\).

Conditions: randomized experiment (independent); expected successes \(40(0.278) = 11.1\) and \(50(0.278) = 13.9\); expected failures \(28.9\) and \(36.1\). All \(\geq 10\).

\[SE = \sqrt{\hat p_{pool}(1-\hat p_{pool})\left(\frac{1}{n_1}+\frac{1}{n_2}\right)} = \sqrt{0.278(0.722)\left(\frac{1}{40} + \frac{1}{50}\right)} = 0.095\] \[Z = \frac{(\hat p_T - \hat p_C) - 0}{SE} = \frac{0.13 - 0}{0.095} = 1.37\]

Two-sided p-value from N(0,1): area beyond ±1.37.
2 * pnorm(-abs(1.37))             # two-sided, H_A: p_T - p_C != 0
[1] 0.1706869

p-value ≈ 0.171, close to the permutation p-value because the success-failure condition holds. Fail to reject \(H_0\).

Confidence intervals

Bootstrap: resample with replacement within each group (40 from treatment, 50 from control) and compute the difference each time.

Bootstrap distribution of the difference in survival rates, centered near 0.13. Shaded = 95% percentile CI.
lower_ci upper_ci
-0.0543478 0.3107413

Bootstrap distribution of the difference in survival rates, centered near 0.13. Shaded = 95% percentile CI.

SE_boot
0.094442

Bootstrap distribution of the difference in survival rates, centered near 0.13. Shaded = 95% percentile CI.

Normal approximation (observed counts 14, 26, 11, 39 all \(\geq 10\)): \[SE \approx \sqrt{\frac{\hat p_T(1-\hat p_T)}{n_T}+\frac{\hat p_C(1-\hat p_C)}{n_C}} = \sqrt{\frac{0.35(0.65)}{40}+\frac{0.22(0.78)}{50}} = 0.0955\] \[0.13 \pm 1.96 \times 0.0955 \Rightarrow (-0.057, \ 0.317)\]

Method 95% CI
Bootstrap percentile (−0.055, 0.313)
Bootstrap SE (\(0.13 \pm 1.96 \times 0.0944\)) (−0.055, 0.315)
Normal approximation (\(0.13 \pm 1.96 \times 0.0955\)) (−0.057, 0.317)

All intervals contain 0, consistent with failing to reject \(H_0\).

Chapter 18 — Inference for Two-Way Tables

Outline

  • With more than two categories there are no single “successes,” so we use the chi-squared statistic \(X^2\).
  • Permutation test, then the \(\chi^2\) distribution.

Key formulas

  • Expected count (assuming independence): \[E = \frac{\text{row total} \times \text{column total}}{\text{table total}}\]
  • Chi-squared statistic: \[X^2 = \sum_{\text{all cells}} \frac{(\text{observed} - \text{expected})^2}{\text{expected}}\]
  • Model: \(X^2 \sim \chi^2_{df}\) with \(df = (r-1)(c-1)\) if observations are independent and each cell has at least 5 expected counts.
  • p-value is always the right tail (large \(X^2\) = observed far from expected).

χ² distributions are right-skewed; larger df shifts the curve right and thickens the tail.

Example: military spending

Problem. Do people of different U.S. political parties have different views on government spending on national defense? 2016 General Social Survey, 149 respondents; party (Dem/Ind/Rep) vs. natarms (too little / about right / too much).

Hypotheses: \(H_0\): party and opinion on military spending are independent (no association). \(H_A\): party and opinion are associated.

Observed and expected counts

Observed counts with expected counts in parentheses:

Party TOO LITTLE ABOUT RIGHT TOO MUCH Total
Dem 17 (17.60) 14 (14.43) 12 (10.97) 43
Ind 20 (29.48) 28 (24.16) 24 (18.36) 72
Rep 24 (13.92) 8 (11.41) 2 (8.67) 34
Total 61 50 38 149

Example: \(E_{\text{Dem, too little}} = \dfrac{43 \times 61}{149} = 17.60\).

\[X^2 = \sum \frac{(O - E)^2}{E} = \frac{(17-17.60)^2}{17.60} + \cdots + \frac{(2-8.67)^2}{8.67}\] \[X^2 = 0.02 + 0.01 + 0.10 + 3.05 + 0.61 + 1.73 + 7.30 + 1.02 + 5.13 = 18.97\]

     
      TOO LITTLE ABOUT RIGHT TOO MUCH
  Dem      17.60       14.43    10.97
  Ind      29.48       24.16    18.36
  Rep      13.92       11.41     8.67
X-squared 
 18.96998 

Permutation test

Shuffle the opinions across respondents and recompute \(X^2\) each time.

Permutation null distribution of X². Red = shuffled X² at least as large as 18.97 (right tail); there are none.
count_extreme p_value
0 0

Permutation null distribution of X². Red = shuffled X² at least as large as 18.97 (right tail); there are none.

No shuffled \(X^2\) values are \(\geq 18.97\), so the p-value ≈ 0. The null distribution is right-skewed and never negative.

Mathematical model: \(\chi^2\) distribution

Conditions: representative random sample (independent); all expected counts \(\geq 5\). \(df = (r-1)(c-1) = (3-1)(3-1) = 4\).

Permutation null distribution (bars) and the χ² distribution with df = 4 (blue curve).
1 - pchisq(18.97, df = 4)         # right tail of chi-squared, df = 4
[1] 0.0007966825

p-value < 0.001: reject \(H_0\). Strong evidence that opinion on military spending and party are associated. Representative sample → can generalize; observational → no cause-and-effect.

Chapter 19 — Inference for a Single Mean

Outline

  • Standard deviation of data (\(s\)) vs. standard error of the mean (\(SE\)).
  • Bootstrap SE and percentile CIs; CLT for means; the \(t\)-distribution; one-sample \(t\)-interval and \(t\)-test.

Key formulas

  • CLT: \(\bar x \approx N\left(\mu, \dfrac{\sigma}{\sqrt n}\right)\) if observations are independent and the normality condition holds (\(n < 30\): no clear outliers; \(n \geq 30\): no particularly extreme outliers).
  • Estimated SE: \(SE = \dfrac{s}{\sqrt n}\).
  • Test statistic: \[T = \frac{\bar x - \mu_0}{s/\sqrt n}, \qquad df = n - 1\]
  • One-sample \(t\)-interval: \[\bar x \pm t^*_{df} \times \frac{s}{\sqrt n}\]
  • The \(t\)-distribution has thicker tails than \(N(0,1)\) (extra uncertainty from estimating \(\sigma\) with \(s\)); it approaches the normal as \(df\) grows.

Example: Cherry Blossom 10-mile run

Problem. The mean finishing time in 2006 was 93.29 minutes. Has the mean finishing time changed in 2017? Let \(\mu\) = mean 2017 finish time.

Data: random sample of \(n = 100\) runners from 2017 (run17, cherryblossom). \(\bar x = 99.02\) min, \(s = 17.93\) min.

Hypotheses: \(H_0: \mu = 93.29\) vs. \(H_A: \mu \neq 93.29\)

Bootstrap CI for the mean

1,000 bootstrap sample means. Shaded = 95% percentile CI. Their spread (SE ≈ 1.8) is much smaller than the spread of the raw data (s ≈ 17.9).
lower_ci upper_ci
95.53098 102.5462

1,000 bootstrap sample means. Shaded = 95% percentile CI. Their spread (SE ≈ 1.8) is much smaller than the spread of the raw data (s ≈ 17.9).

SE_boot
1.776952

1,000 bootstrap sample means. Shaded = 95% percentile CI. Their spread (SE ≈ 1.8) is much smaller than the spread of the raw data (s ≈ 17.9).

Bootstrap SE CI: \(\bar x \pm 1.96 \times SE_{boot} = 99.02 \pm 1.96(1.78) = (95.51, \ 102.49)\).

Simulation test (shifted bootstrap)

For a single mean there are no groups to shuffle, so the data are shifted to have mean 93.29 (making \(H_0\) true) and then bootstrapped.

Null distribution centered at 93.29. Red = simulated means at least as far from 93.29 as the observed 99.02, in either direction (H_A: ≠).
count_extreme p_value
1 0.001

Null distribution centered at 93.29. Red = simulated means at least as far from 93.29 as the observed 99.02, in either direction (H_A: ≠).

One-sample \(t\)-test

Conditions: random sample (independent); \(n = 100 \geq 30\) with no particularly extreme outliers.

\[T = \frac{\bar x - \mu_0}{s/\sqrt n} = \frac{99.02 - 93.29}{17.93/\sqrt{100}} = \frac{5.73}{1.793} = 3.20, \qquad df = 100 - 1 = 99\]

Two-sided p-value: area of t(99) beyond ±3.20.
2 * pt(-abs(3.20), df = 99)       # two-sided, H_A: mu != 93.29
[1] 0.001847065

p-value ≈ 0.002 < 0.05: reject \(H_0\). The 2017 mean finish time differs from 93.29 (it is higher; runners got slower).

One-sample \(t\)-interval

\[\bar x \pm t^*_{99} \times \frac{s}{\sqrt n} = 99.02 \pm 1.98 \times \frac{17.93}{\sqrt{100}} \Rightarrow (95.46, \ 102.56)\]

Method 95% CI
One-sample \(t\)-interval (95.46, 102.56)
Bootstrap SE (95.51, 102.49)
Bootstrap percentile (95.53, 102.55)

93.29 is outside every interval, consistent with rejecting \(H_0\) at \(\alpha = 0.05\).

t-distributions have thicker tails than the standard normal; they approach N(0,1) as df increases.

Chapter 20 — Inference for Comparing Two Independent Means

Outline

  • Permutation test; pooled two-sample \(t\)-test; relaxing the equal-variance assumption; bootstrap and \(t\) CIs.

Key formulas

  • Pooled SD (equal variances assumed): \[s_p = \sqrt{\frac{(n_1 - 1)s_1^2 + (n_2 - 1)s_2^2}{n_1 + n_2 - 2}}\]
  • Standard error: \[SE = s_p\sqrt{\frac{1}{n_1} + \frac{1}{n_2}}\]
  • Test statistic: \[T = \frac{(\bar x_1 - \bar x_2) - 0}{s_p\sqrt{\frac{1}{n_1} + \frac{1}{n_2}}}, \qquad df = n_1 + n_2 - 2\]
  • CI: \[(\bar x_1 - \bar x_2) \pm t^*_{df} \times s_p\sqrt{\frac{1}{n_1} + \frac{1}{n_2}}\]
  • Conditions: equal population variances, independence within and between groups, normality (large samples, no extreme outliers). Without equal variances, an unpooled version uses an approximate \(t\) with a non-integer \(df\).

Example: birth weights and smoking

Problem. Do babies of mothers who smoke have a different mean birth weight than babies of mothers who don’t? Let \(\mu_n\) and \(\mu_s\) be mean birth weights (lb) for nonsmoking and smoking mothers.

Data: random sample of 981 U.S. births in 2014 (births14).

habit \(n\) mean sd
nonsmoker 867 7.27 1.23
smoker 114 6.68 1.60

\(\bar x_n - \bar x_s = 7.27 - 6.68 = 0.59\) lb

Hypotheses: \(H_0: \mu_n - \mu_s = 0\) vs. \(H_A: \mu_n - \mu_s \neq 0\)

Permutation test

Permutation null distribution of the difference in means. Red = permuted differences at least as extreme as ±0.59 (H_A: ≠); none are, so nothing is shaded.
count_extreme p_value
0 0

Permutation null distribution of the difference in means. Red = permuted differences at least as extreme as ±0.59 (H_A: ≠); none are, so nothing is shaded.

No permuted differences are as extreme as 0.59, so the p-value ≈ 0.

Two-sample \(t\)-test

Conditions: random sample (independent within and between groups); large samples with no extreme outliers; SDs 1.23 and 1.60 are reasonably similar.

\[s_p = \sqrt{\frac{(n_n-1)s_n^2 + (n_s-1)s_s^2}{n_n+n_s-2}} = \sqrt{\frac{866(1.23^2) + 113(1.60^2)}{979}} = 1.28\] \[T = \frac{(\bar x_n - \bar x_s) - 0}{s_p\sqrt{\frac{1}{n_n}+\frac{1}{n_s}}} = \frac{0.59}{1.28\sqrt{\frac{1}{867} + \frac{1}{114}}} = 4.63, \qquad df = 867 + 114 - 2 = 979\]

t(979) curve; the red tails beyond ±4.63 are so small they are barely visible.
2 * pt(-abs(4.63), df = 979)      # two-sided, H_A: mu_n - mu_s != 0
[1] 4.148965e-06

p-value < 0.001: reject \(H_0\). Strong evidence that mean birth weights differ.

Confidence intervals

Bootstrap distribution of the difference in means (resampling within each group). Shaded = 95% percentile CI, which does not contain 0.
lower_ci upper_ci
0.3106516 0.8989899

Bootstrap distribution of the difference in means (resampling within each group). Shaded = 95% percentile CI, which does not contain 0.

\(t\)-interval: \[SE = s_p\sqrt{\frac{1}{n_n}+\frac{1}{n_s}} = 1.28\sqrt{\frac{1}{867} + \frac{1}{114}} = 0.128\] \[0.59 \pm t^*_{979} \times 0.128 = 0.59 \pm 1.96(0.128) \Rightarrow (0.339, \ 0.841)\]

Bootstrap percentile ≈ (0.31, 0.92). Zero is not in either interval, consistent with the test.

Chapter 21 — Inference for Comparing Paired Means

Outline

  • Paired designs: repeated measures (same subject twice) or matching (similar subjects). Analyzing the difference within each pair removes subject-to-subject variability → narrower CIs and more power.
  • Paired data reduce to a one-sample problem on the differences (Ch. 19 methods).

Key formulas

\[\bar x_{diff} = \text{mean of the differences}, \qquad SE_{diff} = \frac{s_{diff}}{\sqrt{n_{diff}}}\] \[T = \frac{\bar x_{diff} - 0}{s_{diff}/\sqrt{n_{diff}}}, \qquad df = n_{diff} - 1\] \[\text{CI: } \bar x_{diff} \pm t^*_{df} \times SE_{diff}\]

Example: textbook prices

Problem. Do you save money buying textbooks on Amazon instead of the UCLA bookstore? Each book has two prices, so the data are paired. Difference = UCLA bookstore price − Amazon price. Let \(\mu_{diff}\) = mean price difference.

Data: 68 books (ucla_textbooks_f18). \(\bar x_{diff} = 3.58\), \(s_{diff} = 13.4\), median 0.625.

Hypotheses: \(H_0: \mu_{diff} = 0\) vs. \(H_A: \mu_{diff} \neq 0\)

Permutation test for paired data

Under \(H_0\) the “UCLA” and “Amazon” labels are interchangeable within a book. Each permutation flips a coin for each book: keep the prices, or swap them (which flips the sign of that book’s difference).

Null distribution of the mean difference from 1,000 within-pair permutations. Red = means at least as extreme as ±3.58 (H_A: ≠).
count_extreme p_value
17 0.017

Null distribution of the mean difference from 1,000 within-pair permutations. Red = means at least as extreme as ±3.58 (H_A: ≠).

The p-value is the proportion of permuted means \(\geq 3.58\) or \(\leq -3.58\) (red bars).

Bootstrap CI

Resample the 68 differences with replacement.

Bootstrap distribution of the mean price difference. Shaded = 95% percentile CI.
lower_ci upper_ci
0.4706287 6.934684

Bootstrap distribution of the mean price difference. Shaded = 95% percentile CI.

SE_boot
1.658731

Bootstrap distribution of the mean price difference. Shaded = 95% percentile CI.

Percentile CI ≈ ($0.81, $7.05); bootstrap SE CI: \(3.58 \pm 1.96(1.63) \approx\) ($0.39, $6.77).

Mathematical model

Conditions: books are independent of each other; \(n_{diff} = 68 \geq 30\), and although the differences are skewed, there are no particularly extreme outliers.

\[SE_{diff} = \frac{s_{diff}}{\sqrt{n_{diff}}} = \frac{13.4}{\sqrt{68}} = 1.62\] \[T = \frac{\bar x_{diff} - 0}{SE_{diff}} = \frac{3.58 - 0}{1.62} = 2.20, \qquad df = 68 - 1 = 67\]

Two-sided p-value: area of t(67) beyond ±2.20.
2 * pt(-abs(2.20), df = 67)       # two-sided, H_A: mu_diff != 0
[1] 0.03125996

p-value ≈ 0.031 < 0.05: reject \(H_0\); on average, UCLA bookstore prices are higher than Amazon’s.

95% CI: \(\bar x_{diff} \pm t^*_{67} \times SE_{diff} = 3.58 \pm 1.996(1.62) \Rightarrow (\$0.35, \ \$6.81)\), which excludes 0.

Chapter 22 — Inference for Comparing Many Means (ANOVA)

Outline

  • Why not many pairwise \(t\)-tests? Type 1 errors pile up: \(P(\text{at least one Type 1 error in } m \text{ tests}) = 1 - (1-\alpha)^m\); for 6 tests, \(1 - 0.95^6 = 0.265\).
  • One holistic test using the F statistic, via permutation or the \(F\)-distribution. Rejecting \(H_0\) does not say which means differ (that needs post-hoc tests with Type 1 error control).

Key formulas (\(k\) groups, \(n\) total observations)

Quantity Formula
Mean squares \(MSG = \dfrac{SSG}{k-1}, \quad MSE = \dfrac{SSE}{n-k}\)
F statistic \(F = \dfrac{MSG}{MSE} = \dfrac{\text{variability between groups}}{\text{variability within groups}}\)

Model: \(F \sim F_{k-1, \, n-k}\) if observations are independent, data are nearly normal within groups (no extreme outliers), and variances are roughly equal. The p-value is always the right tail (large \(F\) = group means far apart relative to within-group spread).

Example: vocabulary scores by social class

Problem. Do scores on a 10-question vocabulary test (Wordsum, 0–10) differ between self-identified social classes? Let \(\mu_L, \mu_M, \mu_U, \mu_W\) be the mean scores for Lower, Middle, Upper, and Working class.

Data: 795 GSS respondents.

class \(n\) mean sd
LOWER 41 5.07 2.24
MIDDLE 331 6.76 1.89
UPPER 16 6.19 2.34
WORKING 407 5.75 1.87

Hypotheses: \(H_0: \mu_L = \mu_M = \mu_U = \mu_W\) vs. \(H_A\): at least one mean is different.

Computing \(F\)

ANOVA table for Wordsum score by social class (\(k = 4\) groups, \(n = 795\)):

Source df Sum of squares Mean square F p-value
class (groups) \(df_G = k - 1 = 3\) \(SSG = 236.56\) \(MSG = 78.85\) \(21.73\) \(< 0.001\)
Residuals (error) \(df_E = n - k = 791\) \(SSE = 2869.80\) \(MSE = 3.628\)

From the table:

\[MSG = \frac{SSG}{df_G} = \frac{236.56}{3} = 78.85\] \[MSE = \frac{SSE}{df_E} = \frac{2869.80}{791} = 3.628\] \[F = \frac{MSG}{MSE} = \frac{78.85}{3.628} = 21.73\]

Permutation test

Shuffle the Wordsum scores across respondents and recompute \(F\).

Null distribution of F from 1,000 shuffles. Red = shuffled F at least as large as the observed 21.73 (right tail); there are none.
count_extreme p_value
0 0

Null distribution of F from 1,000 shuffles. Red = shuffled F at least as large as the observed 21.73 (right tail); there are none.

No shuffled \(F\) values are \(\geq 21.73\), so the p-value ≈ 0/1000 = 0.

Mathematical model: \(F\)-distribution

Conditions: GSS uses random sampling (independent); distributions are approximately normal; SDs (1.87 to 2.34) are roughly equal, which matters here because group sizes differ a lot. \(df_G = k - 1 = 3\), \(df_E = n - k = 791\).

Permutation F statistics (bars) with the F(3, 791) density (blue).
1 - pf(21.73, df1 = 3, df2 = 791) # right tail of F(3, 791)
[1] 1.569855e-13

p-value < 0.001: reject \(H_0\); at least one social class has a different mean Wordsum score. This analysis does not tell us which classes differ; see the post-hoc tests in the next section.

Chapter 22 (continued) — Post-Hoc Tests and Multiple Comparisons

Outline

  • After an ANOVA (or \(\chi^2\) test) rejects \(H_0\), we follow up with post-hoc pairwise comparisons to find which groups differ.
  • With \(k\) groups there are \(m = \binom{k}{2} = \dfrac{k(k-1)}{2}\) pairwise comparisons.
  • Doing many tests inflates the chance of a Type 1 error, so we control the familywise error rate (FWE) with Bonferroni or Tukey methods.
  • The same ideas apply to comparing several proportions after a \(\chi^2\) test.

Key formulas

  • Number of pairwise comparisons: \[m = \binom{k}{2} = \frac{k(k-1)}{2}\]
  • Probability of at least one Type 1 error in \(m\) independent tests at level \(\alpha\) (all \(H_0\) true): \[1 - (1-\alpha)^m\]
  • Familywise error rate (FWE): probability of making at least one Type 1 error among all the tests. Multiple comparison methods keep \(FWE \leq \alpha\).
  • Bonferroni method: test each comparison at level \(\alpha/m\). Because \[P(E_1 \text{ or } \cdots \text{ or } E_m) \leq P(E_1) + \cdots + P(E_m)\] where \(E_i\) = Type 1 error on test \(i\), \[FWE \leq \frac{\alpha}{m} + \cdots + \frac{\alpha}{m} = m \cdot \frac{\alpha}{m} = \alpha\] Equivalently, the adjusted p-value is \(\min(1, \ m \times \text{p-value})\), compared to the original \(\alpha\).
  • Bonferroni CIs: use confidence level \(100(1 - \alpha/m)\%\) for each of the \(m\) intervals (e.g., \(100(1 - 0.05/6) = 99.17\%\) for 6 comparisons).
  • Tukey procedure (pairwise comparisons of means only): gives simultaneous CIs for every difference \(\mu_i - \mu_j\). A difference is significant when its interval does not contain 0.

Example: Wordsum scores by social class (follow-up)

Problem. The ANOVA in Chapter 22 gave convincing evidence (\(F_{3,791} = 21.73\), p-value < 0.001) that at least one social class has a different mean Wordsum score. Which classes differ?

Number of comparisons: \(k = 4\) classes, so \(m = \dfrac{4 \cdot 3}{2} = 6\).

Hypotheses (one pair for each comparison):

  • \(H_0: \mu_L - \mu_M = 0\) vs. \(H_A: \mu_L - \mu_M \neq 0\)
  • \(H_0: \mu_L - \mu_U = 0\) vs. \(H_A: \mu_L - \mu_U \neq 0\)
  • \(H_0: \mu_L - \mu_W = 0\) vs. \(H_A: \mu_L - \mu_W \neq 0\)
  • \(H_0: \mu_M - \mu_U = 0\) vs. \(H_A: \mu_M - \mu_U \neq 0\)
  • \(H_0: \mu_M - \mu_W = 0\) vs. \(H_A: \mu_M - \mu_W \neq 0\)
  • \(H_0: \mu_U - \mu_W = 0\) vs. \(H_A: \mu_U - \mu_W \neq 0\)

Why adjust? If all six null hypotheses are true and each test uses \(\alpha = 0.05\): \[P(\text{at least one Type 1 error}) = 1 - (1 - 0.05)^6 = 1 - 0.95^6 = 0.265\]

Unadjusted pairwise \(t\)-tests

pairwise.t.test uses the SD pooled across all groups.

with(gss_w, pairwise.t.test(wordsum, class, p.adjust.method = "none"))

    Pairwise comparisons using t tests with pooled SD 

data:  wordsum and class 

        LOWER   MIDDLE  UPPER
MIDDLE  1.1e-07 -       -    
UPPER   0.048   0.240   -    
WORKING 0.031   1.6e-12 0.367

P value adjustment method: none 
LOWER MIDDLE UPPER
MIDDLE 1.1e-07 – –
UPPER 0.048 0.240 –
WORKING 0.031 1.6e-12 0.367

At \(\alpha = 0.05\) these look significant for Middle–Lower, Upper–Lower, Working–Lower, and Working–Middle. But unadjusted p-values ignore the inflated Type 1 error rate.

Bonferroni adjustment

Each test uses level \(\alpha/m = 0.05/6 = 0.00833\). Equivalently, multiply each p-value by 6 and compare to 0.05 (e.g., Upper–Lower: \(6 \times 0.048 = 0.29\)).

with(gss_w, pairwise.t.test(wordsum, class, p.adjust.method = "bonferroni"))

    Pairwise comparisons using t tests with pooled SD 

data:  wordsum and class 

        LOWER   MIDDLE  UPPER
MIDDLE  6.8e-07 -       -    
UPPER   0.29    1.00    -    
WORKING 0.18    9.8e-12 1.00 

P value adjustment method: bonferroni 

After adjustment, only Middle–Lower and Middle–Working are significant. Bonferroni is very conservative (FWE usually well below \(\alpha\), so power is lost).

Tukey procedure

Tukey 95% simultaneous confidence intervals for each difference in means. A difference is significant when its interval does not contain 0.

Comparison Difference Lower 95% Upper 95% Adjusted p-value Contains 0?
MIDDLE-LOWER 1.688 0.876 2.500 7.00e-07 No (significant)
UPPER-LOWER 1.114 -0.331 2.560 1.95e-01 Yes
WORKING-LOWER 0.676 -0.127 1.480 1.34e-01 Yes
UPPER-MIDDLE -0.574 -1.829 0.681 6.42e-01 Yes
WORKING-MIDDLE -1.012 -1.375 -0.649 0.00e+00 No (significant)
WORKING-UPPER -0.438 -1.688 0.812 8.04e-01 Yes

Tukey 95% simultaneous confidence intervals for pairwise differences. Intervals that do not cross 0 (dashed line) indicate significant differences.

Conclusion. Tukey and Bonferroni agree (the unadjusted p-values do not): convincing evidence that mean scores differ between Middle and Lower and between Middle and Working classes. We cannot reject the other null hypotheses; for example, it is plausible that Upper and Lower classes have the same mean score.

Chapter 23 — Applications: Inference for Means

(No notes file for this chapter was in the folder.) Use this decision guide for numerical responses:

Situation Statistic Simulation Mathematical model
One sample of numbers \(\bar x\) Bootstrap (CI), shifted bootstrap (test) \(t_{n-1}\)
Two independent groups \(\bar x_1 - \bar x_2\) Permute group labels (test), bootstrap within groups (CI) \(t_{n_1 + n_2 - 2}\) (pooled)
Two measurements on the same unit \(\bar x_{diff}\) Permute within pairs / sign flips (test), bootstrap differences (CI) \(t_{n_{diff}-1}\)
Three or more groups \(F\) Permute group labels (test) \(F_{k-1,\,n-k}\)

Ask: Is the data paired? How many groups? Are conditions (independence, normality/outliers, equal variance) reasonable?

Chapter 24 — Inference for Linear Regression with a Single Predictor

Outline

  • The slope \(b_1\) varies from sample to sample. Inference targets the population slope \(\beta_1\).
  • Test \(H_0: \beta_1 = 0\) (no linear relationship) by permutation or the \(t\)-distribution; CI by bootstrap or \(t\).
  • Conditions (LINE): Linearity, Independent observations, Normality of residuals, Equal (constant) variability. Check with a residual plot.

Key formulas

  • Fitted line: \(\hat y = b_0 + b_1 x\) (estimates of \(\beta_0, \beta_1\)).
  • Residual standard deviation: \(s = \sqrt{\dfrac{SSE}{n-2}} = \sqrt{\dfrac{\sum (y_i - \hat y_i)^2}{n-2}}\)
  • Standard error of the slope: \(SE_{b_1} = \dfrac{s}{\sqrt{\sum (x_i - \bar x)^2}}\) (read it from regression output).
  • Test statistic: \[T = \frac{b_1 - \beta_{1,0}}{SE_{b_1}}, \qquad df = n - 2\] where \(\beta_{1,0}\) is the null value (usually 0).
  • CI: \[b_1 \pm t^*_{n-2} \times SE_{b_1}\]

Sampling variability of the slope

bdims (openintro): body measurements of 507 physically active adults. Population line: \(\widehat{\text{Weight}} = -105.01 + 1.02 \times \text{Height}\).

Least squares lines from 100 random samples of 20 people from bdims. The slope changes from sample to sample.

Example: weight vs. height (bdims)

Problem. Is body weight linearly associated with height? Data: 507 adults (bdims). Let \(\beta_1\) = population slope of weight (kg) on height (cm).

Hypotheses: \(H_0: \beta_1 = 0\) vs. \(H_A: \beta_1 \neq 0\)

Mathematical model

From the least squares fit, \(b_1 \approx 1.02\) kg per cm. The test statistic is \(T = \dfrac{b_1 - 0}{SE_{b_1}}\) with \(df = 507 - 2 = 505\), and the p-value is the two-sided tail area of \(t_{505}\).

Residual plot: look for no pattern (linearity) and even spread (constant variability).
2 * pt(-abs(T), df = 505)         # two-sided, H_A: beta_1 != 0
[1] 2.8291e-81

Permutation test for the slope

Shuffle the response (\(y\)) values to break any link with \(x\), then refit the line.

Null distribution of slopes from 1,000 shuffles of weight. Red = slopes at least as extreme as the observed slope in either direction; none are, so the p-value ≈ 0.
count_extreme p_value
0 0

Null distribution of slopes from 1,000 shuffles of weight. Red = slopes at least as extreme as the observed slope in either direction; none are, so the p-value ≈ 0.

Bootstrap CI for the slope

Resample (x, y) pairs with replacement and refit.

Bootstrap distribution of the slope. Shaded = 95% percentile CI.
lower_ci upper_ci
0.9380495 1.101884

Bootstrap distribution of the slope. Shaded = 95% percentile CI.

Summary: Formula Sheet

Ch Parameter Standard error Test statistic/Standardized Score/CI
16 \(p\) Test: \(\sqrt{p_0(1-p_0)/n}\); CI: \(\sqrt{\hat p(1-\hat p)/n}\) Statistic: \(\hat p\)
Standardized: \(Z = \dfrac{\hat p - p_0}{\sqrt{p_0(1-p_0)/n}}\)
CI: \(\hat p \pm z^* \sqrt{\dfrac{\hat p(1-\hat p)}{n}}\)
17 \(p_1 - p_2\) Test: \(\sqrt{\hat p_{pool}(1-\hat p_{pool})(\frac{1}{n_1}+\frac{1}{n_2})}\); CI: unpooled Statistic: \(\hat p_1 - \hat p_2\)
Standardized: \(Z = \dfrac{(\hat p_1 - \hat p_2) - 0}{\sqrt{\hat p_{pool}(1-\hat p_{pool})\left(\frac{1}{n_1}+\frac{1}{n_2}\right)}}\)
CI: \((\hat p_1 - \hat p_2) \pm z^* \sqrt{\dfrac{\hat p_1(1-\hat p_1)}{n_1}+\dfrac{\hat p_2(1-\hat p_2)}{n_2}}\)
18 association — \(df = (r-1)(c-1)\)
Statistic: \(X^2 = \sum \dfrac{(O-E)^2}{E}\), with \(E = \dfrac{\text{row total} \times \text{col total}}{\text{table total}}\)
Standardized: —
CI: —
19 \(\mu\) \(s/\sqrt n\) \(df = n - 1\)
Statistic: \(\bar x\)
Standardized: \(T = \dfrac{\bar x - \mu_0}{s/\sqrt n}\)
CI: \(\bar x \pm t^*_{df} \dfrac{s}{\sqrt n}\)
20 \(\mu_1 - \mu_2\) \(s_p\sqrt{\frac{1}{n_1}+\frac{1}{n_2}}\), \(s_p = \sqrt{\frac{(n_1-1)s_1^2 + (n_2-1)s_2^2}{df}}\) \(df = n_1 + n_2 - 2\)
Statistic: \(\bar x_1 - \bar x_2\)
Standardized: \(T = \dfrac{(\bar x_1 - \bar x_2) - 0}{s_p\sqrt{\frac{1}{n_1}+\frac{1}{n_2}}}\)
CI: \((\bar x_1 - \bar x_2) \pm t^*_{df}\, s_p\sqrt{\dfrac{1}{n_1}+\dfrac{1}{n_2}}\)
21 \(\mu_{diff}\) \(s_{diff}/\sqrt{n_{diff}}\) \(df = n_{diff} - 1\)
Statistic: \(\bar x_{diff}\)
Standardized: \(T = \dfrac{\bar x_{diff} - 0}{s_{diff}/\sqrt{n_{diff}}}\)
CI: \(\bar x_{diff} \pm t^*_{df} \dfrac{s_{diff}}{\sqrt{n_{diff}}}\)
22 all \(\mu_i\) equal — \(df_G = k - 1\), \(df_E = n - k\)
Statistic: \(F = \dfrac{MSG}{MSE}\), with \(MSG = \dfrac{SSG}{df_G}\), \(MSE = \dfrac{SSE}{df_E}\)
Standardized: —
CI: — (pairwise CIs via Tukey or Bonferroni)
24 \(\beta_1\) \(SE_{b_1} = \dfrac{s}{\sqrt{\sum(x_i - \bar x)^2}}\) \(df = n - 2\)
Statistic: \(b_1\)
Standardized: \(T = \dfrac{b_1 - 0}{SE_{b_1}}\)
CI: \(b_1 \pm t^*_{df}\, SE_{b_1}\)

Multiple comparisons (after ANOVA or a \(\chi^2\) test): \(m = k(k-1)/2\) pairs; \(P(\text{at least one Type 1 error}) = 1-(1-\alpha)^m\); Bonferroni level \(\alpha/m\) (adjusted p-value \(= m \times\) p-value); Bonferroni CI level \(100(1-\alpha/m)\%\); Tukey CIs excluding 0 indicate significant differences.

Simulation methods:

Goal Simulation Centered at
Test, one proportion Draw samples from a population with \(p = p_0\) (parametric bootstrap) \(p_0\)
Test, one mean Shift data to mean \(\mu_0\), then bootstrap \(\mu_0\)
Test, two groups / two-way table / ANOVA / slope Permute (shuffle) the response null value
Test, paired Permute within pairs (flip signs of differences) 0
CI (any) Bootstrap (resample with replacement) observed statistic

Simulated p-value: count the simulated statistics as extreme as or more extreme than the observed statistic in the direction of \(H_A\), divided by the number of simulations (shown in red in the pictures). Bootstrap CI: middle 95% of bootstrap statistics (percentile method) or \(\text{estimate} \pm 1.96 \times SE_{boot}\) (SE method).