StatisticsInference for Regression and Several Means1 of 3
Inference for Regression and Several Means · 1
Inference for the Regression Slope
When we fit a regression line to a small sample, we need a way to tell whether its tilt reflects a real trend in the whole population or just the luck of which points we happened to pick.
1
Sample Slope vs. Population Slope
Suppose we take a random sample of n=10 people to see how hours of screen time before bed (x) relate to sleep quality score the next morning (y), and we find a least-squares regression line with a slope of b=−4. Does screen time actually go with worse sleep across the entire population, or could a completely flat population line produce a sample slope of −4 just by random chance?
Sample Slope vs. Population Slope
In our sample of 10 people, the sample slope is known (b=−4, sometimes written b1), while the true slope for the entire population is an unknown parameter β (or β1) that tracks how the population's average y changes for each 1-unit increase in x.
Because every random sample of 10 people picks a different set of points, the sample slope b wobbles from sample to sample around the true slope β. That gives us two questions to answer about β:
Hypothesis test: Could a flat population line (β=0) easily give a sample slope as far away as b=−4 by random luck?
Confidence interval: About how steep is the true population slope β?
2
Standard Error of the Slope
To tell whether b=−4 is unusually far from 0, we first need to find the standard error of the slope (SEb), which is the typical amount the sample slope b wobbles from one random sample to the next. Three features of our sample control how much the line wobbles.
Standard Error of the Slope
Putting the vertical scatter around the line on top and the two anchoring factors on the bottom gives the standard error of the slope:
SEb=horizontalspread of xsx⋅n−1svertical scatterof residuals
Here s measures the typical vertical distance of the points from the sample line, calculated using df=n−2 degrees of freedom because the first 2 points are used up just to fix a straight line (2 points alone always have zero scatter). For our n=10 people, SEb=1.5, meaning sample slopes from random groups of 10 people naturally vary around β by about 1.5 points per hour.
Try changing the spread of the x-values to see how anchoring the ends of the line shrinks SEb.
For the same vertical scatter around the true line, spreading the sampled X-values wider apart holds the sample lines closer together and shrinks the standard error of the slope.
3
Conditions for Regression Inference
Before we can trust SEb=1.5 and use a t-distribution with df=n−2, we have to check that our data meets the four assumptions behind them. We check the first three on two graphs of the residuals: the residual plot (residuals against x) and a dotplot or histogram of the residuals themselves. We check the fourth from how the sample was collected.
Conditions for Regression Inference
Each condition checks a specific part of our t-procedure:
Linearity (residual plot shows random scatter around 0 with no curved U-shape or arch): If the true pattern curves, the slope of a straight line makes no sense.
Equal variance / constant scatter (residual plot keeps roughly the same vertical spread from left to right, with no megaphone fan-out): The formula for SEb uses a single number s for vertical scatter everywhere along the line.
Normality of residuals (dotplot, histogram, or normal probability plot of the residuals shows no heavy skew or extreme outliers): In a small sample, a single extreme residual pulls the line toward it and throws off the t-distribution.
Random and independent (random sample under 10% of the population, with no paired or grouped subjects): Paired observations, like 5 married couples in the same household, do not give 10 independent pieces of information.
Try dragging one point far from the line to see how a single outlier in a small sample pulls the slope b and inflates s.
In a small sample of 10, a single outlier can pull the slope like a seesaw, widen the vertical scatter, and stand out alone in the residuals.
4
Hypothesis Test for the Slope
With all four conditions met, we can test our first question: could a flat population line (β=0, no linear relationship) produce a sample slope as steep as b=−4 just by random sampling luck?
Hypothesis Test for the Slope
Text solution
Set the hypotheses for the unknown population slope βTest the flat population line (β=0) against a two-sided alternative (or use Ha:β<0 if a negative direction was suspected before looking at the data).
H0:β=0Ha:β=0
Divide the distance from β0=0 by the standard error SEbThis counts how many standard errors our sample slope b=−4 sits from a flat line.
t=SEbb−β0=1.5−4−0=−2.67
Find the two-tail area under the t-distribution with n−2 degrees of freedomUsing df=10−2=8, combine the tail areas beyond −2.67 and +2.67 to get the p-value.
df⟹p-value=10−2=8=0.028
Because 0.028<0.05, we reject H0:β=0: a flat population line would produce a sample slope at least this far from 0 by random chance only 2.8% of the time, giving convincing evidence of a linear relationship between screen time before bed and sleep quality in the population.
5
Confidence Interval for the Slope
Rejecting β=0 gives us convincing evidence that the population line isn't flat, so our next goal is to estimate how steep the true population slope β actually is by building a 95% confidence interval around b=−4.
Confidence Interval for the Slope
Text solution
Look up the critical value t∗ for n−2 degrees of freedomFor 95% confidence with df=10−2=8,t∗ gives how many standard errors capture the middle 95% of random sample slopes.
t∗=2.31(for df=8)
Multiply t∗ by SEb to get the margin of errorThis is the farthest we expect b to wobble from β in 95% of samples.
Margin of error=t∗⋅SEb=2.31⋅1.5=3.46
Add and subtract the margin of error from the sample slope bCenter the interval at b=−4 to catch the plausible values of β.
b±t∗⋅SEb=−4±3.46=(−7.46,−0.54)
We are 95% confident that in this population, for every 1-hour increase in screen time before bed, the average sleep quality score is lower by between 0.54 and 7.46 points. Notice two words to be careful with: we say average sleep score rather than an individual person's score, and we never say screen time causes the drop because our data came from an observational study rather than a randomized experiment.
Slide the sample slope b to see how the 95% confidence interval and the two-sided test at α=0.05 always agree on β=0.
A 95% confidence interval for the slope stays completely off 0 at the exact tilts where the two-sided p-value drops below 0.05.
6
Reading Computer Regression Output
In practice, software computes SEb,t, and the p-value for us, so we just need to pull the right numbers out of a computer regression table.
vertical scatter of pointsaround the lines=6.12R-Sq=47.1%
Text solution
Read the slope numbers from the explanatory variable's row (`Screen Time`), ignoring the `Constant` rowThe `Constant` row is for the y-intercept a in y^=a+bx, while the `Screen Time` row gives b,SEb, and t for the slope, and s=6.12 below the table gives the typical vertical distance of points from the line.
bSEbt=−4.00,=1.50,=1.50−4.00=−2.67
Divide the table's `P` by 2 when testing a one-sided alternativeComputer output always gives the two-sided p-value for Ha:β=0, so when b=−4.00 points in the direction of a one-sided Ha:β<0, we take half the two-tail area.
One-sided p-value=20.028=0.014
So for a one-sided test of Ha:β<0, the p-value is 0.014.
Key concepts
Every inference problem on a regression slope asks about the unknown population slope β using the known sample slope b (such as b=−4 for our n=10 screen-time points) and its standard error SEb=sxn−1s=1.5 with df=n−2=8 degrees of freedom.
When you can use t-procedures, and when to stop
First check that the residual plot has no curved pattern (Linearity) and no megaphone fan-out (Equal variance), that a dotplot or histogram of the residuals (not x) has no heavy skew or extreme outliers (Normality), and that the n observations were sampled independently rather than in pairs like twins or couples (Random and independent). If the residual plot fans out or the subjects come in pairs, stop: the formula for SEb does not work.
Testing whether a linear relationship exists (H0:β=0)
Count how many standard errors b sits from 0 using t=SEbb−0=1.5−4=−2.67 with df=n−2=8. Use both tails for Ha:β=0 (p=0.028), or half of the computer table's two-sided `P` when b matches a one-sided alternative set beforehand (Ha:β<0⟹p=20.028=0.014).
Estimating how steep β is (b±t∗⋅SEb)
Multiply t∗ (from df=n−2) by SEb to get the margin of error (−4±2.31(1.5)=(−7.46,−0.54)). Describe the interval as the change in the population averagey for each 1-unit increase in x, never as cause-and-effect in an observational study. And if a question simply asks for the typical vertical distance of data points from the regression line, read s=6.12 directly; do not compute SEb or a confidence interval.
7
Practice
1
Before collecting data from a random sample of 15 mountain streams, a biologist suspects that higher water temperature (°C) is associated with lower dissolved oxygen (mg/L). After finding a sample slope of b=−0.32 from the data, a student writes the hypotheses as H0:b=0 and Ha:b<0. Identify the error in the student's hypotheses, write the correct hypotheses, and define the parameter in context.
Ask yourself which slope is already known from the 15 streams and which slope is still unknown for all mountain streams.
Hypotheses must be statements about the unknown population slope β, never the known sample slope b=−0.32 (and be careful not to plug the sample value −0.32 into the hypotheses as H0:β=−0.32, or use Ha:β=0 when a negative direction was suspected beforehand). Because the biologist suspected a negative relationship before collecting data, the correct hypotheses are:
H0:β=0Ha:β<0
where β is the true slope of the population regression line relating water temperature (°C) to average dissolved oxygen (mg/L) across all such mountain streams.
2
For a random sample of n=17 used cars, a linear regression predicting price (in thousands of dollars) from mileage (in thousands of miles) gives a sample slope of b=−0.18, residual standard deviation s=2.4, and standard deviation of mileage sx=15.0. Calculate the standard error of the slope (SEb), the test statistic t for testing H0:β=0, and the degrees of freedom for the t-distribution.
First find SEb, being careful to use n−1=16 in the denominator rather than n−2=15 (which would give SEb≈0.0413 and t≈−4.36).
Check which number goes under the square root in the denominator of SEb, and which number counts the degrees of freedom for a line.
First find SEb, being careful to use n−1=16 in the denominator rather than n−2=15 (which would give SEb≈0.0413 and t≈−4.36):
SEb=sx⋅n−1s=15.0⋅17−12.4=15.0⋅42.4=0.04
Next divide the sample slope by SEb to find t, and subtract 2 (not 1, which would give df=16) for the two points needed to fix a line:
tdf=SEbb−β0=0.04−0.18−0=−4.50,=n−2=17−2=15
3
An agronomist takes a random sample of n=12 corn plots to study the linear relationship between fertilizer amount (x) and yield (y). (a) In the residual plot (residuals vs. fertilizer), the points stay close to the zero line on the left but fan out widely like a megaphone on the right. Which condition is violated, and why does this break the formula for SEb? (b) To check the normality condition, the agronomist checks a dotplot of the 12 fertilizer amounts (x-values) and sees that it is roughly symmetric with no outliers. Explain what is wrong with this check and what graph she should inspect instead.
(a) Look at the numerator of SEb: does it allow vertical scatter to change across x? (b) Which values need a roughly symmetric distribution with no extreme outliers for the small-sample t-distribution to work?
(a) The Equal Variance (constant scatter) condition is violated (not Linearity, since the pattern is still straight rather than curved). The formula for SEb uses a single number s in the numerator for vertical scatter around the line, which does not work when vertical scatter changes across x and makes the line much less accurate on the right than on the left. (b) The normality condition applies to the residuals, not the explanatory variable x (and cannot be judged from the residual plot against x alone). Instead, she should check a dotplot, histogram, or normal probability plot of the 12 residuals themselves for heavy skew or extreme outliers.
4
Before looking at the data, a nutritionist suspects that higher daily fiber intake (grams) is associated with lower LDL cholesterol (mg/dL). A random sample of n=22 adults gives the following computer regression table (with all inference conditions met): Constant row: Coef = 142.50, SE Coef = 8.10, T = 17.59, P = 0.000; Fiber (g) row: Coef = −1.20, SE Coef = 0.50, T = −2.40, P = 0.026; below the table: s = 11.40, R-Sq = 22.4%. (a) Give the sample slope b, the standard error of the slope SEb, and the typical vertical distance that an individual's LDL cholesterol falls from the regression line. (b) Find the p-value for testing H0:β=0 against Ha:β<0 and state the conclusion at the α=0.05 level in context.
(a) Separate how much the sample slope wobbles (SEb) from how far individual points fall vertically from the line (s). (b) Check whether the computer table's `P` column is one-sided or two-sided.
(a) Reading from the `Fiber (g)` row rather than the `Constant` row (142.50 and 8.10), the sample slope is b=−1.20 and its standard error is SEb=0.50. The typical vertical distance of an individual's LDL cholesterol from the regression line is the residual standard deviation s=11.40 mg/dL below the table (not SEb=0.50). (b) The computer table gives a two-sided p-value of 0.026, so be careful not to use 0.026 directly for a one-sided test. Since b=−1.20 is in the direction of Ha:β<0, the one-sided p-value is:
p-value=20.026=0.013
Because 0.013<0.05, we reject H0 and conclude there is convincing evidence of a negative linear relationship between daily fiber intake and LDL cholesterol in the population.
5
In an observational study of a random sample of n=10 office workers (all conditions met), a researcher predicts afternoon alertness score (0 to 100) from hours of outdoor daylight exposure, finding a sample slope of b=5.0 and a standard error of SEb=2.0. Using df=8 and critical value t∗=2.31: (a) Construct a 95% confidence interval for the population slope β. (b) Explain what is wrong with claiming "Each extra hour of daylight causes a worker's alertness score to rise by between 0.38 and 9.62 points," and give a correct interpretation. (c) Based on this interval alone, state whether a two-sided test of H0:β=0 at α=0.05 would reject H0, and explain why.
Multiply t∗ directly by SEb=2.0 (do not divide SEb by 10 again, which would mistakenly give 5.0±1.46=(3.54,6.46)).
(a) Margin of error is t∗⋅SEb. (b) Check how the data was collected and whether a regression line tracks an individual or a population average. (c) Check where 0 sits relative to your interval.
(a) Multiply t∗ directly by SEb=2.0 (do not divide SEb by 10 again, which would mistakenly give 5.0±1.46=(3.54,6.46)):
b±t∗⋅SEb=5.0±2.31(2.0)=5.0±4.62=(0.38,9.62)
(b) Because the data came from an observational study rather than a randomized experiment, we cannot claim causation, and the regression line tracks the population mean (average) alertness score rather than an individual worker's change. Correctly interpreted: we are 95% confident that in this population, for every 1-hour increase in outdoor daylight exposure, the average afternoon alertness score is higher by between 0.38 and 9.62 points. (c) It would reject H0:β=0 because the null value 0 is not inside the 95% confidence interval (0.38,9.62) (avoid comparing 0.05 to the interval endpoints; check whether 0 is inside the interval), meaning every plausible value for β is positive.
6
Two researchers each sample n=26 runners from a large population to estimate the slope β relating weekly training mileage (x) to 5K race time in minutes (y), where the vertical scatter around the regression line is s=1.8 minutes in both studies. Researcher A samples 26 runners whose weekly mileage all falls narrowly between 18 and 22 miles (sx=1.2 miles). Researcher B samples 26 runners whose weekly mileage spans 5 to 50 miles (sx=12.0 miles), formed by picking 13 pairs of identical twins who train together. (a) Calculate SEb for Researcher A, and explain how having ten times the horizontal spread (sx=12.0 instead of 1.2) would change SEb and the width of a 95% confidence interval if all inference conditions were met. (b) Explain why Researcher B cannot validly use that smaller SEb to run a t-test for β, even if the residual plots look linear, equal in vertical spread, and roughly normal.
(a) Notice where sx sits in SEb=sxn−1s: is it inside or outside the square root? (b) Check the fourth condition, which doesn't show up in a residual plot.
(a) For Researcher A, using n−1=25=5:
SEb=1.2⋅26−11.8=1.2⋅51.8=0.30 minutes per mile
Because sx sits outside the square root in the denominator (unlike n, so be careful not to divide by 10 to get 0.095), multiplying the horizontal spread sx by 10 (to 12.0) while keeping s and n fixed divides SEb by 10 to 0.03 minutes per mile, making the 95% confidence interval one-tenth as wide. (b) Passing the three residual-plot checks is not enough: Researcher B's sample violates the Random and Independent condition because 13 pairs of identical twins who train together are not independent observations, so the sample does not give 26 independent pieces of information and the standard error formula does not apply.