Inference for Regression

Does clutch size in birds really decline with a warming spring? Or could that downward-sloping line in your scatterplot be an accident? Maybe it just reflects which 20 nests you happened to measure. Every fitted regression line is an estimate. It is built from a finite, noisy sample. A different sample would give a different line. Inference for regression asks how much that line would wiggle if you repeated the study. It also asks whether the slope you found is distinguishable from the "no relationship" slope of zero. This matters because a scatterplot alone cannot tell you whether a pattern is signal or sampling noise. The human eye is a notoriously unreliable judge of trend when data are scattered. The big picture is that the least-squares slope and intercept are themselves random variables. Each has a sampling distribution shaped by the amount and spread of the data. It is also shaped by how much scatter surrounds the line. Once we know that sampling distribution, the entire machinery built for Inference for Correlation and for means transfers directly to slopes and predictions. This includes standard errors, t-distributions, confidence intervals, and p-values. The same regression line that summarizes a relationship in The Least-Squares Line and Residuals becomes something more here. It becomes a vehicle for asking whether that relationship generalizes beyond the particular sample in hand. This article builds the confidence interval and hypothesis test for the slope β1\beta_1. It distinguishes a confidence interval for the mean response from a prediction interval for a single future observation. It also lays out the assumptions that must hold for these procedures to be trustworthy. These are linearity, independence, normality of errors, and equal variance (LINE). Diagnostic residual plots are the tool for checking those assumptions. Violations change the analysis, not just the arithmetic. By the end you should be able to compute a standard error for a slope by hand. You should be able to test H0:β1=0H_0: \beta_1 = 0. You should be able to build both flavors of interval around a predicted value. You should also recognize from a residual plot when the whole apparatus is inappropriate. This is the natural bridge to Multiple Regression: An Introduction, where the same logic extends to several predictors at once. It also leads to Logistic Regression for Binary Outcomes, where a different error structure demands a different inferential machine entirely.

Key takeaways
  • The least-squares slope b1b_1 is a random variable with sampling distribution centered at the true slope β1\beta_1 and standard error SEb1=s/(sxn−1)SE_{b_1} = s / (s_x\sqrt{n-1}), where ss is the residual standard deviation.
  • H0:β1=0H_0: \beta_1 = 0 is tested with t=b1/SEb1t = b_1/SE_{b_1} on n−2n-2 degrees of freedom; rejecting it means the linear relationship is unlikely to be due to chance alone.
  • A confidence interval for β1\beta_1 is b1±tn−2∗×SEb1b_1 \pm t^*_{n-2} \times SE_{b_1}; it should not include 0 if the test rejects at the matching α\alpha.
  • A confidence interval for the mean response at x0x_0 is narrower than a prediction interval for one new observation at x0x_0, because the latter adds individual scatter to estimation uncertainty.
  • Validity rests on four assumptions — Linearity, Independence, Normality of residuals, Equal variance (LINE) — checked with residual plots, not the raw scatterplot.
  • Extrapolation beyond the observed range of xx, and influence from a single high-leverage point, are the two most common ways this machinery is misapplied.
The core insight

The fitted slope is a statistic with its own sampling distribution, so every claim about a regression relationship is a probabilistic inference, not a geometric fact about one scatterplot.

The core idea

Suppose we fit the simple linear regression model

Yi=β0+β1xi+εiY_i = \beta_0 + \beta_1 x_i + \varepsilon_i

where β0\beta_0 and β1\beta_1 are fixed but unknown population parameters, and εi\varepsilon_i are random errors assumed independent, normally distributed, with mean 0 and constant variance σ2\sigma^2. The observed data give least-squares estimates b0b_0 and b1b_1, computed exactly as in The Least-Squares Line and Residuals by minimizing the sum of squared residuals. Crucially, b1b_1 is a statistic: if you drew a fresh sample of nn pairs (xi,yi)(x_i, y_i) from the same population, you would get a slightly different b1b_1. Its sampling distribution, under the model assumptions, is approximately normal (exactly normal if the errors themselves are normal), centered at the true β1\beta_1, with standard error

SEb1=ssxn−1,s=∑(yi−y^i)2n−2SE_{b_1} = \dfrac{s}{s_x \sqrt{n-1}}, \qquad s = \sqrt{\dfrac{\sum (y_i - \hat y_i)^2}{n-2}}

