Interval for a slope
A sample of trees gives a fitted slope. What range of values for the true rate of change across the whole orchard does that one slope support?
Where you are 4 in Inference for slopes
When you reach for it
Jordi grows almonds in Catalonia. He takes a random sample of 14 trees from his orchard of 2{,}400 and records each tree’s trunk circumference x, in centimeters, and its kernel yield y that season, in kilograms (made-up data). Bigger trunks go with bigger harvests, and a statistics program prints:
As Reading regression output showed, the slope sits in the Coef column of the Circumference row: in these 14 trees, each extra centimeter of circumference goes with 0.052 kg more predicted yield. But Jordi cares about all 2{,}400 trees, and a different 14 would have given a different slope. What he wants is the rate for the whole orchard, given as an estimate with a margin of error. The interval for a mean in One sample interval for a mean and sample size had the shape estimate \pm\ t^* \times standard error; the interval for a slope has the same shape, with the slope as the estimate.
The procedure
Day 1: the interval from computer output
The parameter. The model behind regression inference, from Sampling distribution of the slope, is a population line \mu_y = \alpha + \beta x: at each circumference, the mean yield of all trees of that circumference in the orchard lies on this line. Its slope \beta is the parameter. In context, \beta is the change in mean kernel yield for each additional centimeter of trunk circumference, among all trees in Jordi’s orchard. The sample slope b estimates it.
The interval. A level-C confidence interval for \beta is
The standard error SE_b is the slope row’s entry in the SE Coef column. It estimates \displaystyle \sigma_b = \dfrac{\sigma}{s_x\sqrt{n - 1}}, the spread of b across samples, with s standing in for the unknown \sigma. Because s varies from sample to sample too, the standardized slope \dfrac{b - \beta}{SE_b} follows a The t distribution and degrees of freedom rather than the standard normal curve, and t^* is its Critical value for the chosen level.
Why n - 2. The degrees of freedom are those of s. In the interval for a mean, s_x was built from deviations from one estimated quantity, \bar{x}; the deviations had to add to 0, so only n - 1 of them were free. Here \displaystyle s = \sqrt{\text{SSE}/(n - 2)} is built from residuals, and residuals are measured from a line whose two numbers, a and b, were fitted from the same data. Least squares forces two facts on the residuals e: they add to 0, and \sum (x - \bar{x})\,e = 0. Two restrictions leave n - 2 residuals free. The extreme case shows it plainly: with n = 2 the line passes through both points, both residuals are 0, and nothing at all is learned about \sigma.
The conditions. The level is honest only under the five conditions of Conditions for regression inference, LINER: a Linear trend in the means, Independent observations (sampling without replacement from no more than a tenth of the population), Normal residuals at each x, Equal spread of residuals, and a Random sample or random assignment. They are checked with the scatter plot, the residual plot, and a dot plot or histogram of the residuals.
Conclude in context. The slope’s units are units of y per unit of x, and the sentence says so: “We are 95\% confident that, among all trees in the orchard, mean kernel yield increases by between ... and ... kg for each additional centimeter of trunk circumference.” What the 95\% means, a capture rate of the method over all possible samples, is the subject of Confidence level and interpreting an interval.
Day 2: the interval from raw data, and its width
Computing SE_b by hand. With the data in front of you rather than a printout, fit the line, find the residuals and \displaystyle s = \sqrt{\text{SSE}/(n - 2)}, find s_x, and then
The fit itself is the one in Slope from r and the spreads, and regression to the mean; the slope can also be found as b = \dfrac{\sum (x - \bar{x})(y - \bar{y})}{\sum (x - \bar{x})^2}, which is the same number. A graphing calculator’s LinRegTInt command does all of it and prints the interval, along with b, \text{df}, s, a, r squared and r. It does not print SE_b, but half the width of the interval divided by t^* recovers it.
An interval that contains 0. A slope of 0 means the mean of y is the same at every x: no linear relationship. If 0 lies outside the interval, every plausible slope has the same sign, and the data give convincing evidence of a linear relationship in that direction. If 0 lies inside, the data are consistent with no linear relationship, and also with slopes of either sign; they do not show that \beta = 0.
What sets the width. The margin is \displaystyle t^* \cdot \dfrac{s}{s_x\sqrt{n - 1}}. Read off the formula:
- more scatter about the line, larger s, gives a proportionally wider interval;
- a wider spread of x values, larger s_x, gives a proportionally narrower one, because points far apart in x pin the slope down the way a long lever pins down an angle;
- a larger sample narrows it through \displaystyle \sqrt{n - 1} and through a smaller t^*, so four times the sample roughly halves the width;
- a higher confidence level widens it through t^* alone.
Worked examples
Day 1: Jordi’s interval
Use Jordi’s printout to construct and interpret a 95\% confidence interval for the slope of the population line. His scatter plot is a straight band, the residual plot shows no curve and no fan, and a dot plot of the residuals is roughly symmetric with no outliers.
SolutionParameter. \beta is the change in mean kernel yield, in kilograms, for each additional centimeter of trunk circumference, among all 2{,}400 trees in Jordi’s orchard.
Conditions. Linear: the scatter plot and residual plot show a straight trend. Independent: 14 trees sampled without replacement is under a tenth of 2{,}400. Normal: the residuals’ dot plot has no strong skew or outliers. Equal spread: no fan in the residual plot. Random: a random sample. All five are met.
Compute. From the Circumference row, b = 0.052 and SE_b = 0.011. With \text{df} = 14 - 2 = 12, the t table gives t^* = 2.179 at 95\%. The margin of error is 2.179 \times 0.011 = 0.023969 \approx 0.024, so the interval is
Conclude. We are 95\% confident that, among all trees in Jordi’s orchard, mean kernel yield increases by between 0.028 and 0.076 kg for each additional centimeter of trunk circumference. Figure 1 draws the two ends as lines; both rise, so the interval contains only positive slopes.
Day 1: other levels and a more useful unit
A centimeter of trunk is a small step. Restate Jordi’s 95\% interval per 10 cm of circumference, then give the 90\% and 99\% intervals.
SolutionThe slope is a rate, so 10 cm multiplies both ends by 10: we are 95\% confident that each additional 10 cm of circumference goes with between 0.28 and 0.76 kg more mean yield.
Only t^* changes with the level; b and SE_b are the same. At \text{df} = 12, the table gives t^* = 1.782 at 90\% and 3.055 at 99\%.
The intervals are nested, and even the widest stays above 0.
Day 1: a falling slope in another layout
Nuria, a neighbor of Jordi’s, takes a random sample of 12 almond orchards in her district (made-up data). For each she records x, the number of hours below freezing during bloom, and y, the mean kernel yield per tree in kilograms. Her program prints:
The conditions are met. Construct and interpret a 95\% interval for \beta.
SolutionHere Estimate plays the part of Coef and Std. Error that of SE Coef, so b = -0.0611 and SE_b = 0.0138. This program even prints the degrees of freedom: 10 = 12 - 2. The table gives t^* = 2.228, and 2.228 \times 0.0138 = 0.0307464 \approx 0.0307, so
Both ends are negative. We are 95\% confident that, across orchards in the district, mean kernel yield per tree falls by between 0.030 and 0.092 kg for each additional hour below freezing during bloom. The orchards were sampled, not assigned frost, so this is an association; frost and yield may also share causes such as the height of the land.
Day 2: Nuria’s eight trees, from the raw data
Nuria plants a newer almond variety and measures a random sample of 8 of its 600 trees (made-up data), circumference x and kernel yield y. The product column is (x - \bar{x})(y - \bar{y}).
| x (cm) | y (kg) | product | residual |
|---|---|---|---|
| 62 | 2.6 | 31.875 | -0.087 |
| 70 | 3.4 | 8.075 | 0.333 |
| 78 | 3.0 | 7.875 | -0.447 |
| 84 | 3.9 | -0.075 | 0.168 |
| 90 | 4.2 | 0.975 | 0.182 |
| 96 | 4.0 | 1.125 | -0.303 |
| 104 | 4.9 | 17.425 | 0.217 |
| 112 | 5.0 | 28.125 | -0.063 |
Find a 95\% interval for the slope of the population line, assuming the conditions hold.
SolutionMeans. The circumferences add to 696, so \bar{x} = 87 cm; the yields add to 31.0, so \bar{y} = 3.875 kg.
Slope. The deviations x - \bar{x} are -25, -17, -9, -3, 3, 9, 17, 25. The products in the third column, each x - 87 times y - 3.875, add to 95.4, and the squared deviations of x add to 625 + 289 + 81 + 9 + 9 + 81 + 289 + 625 = 2008. So
Residuals and s. Each residual is y - \hat{y} with \hat{y} = -0.258 + 0.04751x; the last column lists them. Their squares add to \text{SSE} \approx 0.5225, so \displaystyle s = \sqrt{0.5225/6} \approx 0.2951 kg, dividing by n - 2 = 6 for the two fitted numbers.
Standard error. \displaystyle s_x = \sqrt{2008/7} \approx 16.937 cm, and
Interval. At \text{df} = 6, t^* = 2.447, so the margin is 2.447 \times 0.00659 \approx 0.0161 and the interval is 0.04751 \pm 0.0161, from 0.0314 to 0.0636 kg per cm. We are 95\% confident that, among all 600 trees of the new variety, mean kernel yield rises by between 0.031 and 0.064 kg per additional centimeter of circumference.
Day 2: the calculator’s screen
Nuria enters the same eight trees into a graphing calculator and runs LinRegTInt at 95\%. The screen shows
Match it with the hand computation and recover SE_b.
SolutionThe pair in parentheses is the interval, 0.03140 to 0.06362, which agrees with the hand result 0.0314 to 0.0636. Its midpoint is \dfrac{0.03140 + 0.06362}{2} = 0.04751, the slope b: the interval is centered on the estimate. The screen’s \text{df} = 6, s and a match too, and r squared says the line accounts for about 89.7\% of the variation in yield among these trees.
The screen gives no SE_b, but the half-width is \dfrac{0.06362 - 0.03140}{2} = 0.01611, and dividing by t^* = 2.447 gives SE_b \approx 0.00658, the hand value apart from rounding.
Day 2: an interval that contains zero
Oriol wonders whether trees near the edge of his orchard, beside a hedgerow, yield differently from trees deeper inside. He measures a random sample of 10 trees at distances from 5 to 100 m from the edge (made-up data):
With the conditions met, construct a 95\% interval for \beta and say what it shows.
Solutionb = -0.0071 kg per meter, SE_b = 0.0062, \text{df} = 8 and t^* = 2.306. The margin is 2.306 \times 0.0062 = 0.0142972 \approx 0.0143, so the interval runs from -0.0071 - 0.0143 = -0.0214 to -0.0071 + 0.0143 = 0.0072 kg per meter.
The interval contains 0. A flat population line is plausible, so these data give no convincing evidence of a linear relationship between distance from the edge and yield (Figure 2). They do not show there is none: across the 95 m studied, the plausible change in mean yield runs from a drop of 95 \times 0.0214 \approx 2.03 kg to a rise of 95 \times 0.0072 \approx 0.68 kg, which includes effects a grower would care about. Ten trees cannot settle the question; more trees would narrow the interval.
Day 2: what makes the interval narrower
Jordi plans next season’s study. His sample had s = 0.851 kg and s_x = 20.90 cm, so \displaystyle SE_b = \dfrac{0.851}{20.90\sqrt{13}} \approx 0.01129 and the 95\% margin was 2.179 \times 0.01129 \approx 0.0246. Find the margin, assuming s and s_x come out the same unless stated, if he (a) samples 56 trees; (b) keeps 14 trees but picks them at random within size classes so that s_x = 30 cm; (c) keeps the first design but works in an orchard whose yields scatter more, s = 1.2 kg.
Solution(a) \displaystyle SE_b = \dfrac{0.851}{20.90\sqrt{55}} \approx 0.00549, and at \text{df} = 54, t^* = 2.005, so the margin is about 0.0110. Four times the trees gives less than half the margin: \displaystyle \sqrt{n - 1} roughly doubles, and t^* falls as well.
(b) \displaystyle SE_b = \dfrac{0.851}{30\sqrt{13}} \approx 0.00787 and the margin is 2.179 \times 0.00787 \approx 0.0171. Spreading the trunks over a wider range narrows the interval without measuring a single extra tree. Choosing the x values is allowed, because the conditions concern y at each x; the interval then describes only the range of circumferences covered.
(c) \displaystyle SE_b = \dfrac{1.2}{20.90\sqrt{13}} \approx 0.01592 and the margin is 2.179 \times 0.01592 \approx 0.0347: about 1.41 times as wide, the same as \dfrac{1.2}{0.851}, since the width is proportional to s.
Boundaries
- The stated level holds only under the five conditions. If the trend curves, \beta is not a single rate at all, and no interval for it means anything.
- The interval is about the population that was sampled and the range of x observed. Jordi’s describes trees of 64 to 134 cm in his orchard, not saplings and not another farm.
- A slope from observational data is an association; reading \beta as the effect of changing x needs random assignment.
- An interval that contains 0 does not show that \beta = 0.
- \text{df} = n - 2 is for one explanatory variable. A line with k explanatory variables fits k + 1 numbers and has n - k - 1 degrees of freedom.
- The interval estimates the slope only. It is not an interval for one tree’s yield or for the mean yield at a given circumference; those use other standard errors.
Where this goes next
The interval asks which slopes are plausible; Test for a slope asks whether one particular slope, usually 0, is. Its statistic is \dfrac{b - 0}{SE_b}, the T column of the printout, with the same n - 2 degrees of freedom, and a two-sided test at the 0.05 level rejects \beta = 0 exactly when the 95\% interval leaves 0 out.
Exercises
Oriol records, for a random sample of 16 trees in his orchard, the water each received over the season, 18 to 38 cubic meters, and its kernel yield in kilograms (made-up data). Output A:
Nuria records, for a random sample of 20 trees, the percent of nuts damaged by insects, 1 to 25, and the kernel yield in kilograms (made-up data). Output B:
Assume the conditions hold unless an exercise says otherwise.
Day 1: intervals from output
- For Output A, define \beta in context and give the degrees of freedom.
- Construct and interpret a 95\% interval for \beta from Output A.
- Construct a 90\% interval from Output A and compare its width with the 95\% one.
- Restate your 95\% interval from Exercise 2 per 5 cubic meters of water.
- Construct and interpret a 95\% interval for \beta from Output B.
- Construct a 99\% interval from Output B. Does it contain 0?
- A printout comes from 25 cases. Give the degrees of freedom and t^* for a 95\% interval for the slope.
- A classmate uses \text{df} = 15 for Output A. Give the correct t^* at 95\% and the classmate’s, and say which way the error moves the interval.
Day 2: raw data, the calculator, and width
- Oriol measures 7 young trees of ages 4, 6, 7, 9, 10, 12 and 15 years, with kernel yields 1.2, 2.0, 2.1, 2.9, 2.8, 3.6 and 4.1 kg (made-up data). Find b and a for the line predicting yield from age.
- For the trees in Exercise 9 the squared residuals add to 0.1524. Find s, s_x and SE_b.
- Construct and interpret a 95\% interval for \beta from Exercises 9 and 10.
- Jordi measures 10 trees of another variety (made-up data) and runs LinRegTInt at 90\%. The screen shows (0.03380,\ 0.05939), b = 0.04660, \text{df} = 8, s = 0.41705, a = -0.27405, r^2 = 0.85140, r = 0.92272. Find the margin of error, t^* and SE_b.
- From the screen in Exercise 12, find n and the standard deviation s_x of the circumferences.
- Oriol regresses yield on the steepness of the ground under each of 11 trees, 0 to 15 degrees. The slope row reads Coef -0.0176, SE Coef 0.0300. Construct a 95\% interval and say what it shows.
- If Oriol had measured 64 trees for Output A, with the same s and s_x, by what factor would SE_b change? By what factor the 95\% margin?
- If Oriol kept 16 trees but chose water amounts with twice the standard deviation, what would happen to SE_b and to the margin?
- Jordi wants a 95\% margin of at most 0.015 kg per cm. Taking s = 0.85 and s_x = 21, find the smallest number of trees that achieves it.
Reasoning
- Explain why the degrees of freedom for a slope are n - 2, while those for a mean are n - 1.
- A friend reads Jordi’s interval as “95\% of trees gain between 0.028 and 0.076 kg per centimeter”. Explain what the interval says instead.
- Without computing it, explain why an 80\% interval for \beta from Output B must also leave out 0.
- Oriol’s residual plot for Output A fans out, wider at large water amounts. Which condition fails, and why does it matter for the interval?
- Explain, with a picture of two samples, why a wider spread of x values gives a narrower interval for the slope.
Answers
- \beta is the change in mean kernel yield, in kilograms, for each additional cubic meter of water over the season, among all trees in Oriol’s orchard. \text{df} = 16 - 2 = 14.
- t^* = 2.145; 0.174 \pm 2.145(0.030) = 0.174 \pm 0.064, from 0.110 to 0.238 kg per cubic meter. We are 95\% confident that each additional cubic meter of water goes with between 0.110 and 0.238 kg more mean kernel yield per tree in the orchard.
- t^* = 1.761; 0.174 \pm 0.053, from 0.121 to 0.227. Its width is about 0.106 against 0.129 at 95\%: a lower level, a narrower interval.
- Multiply both ends by 5: between 0.55 and 1.19 kg more mean yield per 5 cubic meters.
- \text{df} = 18, t^* = 2.101; -0.0693 \pm 0.0292, from -0.0985 to -0.0401. We are 95\% confident that each additional percentage point of damaged nuts goes with mean kernel yield lower by between 0.040 and 0.099 kg per tree.
- t^* = 2.878; -0.0693 \pm 0.0400, from -0.1093 to -0.0293. No, 0 is outside: every plausible slope is negative.
- \text{df} = 23, t^* = 2.069.
- Correct: \text{df} = 14, t^* = 2.145. The classmate’s \text{df} = 15 gives t^* = 2.131, slightly too small, so the interval is slightly too narrow and its true capture rate a little below 95\%.
- \bar{x} = 9, \bar{y} = 18.7/7 \approx 2.6714; \sum (x - \bar{x})^2 = 84 and \sum (x - \bar{x})(y - \bar{y}) = 22, so b = 22/84 \approx 0.2619 kg per year and a = 2.6714 - 0.2619(9) \approx 0.314.
- \displaystyle s = \sqrt{0.1524/5} \approx 0.1746 kg; \displaystyle s_x = \sqrt{84/6} \approx 3.742 years; \displaystyle SE_b = \dfrac{0.1746}{3.742\sqrt{6}} \approx 0.01905.
- \text{df} = 5, t^* = 2.571; 0.2619 \pm 0.0490, from 0.2129 to 0.3109 kg per year. We are 95\% confident that, for trees aged 4 to 15 years in this orchard, mean kernel yield rises by between 0.213 and 0.311 kg per additional year of age.
- Margin = \dfrac{0.05939 - 0.03380}{2} \approx 0.0128; t^* = 1.860 at \text{df} = 8 and 90\%; SE_b = 0.0128/1.860 \approx 0.00688. The midpoint, 0.04660, is b.
- n = \text{df} + 2 = 10. From \displaystyle SE_b = \dfrac{s}{s_x\sqrt{n - 1}}, s_x = \dfrac{0.41705}{0.00688 \times 3} \approx 20.2 cm.
- \text{df} = 9, t^* = 2.262; -0.0176 \pm 0.0679, from -0.0855 to 0.0503 kg per degree. It contains 0: the data are consistent with no linear relationship between steepness and yield, and also with sizable slopes of either sign, so they settle nothing.
- SE_b is multiplied by \displaystyle \sqrt{15/63} \approx 0.488, about half. The margin also gains a smaller t^*, 1.999 at \text{df} = 62 against 2.145, so it is multiplied by about 0.488 \times 1.999/2.145 \approx 0.455.
- SE_b halves, since s_x is in the denominator. With n unchanged, t^* is unchanged, so the margin halves too.
- 32 trees. With t^* \approx 2, \displaystyle \sqrt{n - 1} \ge \dfrac{2(0.85)}{21(0.015)} \approx 5.40 suggests n = 31, but the true t^* at \text{df} = 29 is 2.045 and gives a margin of about 0.0151. At n = 32, t^* = 2.042 and the margin is about 0.0148.
- Degrees of freedom count the independent pieces left after estimating. A mean’s deviations come from one estimate, \bar{x}, and must add to 0, leaving n - 1 free. Regression residuals come from a line with two fitted numbers, a and b, and satisfy two equations, \sum e = 0 and \sum (x - \bar{x})e = 0, leaving n - 2 free; s divides by n - 2 for that reason.
- The interval is about one number, the slope of the population line: how much the mean yield of all trees changes per centimeter. It says nothing about the share of individual trees, which scatter about the line by about \text{S} = 0.851 kg. The 95\% describes the method: intervals built this way capture \beta in 95\% of samples.
- All levels use the same center b and the same SE_b; a lower level only uses a smaller t^*. So the 80\% interval sits inside the 95\% one from Exercise 5, which lies entirely below 0.
- Equal spread fails. SE_b uses one s for every x, so with a fan it misstates how much b varies from sample to sample, and the true capture rate is no longer the stated level.
- Picture two samples with the same scatter about the same line, one with x values bunched together and one spread far apart. With bunched points, moving one y up or down tilts the fitted line a lot, so the slope swings from sample to sample. With spread points, the same vertical scatter changes the slope little, as a long ruler resting on two far-apart points barely tilts when one end is nudged. Less swing in b is a smaller \displaystyle SE_b = \dfrac{s}{s_x\sqrt{n - 1}}, and a narrower interval.