Standard normal curve

Critical values at common levels
◆ The Blueprint
Where the critical value comes from

The middle \(C\) of the curve lies between \(-z^*\) and \(z^*\), and each tail outside it has area \(\alpha/2\). The area to the left of \(z^*\) is therefore \(C + \alpha/2 = 1 - \alpha/2\). R's qnorm(p) and qt(p, df) return the value with area \(p\) to its left.

$$\text{CI} = \text{Estimate} \pm \underbrace{z^* \times SE}_{\text{margin of error}}, \qquad z^* = \texttt{qnorm}(1 - \alpha/2)$$

The course textbook (Tintle et al.) calls the critical value the multiplier \(M\). The course sheets also write it as \(Z_{\alpha/2}\) and \(t_{\alpha/2,\,df}\).

Why t has heavier tails

For a mean, the standardized statistic is \(t = (\bar{x} - \mu)/(s/\sqrt{n})\). Its denominator uses \(s\), which changes from sample to sample, so \(t\) varies more than \(z = (\bar{x} - \mu)/(\sigma/\sqrt{n})\). When the population is normal, \(t\) follows a t distribution with \(n - 1\) degrees of freedom. As \(n\) grows, \(s\) comes close to \(\sigma\), and the t distribution approaches the standard normal: 1.645, 1.960, and 2.576 are the limits of \(t^*\) at 90%, 95%, and 99%.

The R printout

print() shows 7 significant digits, so qnorm(0.975) prints 1.959964. Critical values here are rounded to 4 decimals, 1.9600, and every interval uses the unrounded value.

Sampling distribution

Simulated intervals

◆ The Blueprint
The standard error of \(\hat{p}\)

A count of successes in \(n\) independent trials has variance \(n\pi(1-\pi)\), so \(\hat{p} = k/n\) has variance \(\pi(1-\pi)/n\). The interval does not know \(\pi\), so it puts \(\hat{p}\) in its place.

$$SE = \sqrt{\frac{\hat{p}(1-\hat{p})}{n}}, \qquad \hat{p} \pm z^* \times SE$$
Interval and test

A test of \(H_0: \pi = \pi_0\) assumes \(H_0\) is true, so its standard deviation uses \(\pi_0\): \(\sqrt{\pi_0(1-\pi_0)/n}\). An interval has no null value and uses \(\hat{p}\). A 95% interval contains approximately the values of \(\pi_0\) that a two-sided test would not reject at \(\alpha = 0.05\); the match is approximate because the two standard errors differ.

Validity conditions

At least 10 successes and 10 failures: \(n\hat{p} \ge 10\) and \(n(1-\hat{p}) \ge 10\). With fewer, the normal curve describes \(\hat{p}\) poorly, and a 95% interval contains \(\pi\) less than 95% of the time.

The coverage simulation

The simulation treats the observed \(\hat{p}\) as the true \(\pi\). Each simulated sample draws a count \(k^*\) from a binomial distribution with \(n\) trials and success probability \(\hat{p}\), computes its own \(\hat{p}^* = k^*/n\) and standard error, and builds an interval with the same \(z^*\).

Sampling distribution

Simulated intervals

◆ The Blueprint
The standard error of \(\bar{x}\)

The mean of \(n\) independent values with standard deviation \(\sigma\) has standard deviation \(\sigma/\sqrt{n}\). The interval estimates \(\sigma\) with \(s\).

$$SE = \frac{s}{\sqrt{n}}, \qquad \bar{x} \pm t^* \times SE, \qquad df = n - 1$$
Why t

When the population is normal, \((\bar{x} - \mu)/(s/\sqrt{n})\) follows a t distribution with \(n - 1\) degrees of freedom. The extra spread comes from \(s\), which varies from sample to sample. As \(n\) grows, \(t^*\) approaches \(z^*\).

Validity conditions

At least 20 observations, or a sample that is roughly symmetric without strong outliers. The course textbook (Tintle et al.) uses \(n \ge 20\); the traditional rule from the Central Limit Theorem uses \(n \ge 30\).

Interval and test

A 95% t interval contains exactly the values of \(\mu_0\) that a two-sided one-sample t-test would not reject at \(\alpha = 0.05\).

The coverage simulation

Each simulated sample draws \(n\) values from a normal population with mean \(\bar{x}\) and standard deviation \(s\), computes its own mean and standard deviation, and builds an interval with the same \(t^*\). The true mean is set to the observed \(\bar{x}\).

Sampling distribution

Simulated intervals

◆ The Blueprint
The standard error of a difference

The two samples are independent, so the variance of \(\hat{p}_1 - \hat{p}_2\) is the sum of the two variances.

$$SE = \sqrt{\frac{\hat{p}_1(1-\hat{p}_1)}{n_1} + \frac{\hat{p}_2(1-\hat{p}_2)}{n_2}}, \qquad (\hat{p}_1 - \hat{p}_2) \pm z^* \times SE$$
Pooled for tests, unpooled for intervals

The two-proportion test assumes \(H_0: \pi_1 = \pi_2\) is true, so it pools both groups into one proportion for its standard deviation. An interval makes no such assumption and uses each group's own \(\hat{p}\).

Validity conditions

Each group needs at least 10 successes and 10 failures: \(n_1\hat{p}_1\), \(n_1(1-\hat{p}_1)\), \(n_2\hat{p}_2\), and \(n_2(1-\hat{p}_2)\) all at least 10.

An interval that contains 0

If the interval contains 0, a difference of 0 is plausible, and a two-sided test of \(H_0: \pi_1 - \pi_2 = 0\) at \(\alpha = 1 - C\) would usually fail to reject. The match is approximate because the test pools and the interval does not.

The coverage simulation

