Six constructed observations give a least-squares slope of exactly 2. Another sample from the same process would give a different slope, so how far from 2 could the slope of the process itself plausibly be, and is there evidence that it differs from zero? The least-squares calculation alone cannot say. An answer needs a model for how responses vary around their mean. This lesson states that model, estimates its error variance, and builds the standard error, the t test and the confidence interval for the slope, together with the conditions each one relies on.
Key terms
Simple linear regression model
Definition The simple linear regression model says that the responses at predictor values satisfy
for , where and are unknown parameters and the are random errors. Exact classical inference adds four conditions, all given the predictor values. The errors have mean zero, so that the mean response is the line . They are independent. They share one variance . And they are normally distributed. Together these say that the are independent with distribution . The predictor values are treated as fixed, or the analysis is carried out conditional on them, and at least two of them must differ. The slope is the change in the mean response per unit increase in .
In plain words The model splits each response into a systematic part on an unknown straight line and a random part. The least-squares line estimates the unknown line, and inference asks how far the estimate could be from it. The conditions concern the errors and the design. The predictor values themselves need not follow a normal distribution or any other. The slope describes how the mean response differs across predictor values, and it is a causal effect only when the design supports that reading.
Example Suppose a process followed the model with , and at the predictor values . The response at would then be normal with mean 7 and standard deviation 1. Each run of the process would give six new responses and a new least-squares slope, and over many runs those slopes would center on 2 with standard deviation . In practice , and are unknown, and the analysis has to work from one sample.
Error term
Definition In the simple linear regression model, the error term of observation is
the deviation of the response from the unknown population mean line. It cannot be observed, because and are unknown. The residual is the deviation from the fitted line and serves as an estimate of the error. The two differ. The residuals of a fit with an intercept satisfy and , while the errors need not sum to zero. Under the model each residual has variance , where is its hat value, and this is smaller than the error variance .
In plain words The error is the miss relative to the true line, and the residual is the miss relative to the line fitted to the same data. The fitted line is chosen to be as close as possible to these particular points, so the sum of squared residuals is never larger than the sum of squared errors.
Example The constructed sample has and . Its least-squares line is , with residuals , which add to zero and have squared sum 4. Suppose, only for illustration, that the population line were , something nobody could learn from the data. The errors would then be . They add to 1.5, not zero, and their squares add to 4.55, more than 4.
Residual standard deviation
Definition For a least-squares line fitted to observations, the residual standard deviation is
where SSE is the residual sum of squares. The divisor is the number of residual degrees of freedom. The residuals must satisfy the two equations and , one for each estimated coefficient. When the conditional mean is linear and the errors are independent with common variance , the residual variance is an unbiased estimator of , whether or not the errors are normal. The value is in response units and estimates . It is not the sample standard deviation of the responses.
In plain words The residual standard deviation estimates how far responses typically fall from the mean line. Dividing by instead of makes up for the fact that the fitted line was chosen to be close to these very points. The sample standard deviation of the responses measures spread around the overall mean and ignores the predictor, so the two answer different questions.
Example For the six observations, with degrees of freedom, so and response unit. The sample standard deviation of the responses is . Most of the variation in the responses follows the line, and .
Standard error of the slope
Definition Under the simple linear regression model with independent errors of common variance , the least-squares slope has mean and standard deviation over repeated samples at the same predictor values, where . Replacing by the residual standard deviation gives the standard error of the slope,
It has the units of the slope, response units per predictor unit.
In plain words The slope is pinned down better when the points scatter less around the line and when the predictor values are more spread out. Doubling doubles the standard error. Quadrupling halves it, for example by placing the same number of predictor values twice as far from their mean, as long as the straight-line model still holds over the wider range. Changing the unit of rescales the slope and its standard error by the same factor and adds no information. The standard error describes how much the fitted slope would vary between samples, not how much individual responses vary.
Example For the six observations, and , so
response units per predictor unit. Spreading the six predictor values to would give and, with the same , a standard error of , half as large. Crowding them into would give and a standard error of about , twice as large.
t test for a slope
Definition To test , most often with , compute
If and the conditions of the simple linear regression model hold, the statistic has the t distribution with degrees of freedom, written . For the two-sided alternative the p-value is with . It is the probability, computed assuming and the model, of a t statistic at least as far from zero as the one observed. For the statistic equals when , so for pairs sampled at random from a bivariate normal population the same statistic tests whether the population correlation is zero.
In plain words The t statistic counts how many standard errors the fitted slope lies from the hypothesized value. A small p-value says that data like these would be unusual if the model held with that slope. It is not the probability that is true, and it does not show that the predictor causes the response, since confounding, selection or a wrong form of the model can produce a nonzero slope. A large p-value does not show that the slope is zero, only that these data do not rule zero out. A zero slope means no linear trend in the mean, not no relationship, since a symmetric curve can have a least-squares slope of zero.
Example For the six observations, test against . The statistic is
with 4 degrees of freedom, and the two-sided p-value is about 0.0011. If the model held with a zero slope, a t statistic at least this far from zero would occur in about 0.11 percent of samples. That is strong evidence against a zero slope within this model, and it says nothing about why the responses rise with .
Confidence interval for a slope
Definition Under the same conditions, the confidence interval for with level is
where is the quantile of . Over repeated samples at the same predictor values, the procedure captures in a proportion of the samples. The interval leaves out a value exactly when the two-sided t test of gives . Its endpoints are in response units per predictor unit.
In plain words The interval lists the model slopes that are compatible with the data at the chosen level. The 95 percent describes how often the method succeeds over repeated samples. It is not a 95 percent probability that this particular interval contains , and the interval does not mark where 95 percent of the responses or of the fitted slopes fall. Whether the slopes in it matter in practice depends on the units and the application.
Example For the six observations, , so the margin is
and the 95 percent interval is , about response units per predictor unit. Every slope in it is positive, which matches the small p-value of the test.
Check yourself
- Another fitted slope is with and 4 residual degrees of freedom. Find the t statistic for and the 95 percent interval, using . Does the interval exclude zero, and what does the result say about the association?
Show the answer
The statistic is . It is smaller than , so the two-sided test at the 5 percent level does not reject, and the p-value is about .
The margin is , so the interval is about . Zero lies inside it.
The estimate is positive, but the data do not pin down well enough to rule out a zero or slightly negative slope, and they also allow slopes as large as about . This is uncertainty, not evidence that the association is absent. A report should give the estimate with its units, the interval, the design and the conditions behind the t reference.
- An observational study of constructed data reports the 95 percent interval for and the p-value for . Which of these readings are correct? First, there is a 95 percent probability that lies between 0.4 and 1.6. Second, the probability that the slope is zero is 0.002. Third, raising by one unit for any individual would raise by between 0.4 and 1.6 units. Fourth, if the model holds, the procedure that produced the interval captures in 95 percent of repeated samples.
Show the answer
Only the fourth reading is correct.
The first treats as random. Here is a fixed unknown number, and the 95 percent belongs to the procedure. A probability statement about itself needs a Bayesian analysis with a prior, which gives a credible interval instead.
The second confuses the p-value with the probability of the null. The value is the probability, computed assuming a zero slope and the model, of a t statistic at least as far from zero as the observed one.
The third reads an association as a causal effect. In an observational study other factors that vary with can produce the slope, and the slope compares individuals with different values of rather than describing a change made to one individual.
- A constructed sample of 12 days gives a least-squares slope of 0.8 kilowatt hours per degree Celsius for a building’s daily electricity use against the outdoor temperature, with residual standard deviation kilowatt hours and squared degrees. Find the standard error, the t statistic for a zero slope and the 95 percent interval, using . How would the interval change if the 12 days had temperatures spread twice as far from their mean, with the same residual standard deviation? Would a narrower interval show that warmer days cause higher use?
Show the answer
The standard error is kilowatt hours per degree, and with degrees of freedom, a two-sided p-value of about . The margin is , so the interval is about kilowatt hours per degree.
Spreading the temperatures twice as far from their mean doubles every deviation , so becomes 400 and the standard error becomes . The margin halves to about , so if the new sample again gave the estimate 0.8, the interval would be about . This assumes that the straight line with the same error spread still holds over the wider range of temperatures, which needs checking, since use may rise again on cold days.
A narrower interval estimates the association more precisely, but it is still an association in observational data. Season, daylight and occupancy also change with temperature, so the regression alone does not show how much warming by itself changes electricity use.