Instant PDF download, name-and-email checkout. Complete Book Bundle: every Economics, Statistics, Mathematics, Econometrics and Research Methods book
Statistics

t-Test for the Slope of a Regression Line: Confidence Interval and Significance Test for β

Learn the t-test for slope step by step: standard error, t statistic, p-value and a confidence interval for the population slope β, with worked examples.

In 30 seconds
  • A sample regression slope \(b\) is only an estimate of the true population slope \(\beta\). The t-test for slope asks whether \(\beta\) could plausibly be zero, meaning no linear relationship in the population.
  • The test statistic is \(t = b / SE_b\), where \(SE_b = s/\sqrt{S_{xx}}\) and \(s\) is the standard deviation of the residuals. Compare it with a t distribution on \(n – 2\) degrees of freedom.
  • In our case, 12 adults give \(b = -1.40\) beats per minute per weekly hour of exercise, \(SE_b = 0.247\), \(t = -5.67\), df = 10 and \(p \approx 0.0002\): strong evidence of a negative linear relationship.
  • The matching 95% confidence interval is \(b \pm t^{*}SE_b = -1.40 \pm 0.55\), or about \(-1.95\) to \(-0.85\) beats per minute per hour.
  • Exam point: check the conditions (linear, independent, normal residuals, equal spread, random) before the test, and conclude about \(\beta\), in context, not about \(b\).

The case: does more exercise go with a lower resting heart rate?

A health researcher selects 12 adults at random from members of a community sports centre. Each one reports their average hours of exercise per week, and a nurse measures their resting heart rate in beats per minute (bpm):

Adult123456789101112
Exercise (hours/week), \(x\)011233455678
Resting heart rate (bpm), \(y\)787476717274757168666667

The least-squares line is \(\hat y = 76.76 – 1.40x\). In this sample, each extra weekly hour of exercise goes with a resting heart rate about 1.4 bpm lower. (The figures are illustrative.)

But this is only 12 people. A different random sample of 12 would give a different slope. Could the true slope for all members be zero, with this sample’s pattern produced by chance? And if the slope is not zero, how big is it likely to be? Those are questions of inference, and they are answered by the t-test and confidence interval for the slope.

The concept: the slope as an estimate

Inference for regression starts with a model for the population. For each value of \(x\), the responses \(y\) vary around a true mean that lies on a straight line:

\[ \mu_y = \alpha + \beta x \]

Here \(\beta\) (beta) is the population slope and \(\alpha\) is the population intercept. We never see them. The sample line \(\hat y = a + bx\) estimates them. If we took many random samples, the sample slopes \(b\) would vary around \(\beta\). Under the conditions listed below, their sampling distribution is approximately normal, with a standard deviation that we estimate by the standard error of the slope, \(SE_b\).[1]

The null hypothesis is usually \(H_0: \beta = 0\). A slope of zero means the mean of \(y\) does not change with \(x\): no linear relationship. If our sample slope is many standard errors away from zero, that would be very surprising under \(H_0\), so we reject it.

Key termt-test for slope: a significance test of \(H_0: \beta = 0\) (no linear relationship between \(x\) and \(y\) in the population), using the statistic \(t = b/SE_b\), which follows a t distribution with \(n – 2\) degrees of freedom when \(H_0\) is true and the regression conditions hold.
\[ t = \frac{b – 0}{SE_b}, \qquad SE_b = \frac{s}{\sqrt{S_{xx}}}, \qquad s = \sqrt{\frac{\sum (y – \hat y)^2}{n – 2}}, \qquad \text{df} = n – 2 \]

Here \(b\) is the sample slope and \(SE_b\) is its standard error. \(s\) is the standard deviation of the residuals: the typical distance of a point from the line. \(S_{xx} = \sum (x – \bar x)^2\) measures how spread out the \(x\) values are. \(n\) is the number of data pairs, and the degrees of freedom are \(n – 2\) because two parameters (slope and intercept) were estimated. The formula shows that the slope is estimated more precisely when the points lie close to the line (small \(s\)) and when the \(x\) values are widely spread (large \(S_{xx}\)).[2]

Statistics Made Simple textbook coverStatistics Made Simple explains inference for regression and the t-test for slope with worked examples, diagrams and tables.Get the textbook · $12

The matching confidence interval for \(\beta\) is

\[ b \pm t^{*}\,SE_b \]

where \(t^{*}\) is the critical value from the t distribution with \(n – 2\) degrees of freedom (for 95% confidence and df = 10, \(t^{*} = 2.228\)). Computer output usually gives \(b\), \(SE_b\), \(t\) and the p-value in one row, so in exams you may only need to read and interpret them.

