📚 Linear Regression: Least Squares Method and Interpreting Results | 线性回归:最小二乘法与结果解读
Linear regression is one of the most important statistical tools in A-level mathematics. It allows us to model the relationship between two variables by fitting a straight line to observed data, and then to interpret how changes in one variable are associated with changes in another.
线性回归是 A-level 数学中最重要的统计工具之一。它通过将一条直线拟合到观测数据,帮助我们对两个变量之间的关系进行建模,并解释一个变量的变化如何与另一个变量的变化相关联。
1. What Is Linear Regression? | 什么是线性回归?
Linear regression assumes that a response variable y depends on an explanatory variable x in an approximately linear way. We often write the relationship as y = a + bx, where b is the slope and a is the intercept.
线性回归假设响应变量 y 以近似线性的方式依赖于解释变量 x。我们通常将这种关系写成 y = a + bx,其中 b 是斜率,a 是截距。
The goal is to choose the values of a and b that produce the “best” straight line through the data points on a scatter diagram.
其目标是选择 a 和 b 的值,使得散点图上穿过数据点的直线“最佳”。
2. The Principle of Least Squares | 最小二乘法的原理
The most common way to define “best” is the method of least squares. This method chooses the line that minimises the sum of the squared vertical distances between each data point and the fitted line.
定义“最佳”最常用的方法是最小二乘法。该方法选择使每个数据点到拟合直线的垂直距离的平方和最小的直线。
If the fitted value is denoted by ŷ, then the quantity to minimise is:
如果用 ŷ 表示拟合值,那么需要最小化的量为:
S = Σ(yᵢ − ŷᵢ)²
Here yᵢ is the observed value and ŷᵢ = a + bxᵢ is the value predicted by the line for the same xᵢ.
其中 yᵢ 是观测值,ŷᵢ = a + bxᵢ 是该直线在同一个 xᵢ 处预测的值。
Squaring the distances ensures that positive and negative errors do not cancel each other, and it places greater weight on larger deviations.
对距离取平方可以确保正的误差和负的误差不会相互抵消,并且对较大的偏差赋予更大的权重。
3. The Regression Equation | 回归方程
The least-squares regression line of y on x is written as:
y 对 x 的最小二乘回归直线写为:
ŷ = a + bx
Here b is the slope: it represents the average change in y when x increases by one unit.
其中 b 是斜率:它表示当 x 增加一个单位时,y 的平均变化量。
The intercept a is the predicted value of y when x = 0. In some contexts, x = 0 may be outside the range of the data, so the intercept should be interpreted with care.
截距 a 是当 x = 0 时 y 的预测值。在某些情况下,x = 0 可能超出数据范围,因此解释截距时应当谨慎。
An important property is that the fitted line always passes through the point (x̄, ȳ), the mean of the x-values and the mean of the y-values.
一个重要性质是,拟合直线总是通过点 (x̄, ȳ),即 x 值的平均值和 y 值的平均值。
4. Calculating the Slope and Intercept | 计算斜率与截距
To find b and a, we first compute three sums of squares and products:
为了求 b 和 a,我们首先计算三个平方和或乘积和:
Sxx = Σ(xᵢ − x̄)²
Sxy = Σ(xᵢ − x̄)(yᵢ − ȳ)
Syy = Σ(yᵢ − ȳ)²
The slope is then given by:
斜率的计算公式为:
b = Sxy / Sxx
And the intercept by:
截距的计算公式为:
a = ȳ − b x̄
These formulas are often provided in the formula booklet, but it is essential to understand how to substitute correctly from a summary table or a calculator output.
这些公式通常在公式册中给出,但正确地从汇总表或计算器输出中代入数值至关重要。
5. Residuals and Their Role | 残差及其作用
The residual for an observation is the vertical gap between the actual value and the fitted value:
一个观测值的残差是实际值与拟合值之间的垂直差距:
eᵢ = yᵢ − ŷᵢ
Residuals show how far each point lies from the regression line. A positive residual means the point is above the line; a negative residual means it is below the line.
残差显示每个点到回归直线的距离。正残差表示该点位于直线上方;负残差表示该点位于直线下方。
For a least-squares line with an intercept, the sum of the residuals is zero: Σeᵢ = 0.
对于带截距的最小二乘直线,残差之和为零:Σeᵢ = 0。
Plotting residuals against the fitted values or against x can help check whether a linear model is appropriate. If the points show no obvious pattern, the linear model is likely to be suitable.
将残差对拟合值或对 x 作图,有助于检验线性模型是否合适。如果点没有明显的规律,则线性模型可能是合适的。
6. The Coefficient of Determination R² | 决定系数 R²
In simple linear regression, the coefficient of determination R² is the square of the Pearson correlation coefficient r:
在一元线性回归中,决定系数 R² 是 Pearson 相关系数 r 的平方:
R² = r²
Equivalently, R² can be stated as the proportion of the total variation in y that is explained by the linear relationship with x.
等价地,R² 可表示为 y 的总变异中由与 x 的线性关系所解释的比例。
For example, if R² = 0.81, then 81% of the variation in y is explained by x through the regression model; the remaining 19% is due to other factors and random error.
例如,如果 R² = 0.81,那么 y 的变异中有 81% 可以通过回归模型由 x 解释;其余 19% 由其他因素和随机误差引起。
A high R² does not prove causation, but it indicates that the linear association is strong in a statistical sense.
高的 R² 并不能证明因果关系,但它表明在统计意义上线性关联很强。
7. Using Regression for Prediction | 使用回归进行预测
Once the regression equation has been calculated, it can be used to estimate y for a given value of x by direct substitution.
一旦计算出回归方程,就可以通过直接代入来估算给定 x 值对应的 y 值。
Prediction within the range of the observed x data is called interpolation. Interpolation is generally reliable because the model is supported by data in that region.
在观测到的 x 数据范围内进行预测称为内插。内插通常是可靠的,因为该区域有数据支持模型。
Prediction outside this range is called extrapolation. Extrapolation can be dangerous because the linear trend may not continue beyond the observed data.
在范围之外进行预测称为外推。外推可能很危险,因为线性趋势在观测数据之外可能不再延续。
For example, if x data lie between 0 and 10, estimating y at x = 5 is interpolation, while estimating at x = 20 is extrapolation.
例如,如果 x 数据介于 0 和 10 之间,那么在 x = 5 处估计 y 是内插,而在 x = 20 处估计则是外推。
8. Assumptions and Limitations | 假设与局限
Least-squares regression relies on several assumptions. The relationship between x and y should be approximately linear, and the residuals should have roughly constant spread across the range of x.
最小二乘回归依赖于若干假设。x 与 y 之间应近似线性,并且残差在整个 x 范围内应具有大致恒定的离散程度。
The regression line of y on x is not symmetric: if the variables are swapped, the line changes. The equation y = a + bx is designed to predict y from x, not the reverse.
y 对 x 的回归直线不是对称的:如果交换变量,直线会改变。方程 y = a + bx 用于从 x 预测 y,而不是相反。
Outliers can have a strong influence on the least-squares line. An unusual point far from the bulk of the data can pull the slope and intercept towards itself.
异常值对最小二乘直线有很强的影响。一个远离大部分数据的异常点会把斜率和截距拉向自身。
Finally, correlation does not imply causation. Even a strong linear relationship does not mean that x causes y to change.
最后,相关不等于因果。即使线性关系很强,也不意味着 x 导致 y 发生变化。
9. Interpreting Software Output | 解读软件输出结果
In exams and real applications, regression results are often presented using statistical software. A typical output includes the estimates of the intercept and slope, along with standard errors and p-values.
在考试和实际应用中,回归结果通常通过统计软件呈现。典型的输出包括截距和斜率的估计值,以及标准误和 p 值。
For a simple linear model, the key numbers to identify are the coefficient for x (the slope b) and the constant (the intercept a).
对于简单线性模型,需要识别的关键数字是 x 的系数(斜率 b)和常数项(截距 a)。
| Predictor | Coefficient | Meaning |
| Constant | a | Intercept: predicted y when x = 0 |
| x | b | Slope: change in y per one-unit change in x |
The R² value is usually shown separately; it is the percentage of variation in y explained by the model.
R² 值通常单独显示;它是模型解释的 y 变异百分比。
Statistical software also gives a p-value for the slope. A small p-value (typically less than 0.05) suggests that there is evidence of a significant linear relationship between x and y.
统计软件还会给出斜率的 p 值。较小的 p 值(通常小于 0.05)表明有证据显示 x 和 y 之间存在显著的线性关系。
10. Common Exam Pitfalls | 考试常见误区
One common mistake is confusing which variable is x and which is y. The regression line “y on x” minimises vertical distances, so it is not the same as “x on y”.
一个常见错误是混淆哪个变量是 x、哪个是 y。“y on x”的回归直线最小化垂直距离,因此它不同于“x on y”的回归直线。
Another pitfall is using the wrong formula for b. Remember that the denominator is always Sxx, the sum of squares for the explanatory variable.
另一个陷阱是使用错误的 b 公式。请记住,分母始终是 Sxx,即解释变量的平方和。
Students sometimes forget that the regression line passes through (x̄, ȳ). This property is useful for checking whether a computed equation is plausible.
学生有时会忘记回归直线经过 (x̄, ȳ)。这个性质可以用来检查计算出的方程是否合理。
When interpreting the slope, do not say “causation” unless the problem context explicitly supports it. Say “on average, y changes by b units when x increases by one unit.”
在解释斜率时,除非问题背景明确支持,否则不要说“因果关系”。应该说“平均而言,当 x 增加一个单位时,y 改变 b 个单位。”
Finally, always state the unit of prediction and avoid extrapolating beyond the data range unless the question explicitly asks you to do so.
最后,始终说明预测的单位,并且除非题目明确要求,否则避免在数据范围之外外推。
Published by TutorHao | Mathematics Revision Series | aleveler.com
更多咨询请联系16621398022(同微信)
屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导Cancel reply