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.
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}\).
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%.
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.
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.
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.
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 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^*\).
The mean of \(n\) independent values with standard deviation \(\sigma\) has standard deviation \(\sigma/\sqrt{n}\). The interval estimates \(\sigma\) with \(s\).
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^*\).
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\).
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\).
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}\).
The two samples are independent, so the variance of \(\hat{p}_1 - \hat{p}_2\) is the sum of the two variances.
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}\).
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.
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.
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\).
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.
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.
Each group needs at least 20 observations, or data that are roughly symmetric without strong outliers.
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\).
Subtract within each pair, and the \(n\) differences are one sample. The paired interval is the one-sample t interval applied to them.
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.
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.
At least 20 pairs, or differences that are roughly symmetric without strong outliers.
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}\).
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:
The simulation estimates the same share with 1,000 random samples, so its count changes from run to run.
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\).
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%.
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%.
| Call | What 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.int | The one-sample t interval. Set the level with conf.level = 0.99. |
t.test(x1, x2)$conf.int | The two-sample interval with Welch's degrees of freedom. |
t.test(after, before, paired = TRUE)$conf.int | The paired interval for the mean of after - before. |
prop.test(c(k1, k2), c(n1, n2), correct = FALSE)$conf.int | The 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. |