Why this method fits the case

The t-test for slope is the right tool because the researcher wants to generalise from a sample of pairs to a population relationship. Before using it, check the five conditions, often remembered as LINER:[3]

  • Linear: the scatterplot shows a roughly straight pattern, and the residual plot shows no curve. Here the residuals have signs + − + − − + + + − − − +, with no U-shape.
  • Independent: each adult’s measurements do not affect another’s. The 12 are sampled from a large membership (far more than 10 × 12 = 120 people), so independence is reasonable.
  • Normal: the residuals should be roughly normal. A dot plot of the 12 residuals (from −2.95 to 3.85) is roughly symmetric with no outliers.
  • Equal spread: the residual plot shows roughly the same vertical spread across all values of \(x\), with no fan shape.
  • Random: the adults were randomly selected.

It is not the right tool when:

  • The residual plot shows a curve; the slope of a straight line is then not a meaningful summary.
  • The data are not from a random sample or randomised experiment, so there is no population to generalise to.
  • You want to show cause and effect from observational data. A significant slope shows association, not causation.
  • There are several explanatory variables. That needs multiple regression, which is beyond this post.

Setting it up

Let \(\beta\) be the true slope of the population regression line of resting heart rate on weekly exercise hours, for all members of the sports centre. The hypotheses are

\[ H_0: \beta = 0 \qquad H_a: \beta \neq 0 \]

The summary statistics are:

QuantityValue
\(n\)12
\(\bar x\), \(\bar y\)3.75 hours, 71.5 bpm
\(S_{xx}\)70.25
\(S_{xy}\)−98.5
\(S_{yy}\)181
Slope \(b = S_{xy}/S_{xx}\)−1.4021
Intercept \(a = \bar y – b\bar x\)76.758
Sum of squared residuals \(\sum e^2\)42.890
Degrees of freedom\(n – 2 = 10\)
Significance level\(\alpha = 0.05\)

A shortcut for the sum of squared residuals is \(\sum e^2 = S_{yy} – S_{xy}^2/S_{xx} = 181 – 9702.25/70.25 \approx 181 – 138.11 = 42.89\), which avoids computing every residual.

Solving it

Worked example

Carry out the t-test for slope at the 5% significance level.

Step 1 Residual standard deviation: \(s = \sqrt{42.890/10} = \sqrt{4.289} \approx 2.071\) bpm.
Step 2 Standard error of the slope: \(SE_b = 2.071/\sqrt{70.25} = 2.071/8.382 \approx 0.2471\).
Step 3 Test statistic: \(t = -1.4021/0.2471 \approx -5.67\), with df = 10.
Step 4 P-value: \(2 \times P(t_{10} < -5.67) \approx 0.0002\).
Step 5 Decision: \(0.0002 < 0.05\), so reject \(H_0\).

There is convincing evidence of a negative linear relationship between weekly exercise and resting heart rate for members of this sports centre.

Worked example

Construct and interpret a 95% confidence interval for \(\beta\).

Step 1 Critical value: for 95% confidence with df = 10, \(t^{*} = 2.228\).
Step 2 Margin of error: \(2.228 \times 0.2471 \approx 0.551\).
Step 3 Interval: \(-1.402 \pm 0.551\), giving \((-1.95,\ -0.85)\).
Step 4 Check: the interval lies entirely below 0, consistent with rejecting \(H_0: \beta = 0\) at the 5% level.

We are 95% confident that, for members of this centre, each extra weekly hour of exercise is associated with a mean resting heart rate between about 0.85 and 1.95 bpm lower.

Worked example

Regression software prints the following for a study of 20 randomly chosen flats, with \(x\) = floor area (m²) and \(y\) = monthly rent (£). Test whether rent is linearly related to floor area. (The figures are illustrative.)

PredictorCoefSE CoefTP
Constant310.595.23.260.004
Area9.841.526.470.000
Step 1 Read the slope row, not the constant row: \(b = 9.84\), \(SE_b = 1.52\).
Step 2 \(t = 9.84/1.52 \approx 6.47\), df = 20 − 2 = 18. The output’s p-value of “0.000” means \(p < 0.0005\).
Step 3 Reject \(H_0: \beta = 0\) at any usual significance level.
Step 4 95% CI: \(t^{*} = 2.101\) (df = 18), so \(9.84 \pm 2.101 \times 1.52 = 9.84 \pm 3.19\), or about £6.65 to £13.03 per extra m².

There is very strong evidence that rent rises with floor area; each extra square metre adds roughly £7 to £13 to the mean monthly rent.