Each simulated pair of samples draws counts \(k_1^*\) and \(k_2^*\) from binomial distributions with the observed \(\hat{p}_1\) and \(\hat{p}_2\), then builds an interval for the difference with the same \(z^*\). The true difference is set to the observed \(\hat{p}_1 - \hat{p}_2\).

Sampling distribution

Simulated intervals

◆ The Blueprint
The standard error of a difference
$$SE = \sqrt{\frac{s_1^2}{n_1} + \frac{s_2^2}{n_2}}, \qquad (\bar{x}_1 - \bar{x}_2) \pm t^* \times SE$$
Welch's degrees of freedom
$$df = \frac{\left(\frac{s_1^2}{n_1} + \frac{s_2^2}{n_2}\right)^2}{\frac{\left(s_1^2/n_1\right)^2}{n_1 - 1} + \frac{\left(s_2^2/n_2\right)^2}{n_2 - 1}}$$

The result always lies between the smaller of \(n_1 - 1\) and \(n_2 - 1\) and \(n_1 + n_2 - 2\). It need not be a whole number, and qt() accepts it as it is.

Welch and pooled

The pooled interval assumes \(\sigma_1 = \sigma_2\) and uses \(df = n_1 + n_2 - 2\). Welch's interval drops that assumption, and R's t.test() uses it unless you set var.equal = TRUE.

Validity conditions

Each group needs at least 20 observations, or data that are roughly symmetric without strong outliers.

The coverage simulation

Each simulated pair draws two independent normal samples with the observed means and standard deviations. Each pair gets its own Welch degrees of freedom and its own \(t^*\). The true difference is set to the observed \(\bar{x}_1 - \bar{x}_2\).

Sampling distribution

Simulated intervals

◆ The Blueprint
One sample of differences

Subtract within each pair, and the \(n\) differences are one sample. The paired interval is the one-sample t interval applied to them.

$$\bar{x}_{paired} \pm t^* \times \frac{s_{paired}}{\sqrt{n}}, \qquad df = n - 1$$
Why pairing helps

Pairing removes the variation between subjects: a subject who scores high before also tends to score high after, and the difference cancels that. So \(s_{paired}\) is often much smaller than either group's standard deviation, and, when the two measurements are positively correlated, the interval is narrower than a two-sample interval on the same data.

Paired or two-sample

Use the paired interval when observations come in natural pairs: before and after on the same subject, matched subjects, or two measurements on one unit. Use the two-sample interval when the groups are independent.

Validity conditions

At least 20 pairs, or differences that are roughly symmetric without strong outliers.

The coverage simulation

Each simulated sample draws \(n\) differences from a normal population with mean \(\bar{x}_{paired}\) and standard deviation \(s_{paired}\) and builds an interval with the same \(t^*\). The true mean difference is set to the observed \(\bar{x}_{paired}\).

Simulated intervals

Share that contain π, by sample size

◆ The Blueprint
The long-run share

A sample of size \(n\) has some count \(k\) of successes, from 0 to \(n\), and each count gives one interval. The long-run share of intervals that contain \(\pi\) adds the binomial probabilities of the counts whose interval does:

$$\text{share} = \sum_{k=0}^{n} \texttt{dbinom}(k, n, \pi) \times \begin{cases} 1 & \text{if } \pi \text{ is inside } \hat{p} \pm z^* SE \\ 0 & \text{otherwise} \end{cases}$$

The simulation estimates the same share with 1,000 random samples, so its count changes from run to run.

Zero-width intervals

A sample with \(k = 0\) has \(\hat{p} = 0\) and \(SE = \sqrt{0 \times 1/n} = 0\), so its interval is the single point 0. The same happens at \(k = n\). These samples are common when \(n\pi\) is small: \(P(k = 0) = (1-\pi)^n\).

Why the share moves up and down with n

The count \(k\) is a whole number, so the set of counts whose interval contains \(\pi\) changes in jumps as \(n\) grows. For \(\pi = 0.1\) the share is 93.2% at \(n = 100\) and 92.7% at \(n = 200\). Across every \(n\) from 100 to 1,000 it ranges from 91.0% (at \(n = 107\)) to 95.5%, and a few smaller samples, such as \(n = 26\), already reach 93% (Brown, Cai, and DasGupta, 2001, Statistical Science 16(2)). The rule of at least 10 successes and 10 failures marks where the share stays within a few points of 95%.

Other intervals for one proportion

R's prop.test() reports a Wilson score interval, with a continuity correction unless you set correct = FALSE. The Wilson interval collects every \(\pi\) that a score test would not reject, and the score test's standard error uses \(\pi\) itself, so the interval never has zero width. binom.test() reports the Clopper-Pearson interval, which collects every \(\pi\) that the exact binomial test would not reject. Both keep their share closer to 95% than \(\hat{p} \pm z^* \times SE\) when successes are few, and the Clopper-Pearson share is at least 95%.

R's interval functions
CallWhat it returns
qnorm(1 - alpha/2)\(z^*\), the critical value for a proportion.
qt(1 - alpha/2, df)\(t^*\), the critical value for a mean. df may be a decimal, such as Welch's.
t.test(x)$conf.intThe one-sample t interval. Set the level with conf.level = 0.99.
t.test(x1, x2)$conf.intThe two-sample interval with Welch's degrees of freedom.
t.test(after, before, paired = TRUE)$conf.intThe paired interval for the mean of after - before.
prop.test(c(k1, k2), c(n1, n2), correct = FALSE)$conf.intThe two-proportion interval with each group's own \(\hat{p}\).
dbinom(k, n, p)The binomial probability of \(k\) successes, used for the long-run share on The Anvil.
ci_in_R.R