Here ss is the residual standard deviation (estimating σ\sigma), and sxs_x is the sample standard deviation of the xx-values. Two things this formula makes precise, and both are biologically intuitive: more scatter around the line (ss large) inflates the standard error, while a wider spread of xx-values (sxs_x large) shrinks it — spreading your predictor levels out gives more leverage to pin down the slope, which is why well-designed experiments deliberately space treatment levels widely rather than clustering them. Because σ2\sigma^2 is estimated (not known), inference uses the t-distribution with n−2n-2 degrees of freedom — one degree of freedom is spent estimating β0\beta_0, another estimating β1\beta_1, mirroring exactly how the correlation coefficient's significance test in Inference for Correlation also runs on n−2n-2 df. This shared machinery is not a coincidence: testing H0:ρ=0H_0: \rho = 0 and testing H0:β1=0H_0: \beta_1 = 0 are algebraically equivalent for simple linear regression, producing the identical tt-statistic and pp-value, because a slope of zero and a correlation of zero are the same statement about independence between XX and YY.

Mechanism — how the inference actually works

Step 1 — Partition the variability. Total variation in yy splits into variation explained by the line and leftover residual variation:

∑(yi−yˉ)2⏟SST=∑(y^i−yˉ)2⏟SSR+∑(yi−y^i)2⏟SSE\underbrace{\sum(y_i - \bar y)^2}_{\text{SST}} = \underbrace{\sum(\hat y_i - \bar y)^2}_{\text{SSR}} + \underbrace{\sum(y_i - \hat y_i)^2}_{\text{SSE}}

SSE, divided by n−2n-2, gives the residual variance s2s^2, the estimate of the "noise floor" σ2\sigma^2 around the true line.

Step 2 — Compute the standard error of the slope. Using ss from Step 1 and the spread of xx, SEb1=s/(sxn−1)SE_{b_1} = s/(s_x\sqrt{n-1}). This quantity answers: if I replicated this study many times with the same xx-design, how much would my estimated slope typically vary from the truth?

Step 3 — Standardize into a t-statistic. For the hypothesis test of no linear relationship,

t=b1−0SEb1t = \frac{b_1 - 0}{SE_{b_1}}

on n−2n - 2 degrees of freedom. Large ∣t∣|t| means the observed slope is many standard errors from zero — implausible under the null of no relationship.

Step 4 — Build the confidence interval.

b1±tn−2,α/2∗×SEb1b_1 \pm t^*_{n-2, \alpha/2} \times SE_{b_1}

This interval is the set of hypothesized slopes that the data would not reject at level α\alpha — the duality between confidence intervals and two-sided tests that runs throughout inferential statistics.

Step 5 — Distinguish two different predictive questions. Once the line is fit, people often want to predict a yy-value at some new x0x_0. There are two distinct targets:

  • The mean response μY∣x0=β0+β1x0\mu_{Y|x_0} = \beta_0 + \beta_1 x_0 — "what is the average yy for all individuals with this xx?"
  • A single future observation y0y_0 at x0x_0 — "what will one particular new individual's yy-value be?"

Both are estimated by the same point y^0=b0+b1x0\hat y_0 = b_0 + b_1 x_0, but their uncertainties differ. The confidence interval for the mean only has to account for uncertainty in estimating the line:

y^0±tn−2∗ s1n+(x0−xˉ)2(n−1)sx2\hat y_0 \pm t^*_{n-2}\, s\sqrt{\dfrac{1}{n} + \dfrac{(x_0 - \bar x)^2}{(n-1)s_x^2}}

The prediction interval for one new observation must additionally account for that individual's own scatter around the (also uncertain) line:

y^0±tn−2∗ s1+1n+(x0−xˉ)2(n−1)sx2\hat y_0 \pm t^*_{n-2}\, s\sqrt{1+\dfrac{1}{n} + \dfrac{(x_0 - \bar x)^2}{(n-1)s_x^2}}

The extra "11" under the square root is the signature of the prediction interval, and it is always wider — sometimes dramatically so — than the confidence interval for the mean at the same x0x_0. Both intervals flare outward as x0x_0 moves away from xˉ\bar x, forming the characteristic "bowtie" shape around the fitted line.

Figure
Confidence band (mean response) vs. prediction band (single observation)
Predictor x (e.g. spring temperature, °C) Response y (e.g. clutch size) prediction interval (single y₀) confidence interval (mean μ) x̄ region