Statistics Made Simple Practice Questions coverMake slope tests and intervals automatic with the Practice Questions book: 1,569 questions, all fully worked.Get 1,569 questions · $9

What the answer tells us

Figure 1 shows where our test statistic falls. If the population slope were zero, \(t\) would follow the t distribution with 10 degrees of freedom shown below. Values beyond ±2.228 would happen only 5% of the time. Our \(t = -5.67\) is far into the left tail.

Where the slope test statistic falls (t distribution, df = 10)
Null distribution of t5% critical values ±2.228Rejection region and observed t
0.00.10.20.30.4-7-6-5-4-3-2-101234567t statistic (df = 10)Densityobserved t = −5.67p ≈ 0.0002−2.2282.2282.5%2.5%
Figure 1. If the population slope were zero, t = b/SE_b would follow this t distribution with 10 degrees of freedom. The observed t = −5.67 lies far beyond the −2.228 critical value, so H₀: β = 0 is rejected.

Interpreting the result. The test says the negative slope is very unlikely to be a fluke of sampling. The interval says how big the effect plausibly is: about 0.85 to 1.95 bpm per weekly hour. Both statements are about the population of sports-centre members, because that is where the random sample came from.

What it does not say. This is an observational study. People who exercise more may also differ in diet, age or smoking. A significant slope does not prove that exercise causes lower heart rates; only a randomised experiment could show that. See our post on correlation vs causation.

Reasonableness check. The t statistic can also be found from the correlation: \(t = r\sqrt{(n-2)/(1-r^2)}\). Here \(r = -0.874\), so \(t = -0.874 \times \sqrt{10/0.237} \approx -5.67\), matching our answer. Testing \(\beta = 0\) is the same as testing whether the population correlation is zero.[4]

Sensitivity to sample size. Suppose the researcher had stopped after the first six adults (0 to 3 hours). The slope is similar, \(b \approx -1.59\), but with so few points and a narrow range of \(x\), \(SE_b \approx 0.70\). Then \(t \approx -2.28\) with df = 4, and the two-sided p-value is about 0.085, not significant at 5%. Fewer points and less spread in \(x\) both make \(SE_b\) bigger. To estimate a slope precisely, collect more data and spread the \(x\) values widely.

Common mistakeWriting the hypotheses with \(b\) instead of \(\beta\): “\(H_0: b = 0\)”. The sample slope is known (it is −1.40); there is nothing to test about it. Hypotheses are always about the population slope \(\beta\), and you should define \(\beta\) in context.
Common mistakeUsing \(n – 1\) degrees of freedom, as in a one-sample t-test. For regression it is \(n – 2\). With \(n = 12\), the 95% critical value is 2.228 for df = 10, not 2.201 for df = 11. Using the wrong df changes the interval and can change borderline decisions.
Exam tipOn computer output, the slope row is labelled with the name of the explanatory variable, not “Constant”. The “SE Coef” in that row is \(SE_b\), and the “T” is \(b/SE_b\). The printed p-value is two-sided; halve it for a one-sided alternative if the slope has the hypothesised sign. Always state conditions, then conclude in context: “there is convincing evidence of a linear relationship between … and … in the population of …”.[5]

For the full picture of regression, from scatterplots to inference, the Statistics Made Simple textbook explains each step with worked examples and annotated computer output. To practise reading output, checking conditions and writing conclusions, try the Statistics Made Simple Practice Questions book, where every inference question is fully worked.

Statistics Made Simple bundle coverMaster regression inference with both Statistics Made Simple books for $16.Both books · $16

Practice questions

Use \(\alpha = 0.05\) unless told otherwise.

