Statistics · AP Statistics
Inference for slopes
is the trend real?
A least-squares line describes one sample. Inference asks what that line says about the line for the whole population.
A teacher picks 18 students at random and records how many hours each studied for a test and the score each got. The more hours, the higher the score, on the whole. But is the trend real, or could a sample this small show it by chance?
The figure builds a population where the answer is known. The black line is its population regression line: the mean score at each number of hours. At each x the scores are spread normally about the line (the blue curves). Each student’s score is drawn from the curve at their hours.
The red line is fitted to the sample: slope b = 2.247, while the population’s slope is β = 2.5. In practice β is never known, and b is all we have.
This chapter states the model, shows how b varies from sample to sample, checks the conditions, builds a confidence interval for β, tests whether β = 0, reads it all off computer output, and ends with choosing the right procedure among all of the course’s.
a normal distribution of y at every x
Inference for a slope assumes a model: at each value of x, the responses y are normal, centred on a straight line, with the same spread.
α, β and σ are parameters: the intercept and slope of the population regression line, and the standard deviation of y about it, the same for every x. A sample estimates each with a statistic:
| parameter | statistic | in the figure |
| α (intercept) | a | 50 → 49.783 |
| β (slope) | b | 2.5 → 2.247 |
| σ (SD about the line) | s | 9 → 9.834 |
| μy (mean y at x) | ŷ | α + βx → a + bx |
β is the change in the mean score for each extra hour, across all the school’s students. Here β = 2.5: at 3 hours the mean is 57.5, at 5 hours 62.5.
s estimates σ from the residuals, dividing by n − 2 because two numbers (a and b) were estimated first:
The question behind every test in this chapter: do the points truly align, or would a slope like b turn up by chance even if β were 0?
the sampling distribution of b
Another sample of the same population gives another line, and another slope. The slopes from all possible samples form the sampling distribution of b.
In the figure the same 18 hours are kept and new scores drawn, 100 times. Each fitted line (red, then grey) tilts a little differently about the true line, and each slope drops into the dotplot.
When the model holds, the sampling distribution of b is normal, centred at β (b is an unbiased estimator), with standard deviation
where σx is the standard deviation of the x values (dividing by n). The 100 slopes have mean 2.47 and standard deviation 0.83, close to 2.5 and 0.81.
What makes b less variable: less scatter about the line (smaller σ), more spread in x (larger σx), and a larger sample. Spreading the x values out pins a line down better than bunching them.
σ is unknown, so it is replaced by s, and σx√n by sx√(n − 1). That gives the standard error of the slope, and standardizing with it gives a t distribution with n − 2 degrees of freedom:
LINER: linear, independent, normal, equal SD, random
The interval and the test are only trustworthy when the model fits. Check five conditions, each with the data, before any arithmetic.
| condition | how to check |
| Linear | scatterplot roughly straight; residual plot shows no curve |
| Independent | sampling without replacement: n ≤ 10% of the population |
| Normal | histogram or dotplot of the residuals: no strong skew or outliers |
| Equal SD | residual plot: no fan, the same scatter at every x |
| Random | a random sample or a randomized experiment |
For the 18 students: the residual plot (centre) is a patternless band about 0, with no curve and no fan, so the linear and equal-SD conditions are met. The histogram of residuals (right) has one peak and no strong skew; the largest residual is 21.2, about 2.2 s, not an extreme outlier. The students were a random sample, and 18 ≤ 10% of the 950 students at the school.
Common mistakes. Check normality on the residuals, not on x or y. There is no “n ≥ 30” rule that excuses a skewed residual plot here. A curved residual plot means the slope is the wrong summary: no interval can fix that.
Coef, SE Coef, T, P, S and R-Sq
Software prints the regression in a standard table. Every number this chapter needs is in it.
| Predictor | Coef | SE Coef | T | P |
| Constant | 49.783 | 4.749 | 10.48 | 0.000 |
| Hours | 2.247 | 0.883 | 2.55 | 0.022 |
| S = 9.834 R-Sq = 28.8% R-Sq(adj) = 24.4% |
Coef. The Constant row gives the intercept a; the row named for the explanatory variable gives the slope b:
SE Coef of Hours is SEb = 0.883. T = Coef/SE Coef = 2.55: the test statistic for H0: β = 0. P = 0.022 is its two-sided P-value.
S = s = 9.834: actual scores typically differ from the predicted score by about 9.8 points. R-Sq = r2: 28.8% of the variation in score is accounted for by the linear model on hours. Then r = +√0.288 = 0.537, positive like the slope.
Interpreting the slope: for each additional hour studied, the predicted score increases by about 2.247 points.
Common mistakes. The Constant row’s T and P test α = 0, rarely a question worth asking. S is not SEb. R-Sq(adj) is not needed in this course.
b ± t*·SEb, with n − 2 degrees of freedom
A confidence interval for β is the sample slope, plus or minus a margin of error.
Do. With n = 18, df = 16 and for 95% confidence t* = 2.120. From the output:
Conclude. We are 95% confident that the interval from 0.375 to 4.119 captures the slope of the population regression line relating test score to hours studied for students at this school. That is, the mean score rises by between 0.38 and 4.12 points for each extra hour.
The confidence level is about the method: in repeated samples, about 95% of intervals made this way capture β. On the right, 24 of 25 intervals from 25 samples do. One particular interval either captures β or does not.
The figure sweeps the level from 80% to 99%: a higher level needs a larger t* and gives a wider interval. At 99%, t* = 2.921 and the interval is (−0.332, 4.826).
A full answer names the procedure (a t interval for the slope), checks the conditions, does the arithmetic, and concludes in context.
is the claimed slope among the plausible values?
The values inside a confidence interval are the plausible values of β. A claimed value outside it is evidence against the claim.
Is there a relationship? If β = 0, the mean score does not change with hours: no linear relationship. 0 is not in the 95% interval (0.375, 4.119), and every value in it is positive. So the data give convincing evidence that β > 0: in the population, more hours go with higher mean scores.
At 99% the interval is (−0.332, 4.826). It contains 0, so at that level 0 is plausible: the evidence is not strong enough to rule out no relationship.
A claim. A tutoring company says each extra hour of study is worth 5 points on average. 5 lies above both intervals, so the data give convincing evidence against the claim: the true slope appears to be smaller.
A C% interval and a two-sided test at α = 1 − C agree: the test rejects β = β0 exactly when β0 is outside the interval. The interval says more: how big the slope plausibly is.
Common mistakes. A value inside the interval is plausible, not proven: “0 is in the interval, so there is no relationship” is wrong. And “there is a 95% probability that β is in the interval” is wrong: β is fixed; the 95% is the method’s capture rate.
H0: β = 0, against the alternative you set out to show
A significance test for the slope asks whether the sample slope is too far from a hypothesized value, usually 0, to be put down to chance.
The hypotheses are about the population slope β, never about b:
H0: β = 0 says there is no linear relationship: the mean of y is the same at every x. Define β in context: “the slope of the population regression line relating test score to hours studied for all students at the school”. Choose Ha from the question, before seeing the data.
The teacher asks whether score and hours are linearly related at all, so Ha: β ≠ 0, at α = 0.05. The procedure is a t test for the slope, with the same LINER conditions, checked in 9.2.
Why a test is needed. On the right is the world of H0: the true line is flat, and samples are drawn from it with the same hours and the same scatter as ours. Their fitted lines still tilt, by chance. Of 200 such samples, 3 had a slope as steep as ours, 2.247, in either direction. Our slope would be unusual if H0 were true.
H0 may name another value, β = β0, such as a claimed slope; the test is the same with β0 in place of 0.
t = (b − β0)/SEb, and P from the t distribution
The test statistic counts how many standard errors the sample slope lies from the hypothesized slope.
with df = n − 2 = 16. The output prints T = 2.55, from the unrounded b and SEb; either is fine.
The P-value is the probability, if H0 is true, of a t at least this far out. Ha is two-sided, so both tails count: P = 2P(t ≥ 2.55) = 0.022, as the output prints. In the figure the null samples of 9.4 drop their t values onto the t curve; 4 of 200, 0.020, land in the red tails.
Interpreting it. Assuming there is no linear relationship between hours and score in the population, there is a 0.022 probability of getting a sample slope at least as far from 0 as 2.247 by chance alone.
Conclude. Because P = 0.022 < α = 0.05, reject H0. There is convincing evidence of a linear relationship between hours studied and test score for students at this school.
Common mistakes. Never “accept H0”: fail to reject it. The P-value is not the probability that H0 is true. And these students chose their own study time: this was an observational study, so it shows an association, not that studying more causes higher scores. Only a randomized experiment supports cause.
when the printed P is not the answer
The output’s T and P answer one question: a two-sided test of β = 0. Other questions need a small step more.
One-sided. For Ha: β > 0, the P-value is one tail. When b is on the side Ha predicts, halve the printed P: 0.022/2 = 0.0110. When b is on the other side, the P-value is 1 minus that, and there is no evidence for Ha.
Another β0. To test the tutoring company’s claim, H0: β = 5 against Ha: β < 5, compute t by hand:
With df = 16: strong evidence that the true slope is less than 5, as the interval in 9.3 showed.
Test and interval agree. P = 0.022 < 0.05, and the 95% interval leaves out 0. P = 0.022 > 0.01, and the 99% interval takes 0 in.
Errors. A Type I error here would be concluding that hours and score are linearly related when in the population they are not; its probability is α. A Type II error would be missing a relationship that is there. Larger samples, more spread in x, and a larger α all make a Type II error less likely.
match the procedure to the question
Every procedure in the course answers one kind of question. Three questions about the data pick it out.
1. What was measured? A category for each individual (proportions, counts), a number (means), or two numbers for each individual (a slope). 2. How many samples or groups, and are they paired? 3. Estimate or test? “How large…” or “estimate…” asks for an interval; “is there convincing evidence…” for a test.
| procedure | when |
| 1-prop z | one categorical variable, one sample: p |
| 2-prop z | one categorical variable, two groups: p1 − p2 |
| χ² goodness of fit | one categorical variable, its whole distribution against a claim |
| 1-sample t | one quantitative variable, one sample: μ |
| paired t | two measurements on each individual: μdiff |
| 2-sample t | one quantitative variable, two independent groups: μ1 − μ2 |
| χ² homogeneity | one categorical variable, several separate samples or treatments |
| χ² independence | two categorical variables in one sample |
| t for slope | two quantitative variables, a linear relationship: β |
Clues in the wording: “proportion”, “percent” → z; “mean”, “average” → t; “relationship” between categorical variables → χ²; between quantitative variables → the slope.
Common mistakes. Paired data analysed as two samples (the same people measured twice are paired). Homogeneity and independence confused: it depends on the design, several samples or one. A correlation question needs the slope test, not a χ² test.
← Chi-square tests