Step 6 — Verify assumptions before trusting any of it. All the standard errors above are derived under LINE:

  • Linearity — the true relationship between E[Y]E[Y] and xx is a straight line.
  • Independence — errors εi\varepsilon_i are independent across observations (violated by repeated measures, spatial or temporal autocorrelation, litter/clutch clustering).
  • Normality — errors are normally distributed (matters most for small samples; large-nn inference is robust by the Central Limit Theorem).
  • Equal variance (homoscedasticity) — σ2\sigma^2 does not change with xx.

These are checked with residual plots: residuals (yi−y^iy_i - \hat y_i) plotted against fitted values or against xx. A random, structureless scatter around zero supports the assumptions; a curved pattern flags nonlinearity; a "funnel" (fanning) shape flags unequal variance; and a normal quantile plot of residuals checks normality directly.

Figure
Diagnosing assumption violations from residual plots
Healthy: random scatter Curved: nonlinearity Funnel: unequal variance

The evidence

Regression inference is not a single dramatic experiment like Meselson–Stahl but a body of statistical theory, developed and stress-tested across decades, whose validity rests on mathematical derivation confirmed by simulation and by consistent replication across real datasets. Two historical threads are worth knowing.

Gauss and Legendre, and the Gauss–Markov theorem (early 1800s–1821). Carl Friedrich Gauss and Adrien-Marie Legendre independently developed least squares to fit orbits of celestial bodies from noisy astronomical observations; Gauss later proved (in what is now called the Gauss–Markov theorem) that among all linear unbiased estimators of the regression coefficients, the least-squares estimator has the smallest variance — the "Best Linear Unbiased Estimator" (BLUE) property. This theorem is the mathematical bedrock that justifies using b1b_1 as our estimate of β1\beta_1 at all, and it requires only that errors have mean zero and constant variance — normality is needed specifically for the t-based confidence intervals and p-values, not for the point estimate itself.

William Sealy Gosset and the t-distribution ("Student," 1908). Working as a chemist at the Guinness brewery in Dublin, Gosset needed a way to draw conclusions from very small samples — batches of barley, tiny fermentation trials — where the normal-distribution-based methods of the day, calibrated for large samples, gave misleadingly narrow intervals. He derived the exact sampling distribution of the standardized sample mean when the population variance is estimated rather than known, publishing under the pseudonym "Student" because Guinness barred employees from publishing under their own names (to protect trade secrets). Gosset's t-distribution — heavier-tailed than the normal, converging to it as degrees of freedom grow — is precisely the distribution that governs t=b1/SEb1t = b_1/SE_{b_1} in regression inference. Ronald Fisher later generalized and popularized the t-test's use across experimental design, including regression and ANOVA, cementing it as the standard tool for small-sample inference in biology.

Modern validation by simulation. The claim that b1b_1's sampling distribution is (approximately) tn−2t_{n-2}-shaped is now routinely confirmed by Monte Carlo simulation: generate thousands of synthetic datasets from a known linear model with specified β1\beta_1 and error distribution, compute b1b_1 and SEb1SE_{b_1} for each, and check that roughly 95% of the resulting 95%-confidence intervals actually contain the true β1\beta_1. Such simulations consistently confirm the theory when LINE assumptions hold, and just as reliably show coverage failure — intervals that are too narrow or badly centered — when independence or equal-variance assumptions are violated, which is exactly why residual diagnostics are taught as a mandatory companion to the arithmetic, not an optional afterthought.

Worked examples

Example 1 — Genetics-adjacent physiological calculation: metabolic rate and body mass in shrews. A physiologist measures resting metabolic rate (yy, in mL O₂/hour) against body mass (xx, in grams) for n=14n = 14 shrews. Least-squares fitting gives:

QuantityValue
Slope b1b_10.82 mL O₂/hr per gram
Residual SD ss1.35
sxs_x (SD of mass)2.10 g
nn14

Standard error of the slope:

SEb1=ssxn−1=1.352.1013=1.352.10×3.606=1.357.57≈0.178SE_{b_1} = \frac{s}{s_x\sqrt{n-1}} = \frac{1.35}{2.10\sqrt{13}} = \frac{1.35}{2.10 \times 3.606} = \frac{1.35}{7.57} \approx 0.178

Test H0:β1=0H_0: \beta_1 = 0 vs. Ha:β1≠0H_a: \beta_1 \neq 0:

