Sub topic 15
Testing the Slope and Building Confidence Intervals
Assume you know basic algebra, means, variance, standard deviation, and the simple linear regression model:
Y_i = b_0 + b_1X_i + \varepsilon_iHere, \(b1\) is the population slope. It measures the expected change in \(Y\) for a one-unit change in \(X\). The sample estimate of the slope is \(b1\) or \(\hat b_1\).
Testing whether the slope is significant
An investment question might be: “Does market return help explain fund return?” The hypotheses are:
- \(H0: b1 = 0\). The explanatory variable has no linear relationship with the dependent variable.
- \(Ha: b1 \ne 0\). The explanatory variable has a linear relationship with the dependent variable.
A two-tailed test is appropriate when either a positive or negative relationship matters. Use a one-tailed alternative, such as \(Ha: b1 > 0\), only when a direction is justified before examining the data.
The slope test statistic is:
t = \frac{\hat b_1 - b_{1,0}}{s_{\hat b_1}}Usually, \(b{1,0}=0\). The standard error of the estimated slope is \(s{\hat b_1}\). For simple linear regression, the test has \(n-2\) degrees of freedom because two parameters, the intercept and slope, are estimated.
Reject \(H_0\) when the absolute test statistic exceeds the critical value, or when the p-value is less than the significance level.
Confidence interval for the slope
A \(100(1-\alpha)\%\) confidence interval for the population slope is:
\hat b_1 \pm t_{\alpha/2,n-2}s_{\hat b_1}For a 95% interval, use \(t{0.025,n-2}\). If the interval contains zero, a two-tailed test at the 5% level would fail to reject \(H0:b_1=0\). If it excludes zero, the test rejects the null.
Consider these observations:
| \(X\) | \(Y\) |
|---|---|
| 1.0 | 2.1 |
| 2.0 | 3.9 |
For the complete five-observation sample \((X,Y)=(1,2.1),(2,3.9),(3,6.2),(4,7.8),(5,10.1)\), the estimated slope is about \(1.97\). Statistical software gives a slope standard error of about \(0.10\). With \(n-2=3\) degrees of freedom, the 95% critical value is about \(3.182\):
1.97 \pm 3.182(0.10)The interval is approximately \((1.65, 2.29)\). Because zero is outside this interval, the slope is statistically significant at the 5% level.
A confidence interval for the mean response differs from a prediction interval for one future observation. The prediction interval is wider because it includes both uncertainty in the estimated mean and the random error of a new observation.
import numpy as np
from scipy import stats
x = np.array([1.0, 2.0, 3.0, 4.0, 5.0])
y = np.array([2.1, 3.9, 6.2, 7.8, 10.1])
res = stats.linregress(x, y)
df = len(x) - 2
t_crit = stats.t.ppf(0.975, df)
t_stat = res.slope / res.stderr
interval = (
res.slope - t_crit * res.stderr,
res.slope + t_crit * res.stderr,
)
print("t statistic:", t_stat)
print("p-value:", res.pvalue)
print("95% slope interval:", interval)Exercise
A regression estimates a slope of 0.80 with a standard error of 0.25 and 18 observations. At the 5% level, should you reject the null that the slope is zero if the two-tailed critical value with 16 degrees of freedom is 2.120?
Show answer
The test statistic is 0.80 / 0.25 = 3.20. Since 3.20 > 2.120, reject the null. The slope is statistically significant at the 5% level.