LightMySky
به انگلیسی

Simple Linear Regression and Inference on the Slope

Model the mean response with a line, estimate its coefficients by least squares, and test or form an interval for the slope under stated assumptions. Use residual patterns to check for curvature and unequal spread.

No account needed. Progress saves in this browser.

What a learner can do afterwards

  • Write the model, state its error assumptions and estimate its coefficients by least squares
  • Test whether a slope differs from zero and give an interval for it
  • Read a residual plot for curvature and changing spread

1 · Read

You have used fitted lines for prediction. The population model is y = a + bx + e. Here a + bx is the mean response at x; e is a random departure from that mean. Assume errors have mean zero at each x, constant variance and independence across observations. Exact t inference also assumes normally distributed errors at each x. The pooled response values need not be normally distributed.

Least squares minimises SSE, the sum of squared residuals. A residual is observed y minus fitted y. Let Sxx be the sum of (x minus mean x) squared, and Sxy the sum of (x minus mean x)(y minus mean y). When Sxx > 0, the slope estimate b1 = Sxy/Sxx. The intercept estimate is mean y minus b1 times mean x. Insert x into the fitted equation to calculate fitted y.

Fitted y = 3 + 2xx = 53 + 2(5) = 13Observed y = 11Residual: 11 - 13 = -2
Multiply before adding the intercept. Find the residual by subtracting fitted y from observed y.

Different samples give different slope estimates. SE(b1) estimates their standard deviation. For H0: b = 0 against b != 0, use t = b1/SE(b1). With n observations, under H0 and the model assumptions, t follows a t distribution with n - 2 degrees of freedom. The two-sided p value is the probability under H0 of an absolute t at least as large as observed. Reject H0 if p < the chosen significance level; otherwise do not reject. Nonrejection does not establish a zero slope.

Under the assumptions, a 95% confidence procedure covers the fixed population slope in 95% of repetitions in the long run. A two-sided t interval for b is b1 plus or minus t* times SE(b1); choose t* using n - 2 degrees of freedom and the confidence level. Subtract and add the margin to b1, rounding endpoints last. A valid 95% interval excluding zero matches rejection in the two-sided 5% test. This is evidence, not proof; including zero does not establish a zero slope.

b1 = 0.6; SE = 0.2Supplied t* = 2Margin: 2(0.2) = 0.4Lower: 0.6 - 0.4 = 0.2Upper: 0.6 + 0.4 = 1.0
Use the supplied critical value to calculate the margin before finding both endpoints.

Plot residuals against x or fitted y. A clear curve suggests the linear mean model misses structure. A widening fan suggests increasing error variance. Investigate these warnings before relying on the usual t inference. A pattern-free plot does not verify all assumptions: check sampling design and observation order for dependence, and inspect normality separately. Normal errors are needed for exact t inference, not for calculating a least-squares fit.

Prediction outside the observed x range is extrapolation: the relationship may change there. Interpolation stays inside the range, but accuracy still depends on the model and data. At the same x and confidence level, a usual prediction interval for one new observation is wider than a confidence interval for the mean response. It includes uncertainty in the estimated mean and the new observation's random departure from it.

Model the line, test the slope, and let the residuals check your work.

Lesson, questions and flashcards written for this dataset.

Readings, extra questions and flashcards written for this dataset. Video links reference Khan Academy lessons; the videos remain the work of their publishers.

More to read

Errors belong to the population model

A fitted equation describes a line estimated from observations. The population model adds a random error to a mean response: y = a + bx + e. At a given x, a + bx is the mean response and e is the departure from it. The fitted line estimates that mean. A residual uses the fitted line, so it is observed y minus fitted y rather than the unknown population error.

Least squares chooses the intercept and slope that minimise the sum of squared residuals. Provided the predictor values vary, the slope estimate is Sxy/Sxx, where Sxy sums centred cross-products and Sxx sums squared predictor deviations. The intercept then makes the line pass through the pair of sample means.

For the usual exact t inference, errors are independent across observations and normally distributed with mean zero and constant variance at each predictor value. Normality concerns departures from the mean line at each x. It does not require all response values pooled across different x values to have a normal distribution.

A mean response and one new response

Inserting a predictor value into a fitted line gives a point prediction. That number can estimate the mean response at the chosen x or predict the response of one new observation. These targets have different uncertainty.

A confidence interval for the mean response accounts for uncertainty in estimating the line. A usual prediction interval for a new observation also accounts for the new observation's random departure from its mean. With the same x and confidence level, and under the usual regression assumptions with positive error variance, the prediction interval is wider.

Check whether the proposed x is inside the observed range. Inside is interpolation; outside is extrapolation. Range membership alone does not establish accuracy. The model might miss a curve or important variation even within the data. Outside the range, the relationship may change in ways the observations cannot reveal. An interval calculated under the fitted model does not account for every possible model failure.

Evidence about the population slope

For a two-sided test of a zero slope, divide the estimated slope by its standard error. Under the null hypothesis and the model assumptions, this statistic follows a t distribution with n - 2 degrees of freedom. Its two-sided p value is the probability of an absolute test statistic at least as large as the one observed.

Compare the p value with a significance level selected before examining the result. A value below that level leads to rejection of a zero slope. A larger value leads to nonrejection, not a finding that the slope is exactly zero. Statistical evidence for a nonzero slope does not establish causation, a large practical effect or accurate prediction.

To construct a slope interval, multiply the slope's standard error by the critical t value and subtract and add that margin to the estimated slope. A valid two-sided 95% t interval excludes zero when the matching two-sided test rejects at 5%. Both procedures depend on the model assumptions. Residual plots can warn of curvature or changing spread, but sampling design and observation order also matter when judging independence.

Explore more

2 · Watch

به انگلیسی

Take it off screen

Print a worksheetA4 with an answer key page for grown-ups. No screen, no internet.

Where it sits

Where this leads

Jobs that lean on this skill. Follow one to see everything it is built on.

Then practise

14 questions wait behind this lesson, each with its answer explained. Every answer feeds the sky: stars light as they are learned, and dim when it is time to come back.

Spotted a problem on this page? Tell us
Simple Linear Regression and Inference on the Slope · Mathematics, ages 21 to 22 · LightMySky