t=0.820.178≈4.61,df=12t = \frac{0.82}{0.178} \approx 4.61, \quad df = 12

The critical value t12,0.025∗≈2.179t^*_{12, 0.025} \approx 2.179. Since 4.61>2.1794.61 > 2.179, we reject H0H_0 at α=0.05\alpha = 0.05 (in fact p<0.001p < 0.001). A 95% CI for β1\beta_1:

0.82±2.179(0.178)=0.82±0.388  ⇒  (0.43, 1.21)0.82 \pm 2.179(0.178) = 0.82 \pm 0.388 \;\Rightarrow\; (0.43,\ 1.21)

Interpretation: for every extra gram of body mass, resting metabolic rate increases by somewhere between 0.43 and 1.21 mL O₂/hr, with 95% confidence — and the interval excludes zero, consistent with the well-established (though sublinear across broader mass ranges) mass–metabolism relationship in mammals.

Example 2 — Prediction vs. confidence interval in an ecological/clinical scenario. An agricultural scientist regresses crop yield (yy, tons/hectare) on nitrogen fertilizer applied (xx, kg/hectare) across n=22n = 22 plots, obtaining b0=2.10b_0 = 2.10, b1=0.034b_1 = 0.034, s=0.51s = 0.51, xˉ=120\bar x = 120 kg/ha, sx=38s_x = 38 kg/ha. She wants to know two different things at x0=180x_0 = 180 kg/ha (a relatively high, less-densely-sampled dose): Point estimate:

y^0=2.10+0.034(180)=2.10+6.12=8.22 tons/ha\hat y_0 = 2.10 + 0.034(180) = 2.10 + 6.12 = 8.22 \text{ tons/ha}

(a) Mean yield across all plots that would receive 180 kg/ha — a confidence interval for μY∣180\mu_{Y|180}:

SEmean=s122+(180−120)221×382=0.510.0455+360030324=0.510.0455+0.1187SE_{\text{mean}} = s\sqrt{\frac{1}{22} + \frac{(180-120)^2}{21 \times 38^2}} = 0.51\sqrt{0.0455 + \frac{3600}{30324}} = 0.51\sqrt{0.0455+0.1187}
=0.510.1642=0.51(0.405)≈0.207= 0.51\sqrt{0.1642} = 0.51(0.405) \approx 0.207

With t20,0.025∗≈2.086t^*_{20,0.025} \approx 2.086:

8.22±2.086(0.207)=8.22±0.432  ⇒  (7.79, 8.65) tons/ha8.22 \pm 2.086(0.207) = 8.22 \pm 0.432 \;\Rightarrow\; (7.79,\ 8.65) \text{ tons/ha}

(b) Yield on one particular new plot given 180 kg/ha — a prediction interval:

SEpred=s1+122+(180−120)221×382=0.511.1642=0.51(1.079)≈0.550SE_{\text{pred}} = s\sqrt{1+\frac{1}{22} + \frac{(180-120)^2}{21\times38^2}} = 0.51\sqrt{1.1642} = 0.51(1.079) \approx 0.550
8.22±2.086(0.550)=8.22±1.147  ⇒  (7.07, 9.37) tons/ha8.22 \pm 2.086(0.550) = 8.22 \pm 1.147 \;\Rightarrow\; (7.07,\ 9.37) \text{ tons/ha}

The prediction interval (2.30 tons wide) is more than double the confidence interval (0.86 tons wide) — the extra width is the price of predicting one noisy individual plot rather than an infinitely-replicated average, and both intervals would flare out further still if the scientist pushed x0x_0 to 300 kg/ha, well outside the sampled range of nitrogen doses — a warning sign for extrapolation discussed below.

Common misconceptions & traps