EasyQ1. For a random sample of 20 pairs, the regression slope is \(b = 2.35\) with \(SE_b = 0.80\). Find the test statistic and degrees of freedom for testing \(H_0: \beta = 0\). Show worked answer
\(t = 2.35/0.80 \approx 2.94\).
df \(= 20 – 2 = 18\).
(The two-sided p-value is about 0.009, so \(H_0\) would be rejected.)
EasyQ2. A regression uses 15 data pairs. State the degrees of freedom and the critical value \(t^{*}\) for a 95% confidence interval for \(\beta\). Show worked answer
df \(= 15 – 2 = 13\).
\(t^{*} = 2.160\) (from t tables, 0.025 in each tail).
MediumQ3. A study of 22 towns gives a slope of 0.48 (extra cafés per 1,000 residents per £1,000 of median income) with \(SE_b = 0.12\). Construct a 95% confidence interval for \(\beta\) and interpret it. Show worked answer
df \(= 20\), \(t^{*} = 2.086\).
Margin: \(2.086 \times 0.12 \approx 0.250\).
Interval: \(0.48 \pm 0.25 = (0.23,\ 0.73)\).
We are 95% confident that each extra £1,000 of median income is associated with between 0.23 and 0.73 more cafés per 1,000 residents, on average. The interval excludes 0, so there is evidence of a positive linear relationship.
MediumQ4. Data: \(x\) = 2, 4, 6, 8, 10 and \(y\) = 5, 9, 10, 14, 17, with \(b = 1.45\), \(S_{xx} = 40\) and \(\sum e^2 = 1.90\). Calculate \(s\), \(SE_b\) and \(t\). Show worked answer
\(s = \sqrt{1.90/3} = \sqrt{0.6333} \approx 0.796\).
\(SE_b = 0.796/\sqrt{40} = 0.796/6.325 \approx 0.126\).
\(t = 1.45/0.126 \approx 11.5\), df = 3. The two-sided p-value is about 0.001, so the slope is significant.
ExamQ5. An economist regresses monthly household spending on eating out (£, \(y\)) on monthly household income (£ hundred, \(x\)) for a random sample of 25 households. Output gives slope \(b = 3.12\) and \(SE_b = 1.40\). (a) State hypotheses to test whether spending increases with income. (b) Calculate the test statistic and find the p-value. (c) State your conclusion at the 5% level. (d) Construct a 95% confidence interval for \(\beta\). (e) Name two conditions that must be checked and how. [9] Show worked answer
(a) \(H_0: \beta = 0\), \(H_a: \beta > 0\), where \(\beta\) is the true slope of spending on income for all households in the population. [1]
(b) \(t = 3.12/1.40 \approx 2.23\), df \(= 23\). [1] One-sided p-value \(= P(t_{23} > 2.23) \approx 0.018\). [1]
(c) \(0.018 < 0.05\): reject \(H_0\). There is convincing evidence that eating-out spending increases with income. [1]
(d) \(t^{*} = 2.069\) (df = 23); \(3.12 \pm 2.069 \times 1.40 = 3.12 \pm 2.90\), so about (0.22, 6.02) pounds per £100 of income. [2]
(e) Any two, with method: linearity (residual plot with no curve) [1]; equal spread (residual plot with no fan) / normal residuals (histogram or normal plot of residuals roughly symmetric, no outliers) / independence (sample under 10% of population) [1]. [1 for method]

Frequently asked questions

Why are there n − 2 degrees of freedom?

Because two quantities, the slope and the intercept, are estimated from the data before the residuals are calculated. Each estimate uses up one degree of freedom, leaving \(n – 2\) for estimating the spread of the points around the line.

Is the t-test for slope the same as testing the correlation?

Yes, for simple linear regression. Testing \(H_0: \beta = 0\) gives exactly the same t statistic and p-value as testing whether the population correlation is zero, using \(t = r\sqrt{(n-2)/(1-r^2)}\).

Can I test whether the slope equals a value other than zero?

Yes. Use \(t = (b – \beta_0)/SE_b\), where \(\beta_0\) is the hypothesised value. For example, an economist might test whether a slope equals 1. The degrees of freedom are still \(n – 2\).

What if the conditions are not met?

If the residual plot is curved, try transforming a variable and refitting. If there are outliers, investigate them and report results with and without them. If the sample is not random, the test result does not generalise to a population. Our hypothesis testing guide covers the general logic of tests and p-values.

References

  1. Illowsky, B. & Dean, S. (2023) Introductory Statistics 2e. Houston, TX: OpenStax. https://openstax.org/details/books/introductory-statistics-2e
  2. Moore, D. S., McCabe, G. P. & Craig, B. A. Introduction to the Practice of Statistics. New York: W. H. Freeman.
  3. Starnes, D. S. & Tabor, J. The Practice of Statistics. New York: W. H. Freeman.
  4. Agresti, A., Franklin, C. & Klingenberg, B. Statistics: The Art and Science of Learning from Data. Boston: Pearson.
  5. College Board. AP Statistics Course and Exam Description. New York: College Board.
Statistics Made Simple Complete Bundle cover showing both the textbook and practice book
This topic has a full chapter in Statistics Made Simple, with 1,569 worked practice questions in the bundle.Statistics Made Simple Complete Bundle — Textbook + 1,569 Practice Questions
Get it for $16
E

The EconTutorials team writes clear, exam-focused lessons in economics and statistics for A-Level, IB, AP and university students, with more than 13 years of classroom teaching behind every guide and book in the Made Simple series.