MisconceptionWhy it's wrong
"A significant slope means the relationship is strong/important."Statistical significance depends on nn and scatter; a tiny, biologically trivial slope can be significant with large nn. Check R2R^2 and effect size, not just the pp-value.
"The regression line can be trusted anywhere, even far outside the data."Extrapolation beyond the observed xx-range assumes linearity continues untested; both CI and PI formulas widen sharply there, and the true relationship may curve or plateau.
"A confidence interval for the mean response is the same as a prediction interval."The CI concerns the average yy at x0x_0; the PI concerns one future observation and is always wider due to individual-level scatter.
"If residuals look scattered on the (x,y) plot, the assumptions are fine."Assumptions are diagnosed from the residual plot (residuals vs. fitted or vs. x), not the raw scatterplot — nonlinearity or heteroscedasticity can be invisible in the original scatter but obvious in residuals.
"Correlation and regression slope test give different conclusions."For simple linear regression, H0:ρ=0H_0: \rho=0 and H0:β1=0H_0: \beta_1=0 are mathematically identical tests with the same tt-statistic and pp-value.
"One high-leverage outlier is just 'a data point' like any other."A point far from xˉ\bar x can single-handedly determine the slope's sign or magnitude; leverage and influence diagnostics (e.g., Cook's distance) are needed to check this.

The scientist behind it

Origins · 1 minWilliam Sealy Gosset and how this was discovered
WS
William Sealy Gosset
1876–1937 · Statistician at Guinness Brewery, Dublin; pioneer of small-sample inference

Gosset trained in chemistry and mathematics at Oxford before joining Guinness in 1899, where he faced a distinctly practical problem: brewing experiments — comparing barley varieties, hop treatments, yeast strains — could only ever be run on small numbers of batches, yet the statistical theory of the era assumed sample sizes large enough that the sample standard deviation could be treated as if it were the true population standard deviation. Gosset noticed that this assumption badly understated uncertainty when samples were small, giving false confidence in brewing decisions. Through both theoretical derivation and, notably, empirical simulation — he generated thousands of samples from measured height and finger-length data of criminals (a dataset then available) and tabulated the resulting distribution of the standardized mean by hand — he worked out the exact small-sample sampling distribution, published in 1908 in Biometrika under the pseudonym "Student." Guinness's confidentiality policy forbade employees from publishing, fearing competitors might infer trade secrets from statistical papers, so his identity remained something of an open secret in statistical circles for years. Ronald Fisher, recognizing the importance of Gosset's work, refined the notation and proofs and built the t-test into the foundation of experimental design and analysis of variance, from which it propagated into essentially every corner of quantitative biology — including, directly, the standard error and confidence interval formulas for a regression slope used throughout this article.

Origins · 1 minhow this was discovered
History
1809
— Gauss publishes least-squares theory in the context of predicting orbital paths.
1821
— Gauss proves the Gauss–Markov theorem establishing least squares as the best linear unbiased estimator.
1908
— Gosset ("Student") derives the exact sampling distribution underlying the t-test, published in Biometrika.
1920
s — Ronald Fisher formalizes the t-distribution's role in regression, ANOVA, and experimental design.
1950
s–60s — Confidence and prediction interval formulas for regression become standard in applied statistics texts and software.

Where this matters today

Medicine and epidemiology. Dose–response regressions (e.g., drug concentration vs. blood pressure reduction) rely on slope confidence intervals to establish whether a treatment effect is distinguishable from zero, and prediction intervals inform individualized risk estimates — e.g., predicting a single patient's expected lab value given age and weight, which requires the wider prediction interval, not the confidence band for the population mean.

Agriculture and ecology. Fertilizer-response curves, growth-rate-vs-temperature relationships, and species-abundance-vs-habitat-variable regressions all use slope tests to decide whether a management variable causally tracks with an outcome, and prediction intervals to set realistic expectations (e.g., "how much yield variation should one field show") rather than overstating precision with mean-response intervals alone.

Conservation biology. Regressions of population size against habitat area, or extinction risk against fragment size, use slope confidence intervals to argue for policy thresholds; residual diagnostics are essential here because ecological data often violate independence (spatially clustered sites) or equal variance (small populations are noisier than large ones), demanding corrected standard errors.

Biotechnology and calibration curves. Standard curves in assays (e.g., ELISA absorbance vs. known concentration) are regressions whose slope and intercept convert instrument readings into concentrations; prediction intervals around the calibration line quantify the uncertainty in back-calculated concentrations for unknown samples — a routine, high-stakes application in diagnostic labs.

Public health surveillance. Trend lines fit to disease incidence over time use slope tests to determine whether an apparent rise or fall in cases is statistically distinguishable from a flat trend, informing outbreak declarations — though autocorrelation in time-series counts often violates the independence assumption, requiring more advanced time-series-aware models that extend this basic framework.

Ask the tutor: How would these formulas change if I had unequal variance across x (heteroscedasticity) — what correction should I apply?

Why do we need n−2n-2 degrees of freedom instead of n−1n-1 in simple linear regression?

Two parameters — the intercept β0\beta_0 and the slope β1\beta_1 — are estimated from the data before the residual variance s2s^2 can be computed, so two degrees of freedom are "spent" fitting the line. This parallels the single degree of freedom lost when estimating one mean in a one-sample t-test: each estimated parameter constrains the residuals, reducing the residual degrees of freedom by one. With nn data points and 2 fitted parameters, n−2n-2 independent pieces of information remain to estimate the leftover scatter around the line, so s2=SSE/(n−2)s^2 = \text{SSE}/(n-2), and all subsequent tt-tests and confidence intervals for the slope use tn−2t_{n-2}.

Is a high R2R^2 the same thing as a statistically significant slope?

No — they answer different questions. R2R^2 measures the proportion of variance in y explained by the regression, an effect-size-like quantity, while the significance test asks whether the slope is distinguishable from zero given sampling variability. With a very large sample size, even a slope explaining a tiny fraction of variance (low R2R^2) can be highly statistically significant, because the standard error shrinks as nn grows. Conversely, with a small sample, a large, biologically meaningful-looking slope might not reach significance simply because there isn't enough data to rule out chance. Always report and interpret both together.

What does it mean if the 95% confidence interval for the slope includes zero?

It means that zero (no linear relationship) is among the plausible values of β1\beta_1 consistent with the observed data at the 95% confidence level, so we fail to reject H0:β1=0H_0:\beta_1=0 at α=0.05\alpha=0.05. This is not proof that the true slope is zero — absence of evidence is not evidence of absence — it may simply reflect insufficient sample size, excessive scatter, or a genuinely weak or absent linear relationship. A wide confidence interval straddling zero, rather than a narrow one centered near zero, usually signals low statistical power rather than strong evidence for the null.

Can regression inference be trusted if the sample size is small, say n = 8?

Small samples make the t-distribution's heavier tails especially important — using a normal-based critical value instead of the correct tn−2t_{n-2} value would understate uncertainty and produce falsely narrow intervals, exactly the problem Gosset originally solved. But small samples also make the normality assumption on residuals harder to check (few residuals to inspect) and make the whole procedure more sensitive to a single unusual point. With very small nn, results should be treated as provisional, ideally supplemented with nonparametric or resampling-based (bootstrap) confidence intervals that do not rely as heavily on the normality assumption.

How does a prediction interval change if I want to predict at the mean of x, x̄, versus far from it?

Both the confidence interval for the mean response and the prediction interval are narrowest exactly at x0=xˉx_0 = \bar x, because the term (x0−xˉ)2(x_0-\bar x)^2 in the standard error formula vanishes there — the fitted line is best-determined at the center of mass of the data. As x0x_0 moves away from xˉ\bar x in either direction, that squared term grows, widening both intervals and producing the characteristic bowtie or hourglass shape of the confidence and prediction bands. This is a direct, quantitative reason to avoid extrapolating predictions to x0x_0 values far outside the range actually sampled.

Does regression inference require that x, the predictor, be normally distributed?

No — the LINE assumptions concern the errors εi\varepsilon_i (equivalently, the conditional distribution of yy given xx), not the marginal distribution of the predictor xx itself. In many designed experiments, xx is fixed by the experimenter (e.g., chosen fertilizer doses) rather than randomly sampled at all, and the inference remains valid. What does matter is that the relationship between E[Y]E[Y] and xx is linear, that residuals are independent and normally distributed with constant variance across the range of xx studied — properties of the response's errors, not the predictor's distribution.

Why is the slope test in regression identical to the correlation test from Inference for Correlation?

Algebraically, the least-squares slope can be written as b1=r⋅(sy/sx)b_1 = r \cdot (s_y/s_x), where rr is the sample correlation coefficient. Substituting this into the slope's tt-statistic formula and simplifying shows it reduces exactly to the standard tt-statistic for testing H0:ρ=0H_0: \rho=0, namely t=r(n−2)/(1−r2)t = r\sqrt{(n-2)/(1-r^2)}. Both tests examine the same underlying question — is there a nonzero linear association between XX and YY? — just parameterized differently (slope in original units vs. a unitless correlation), so it is unsurprising, and mathematically guaranteed, that they yield identical pp-values in simple linear regression.

Before this

Where this leads