6C Linear Regression | 6C 线性回归

📚 6C Linear Regression | 6C 线性回归

Linear regression is one of the most widely used statistical techniques for modelling the relationship between two quantitative variables. In the IB Mathematics and Cambridge exam contexts, students are expected to understand the underlying principles, perform calculations both by hand and using a graphics display calculator (GDC), and critically interpret the results in real-world settings.

线性回归是用来对两个定量变量之间的关系进行建模的最广泛使用的统计技术之一。在IB数学和剑桥考试中,学生需要理解其基本原理,能够通过手算和图形计算器进行计算,并且能够批判性地解释实际问题中的结果。

1. Introduction to Linear Regression | 线性回归简介

Linear regression is a method that finds the straight line which best represents the trend in a scatter plot of bivariate data. The line can be used to predict the value of one variable given the other, provided the relationship is approximately linear.

线性回归是一种寻找最能代表双变量数据散点图趋势的直线的方法。只要两个变量之间的关系近似线性,这条直线就可以用于已知一个变量时预测另一个变量的值。

In many applied contexts, we suspect a causal or associative link between an independent variable (often called the explanatory variable or predictor) and a dependent variable (the response variable). Regression helps us model that link and assess the strength of the association.

在许多实际应用中,我们怀疑自变量(常称为解释变量或预测变量)与因变量(响应变量)之间存在因果关系或关联。回归帮助我们建立这种关系的模型,并评估关联的强度。

For example, a biologist might use linear regression to model the relationship between hours of sunlight and the growth rate of a plant, expecting an increase in growth rate with more sunlight.

例如,一个生物学家可能会使用线性回归来建立光照时间与植物生长速度之间关系的模型,预期光照越长生长速度越快。


2. The Simple Linear Regression Model | 简单线性回归模型

The simplest form of linear regression involves one independent variable x and one dependent variable y. The model assumes that the true relationship can be described by the equation y = α + βx + ε, where α is the intercept, β is the slope, and ε is the random error term representing scatter around the line.

最简单的线性回归形式包含一个自变量 x 和一个因变量 y。模型假设真实关系可以用方程 y = α + βx + ε 来描述,其中 α 是截距,β 是斜率,ε 是表示数据点在直线周围离散程度的随机误差项。

When we fit a regression line to sample data, we estimate α and β and denote the fitted line as ŷ = a + bx. Here a is the estimated intercept and b is the estimated slope. The “hat” on y indicates a predicted value, not an observed one.

当我们对样本数据拟合回归直线时,我们估计 α 和 β,并将拟合直线记作 ŷ = a + bx。这里 a 是估计的截距,b 是估计的斜率。y 上面的“帽子”表示这是预测值,而不是观测值。

The values of a and b are chosen so that the line is as close as possible to all observed data points according to a criterion called least squares.

a 和 b 的值是按照“最小二乘”准则来选择的,使得这条直线尽可能地靠近所有观测数据点。


3. Least Squares Estimation | 最小二乘估计

The least squares method determines the values of a and b that minimise the sum of the squared vertical distances (residuals) between the observed yᵢ values and the predicted values ŷᵢ on the line. In symbols, we minimise Σ (yᵢ − ŷᵢ)².

最小二乘法通过最小化观测值 yᵢ 与直线上预测值 ŷᵢ 之间的垂直距离(残差)的平方和来确定 a 和 b。用符号表示就是使 Σ (yᵢ − ŷᵢ)² 达到最小。

Squaring ensures that positive and negative residuals do not cancel out and gives a line that tends to pass through the centre of the data cloud. This unique line is called the least squares regression line.

平方处理保证了正负残差不会相互抵消,并给出了一条通常通过数据云中心的直线。这条唯一的直线被称为最小二乘回归线。

Graphically, the least squares line passes through the point of means (x̄, ȳ), which provides a useful check when plotting the regression line or interpreting the equation.

从图形上看,最小二乘直线总是通过均值点 (x̄, ȳ),这为绘制回归直线或理解方程提供了一个有用的检验。


4. Formulas for Regression Coefficients | 回归系数的公式

For a set of n paired observations (xᵢ, yᵢ), the slope b of the least squares regression line is given by:

对于一组包含 n 对观测值的数据 (xᵢ, yᵢ),最小二乘回归直线的斜率 b 由下式给出:

b = Σ (xᵢ − x̄)(yᵢ − ȳ) / Σ (xᵢ − x̄)²

Once b is found, the intercept a can be calculated simply as:

求出 b 之后,截距 a 可以简单地通过下式计算:

a = ȳ − b x̄

These formulas follow directly from minimising the sum of squared residuals. In examinations, candidates are often expected to compute a and b using these formulas, either manually or with a GDC.

这些公式直接源自最小化残差平方和的过程。在考试中,考生通常被要求使用这些公式手动计算,或用图形计算器得出 a 和 b 的值。

For the special case where both variables are standardised, the regression line simplifies to ŷ = r x, but the basic formulas above are the general ones used for raw data.

当两个变量都经过标准化处理时,回归直线可以简化为 ŷ = r x,但上面给出的基本公式是处理原始数据时所用的通用公式。


5. Worked Example: Calculating by Hand | 手算示例

Consider a small data set of five observations: (x, y) = (1, 2.1), (2, 3.9), (3, 6.0), (4, 7.8), (5, 10.2). We will calculate the least squares regression line manually.

考虑一个包含五个观测值的小数据集: (x, y) = (1, 2.1), (2, 3.9), (3, 6.0), (4, 7.8), (5, 10.2)。我们将手动计算最小二乘回归直线。

First, compute the means: x̄ = (1+2+3+4+5)/5 = 3; ȳ = (2.1+3.9+6.0+7.8+10.2)/5 = 30/5 = 6.

首先计算平均值:x̄ = (1+2+3+4+5)/5 = 3;ȳ = (2.1+3.9+6.0+7.8+10.2)/5 = 30/5 = 6。

Next, construct a table to find the required sums:

接下来构造一个表格来求所需的求和项:

xᵢ yᵢ xᵢ − x̄ yᵢ − ȳ (xᵢ − x̄)(yᵢ − ȳ) (xᵢ − x̄)²
1 2.1 −2 −3.9 7.8 4
2 3.9 −1 −2.1 2.1 1
3 6.0 0 0 0 0
4 7.8 1 1.8 1.8 1
5 10.2 2 4.2 8.4 4
Sums → 20.1 10

From the table, Σ (xᵢ − x̄)(yᵢ − ȳ) = 20.1 and Σ (xᵢ − x̄)² = 10. Thus, b = 20.1 / 10 = 2.01. Then a = ȳ − b x̄ = 6 − 2.01×3 = 6 − 6.03 = −0.03.

由表格可得,Σ (xᵢ − x̄)(yᵢ − ȳ) = 20.1,Σ (xᵢ − x̄)² = 10。因此 b = 20.1 / 10 = 2.01。然后 a = ȳ − b x̄ = 6 − 2.01×3 = 6 − 6.03 = −0.03。

The fitted regression line is ŷ = −0.03 + 2.01x, which can be approximated as ŷ = 2.01x (since the intercept is very close to zero). This line describes the data very well.

拟合的回归直线为 ŷ = −0.03 + 2.01x,可以近似写作 ŷ = 2.01x(因为截距非常接近于零)。这条直线很好地描述了数据。


6. Interpreting the Slope and Intercept | 斜率和截距的解释

The slope b represents the estimated change in the response variable y for a one-unit increase in the explanatory variable x. In the example above, a slope of 2.01 means that when x increases by 1 unit, y is predicted to increase by approximately 2.01 units, on average.

斜率 b 表示当解释变量 x 增加一个单位时,响应变量 y 的估计变化量。在上述例子中,斜率为 2.01 意味着 x 每增加 1 个单位,y 预计平均增加约 2.01 个单位。

The intercept a is the predicted value of y when x = 0. However, the intercept should be interpreted with caution because x = 0 may lie outside the range of the observed data, in which case a may just be an extrapolation with no real meaning.

截距 a 是当 x = 0 时 y 的预测值。但须谨慎解释截距,因为 x = 0 可能在观测数据范围之外,这种情况下 a 仅仅是一种外推值,没有实际含义。

In many IB exam questions, students are asked to interpret the slope and intercept in the context of a word problem, using proper units and making clear whether the intercept is meaningful or not.

在许多 IB 考题中,学生被要求根据应用题的情景来解释斜率和截距,使用正确的单位,并明确指出截距是否具有实际意义。


7. Correlation Coefficient r | 相关系数 r

Pearson’s product-moment correlation coefficient r measures the strength and direction of a linear relationship between two variables. It is given by:

皮尔逊积矩相关系数 r 衡量两个变量之间线性关系的强度和方向。其公式为:

r = Σ (xᵢ − x̄)(yᵢ − ȳ) / √[ Σ (xᵢ − x̄)² · Σ (yᵢ − ȳ)² ]

The value of r always lies between −1 and 1. An r close to 1 indicates a strong positive linear correlation, an r close to −1 indicates a strong negative linear correlation, and an r near 0 suggests a weak or no linear relationship.

r 的取值始终在 −1 和 1 之间。r 接近 1 表示强正线性相关,r 接近 −1 表示强负线性相关,r 接近 0 则表明线性关系很弱或不存在。

It is important to note that correlation does not imply causation. A high r value does not prove that changes in x cause changes in y; there could be lurking variables or coincidental patterns.

必须注意,相关并不意味着因果。即使 r 值很高,也不能证明 x 的变化会导致 y 的变化;可能存在潜在变量或纯属巧合。


8. Coefficient of Determination r² | 决定系数 r²

The coefficient of determination r² is the square of the correlation coefficient and represents the proportion of the total variation in the y-values that is explained by the regression line on x. An r² of 0.85, for instance, means that 85% of the variation in y can be accounted for by the linear relationship with x.

决定系数 r² 是相关系数的平方,表示 y 值的总变异中能由 x 的回归直线所解释的比例。例如,r² = 0.85 意味着 y 的变异中有 85% 可用与 x 的线性关系来解释。

In the worked example, Σ (yᵢ − ȳ)² = (−3.9)² + (−2.1)² + 0² + 1.8² + 4.2² ≈ 15.21 + 4.41 + 0 + 3.24 + 17.64 = 40.5. From earlier, b² · Σ (xᵢ − x̄)² / Σ (yᵢ − ȳ)² = (2.01² × 10) / 40.5 = 40.401 / 40.5 ≈ 0.998. Hence r² is about 0.998, indicating a nearly perfect linear fit.

在上述手算示例中,Σ (yᵢ − ȳ)² = 40.5,而回归平方和约为 40.401,因此 r² ≈ 0.998,表明几乎完美的线性拟合。

IB and Cambridge exams often ask students to interpret r² in context and to explain its relationship with r, emphasising that r² is a more useful measure of effect size than r alone.

IB 和剑桥考试常要求学生结合情景解释 r²,并说明它与 r 的关系,强调 r² 作为效应量的度量比单独的 r 更有用。


9. Residuals and Model Assessment | 残差与模型评估

A residual is the difference between an observed value yᵢ and the corresponding predicted value ŷᵢ from the regression line: residual = yᵢ − ŷᵢ. Residuals tell us how far individual data points lie from the fitted line.

残差是观测值 yᵢ 与回归直线给出的对应预测值 ŷᵢ 之间的差值:残差 = yᵢ − ŷᵢ。残差告诉我们各个数据点距离拟合直线有多远。

A plot of residuals against the predicted values or against x should show no obvious pattern if the linear model is appropriate. Ideally, the residuals should be randomly scattered around zero with constant spread.

如果线性模型合适,残差相对于预测值或 x 的散点图应当没有明显模式。理想情况下,残差应围绕零随机散开,且散布程度大致恒定。

If a residual plot reveals a curved pattern, the relationship may be nonlinear; if it fans out, the variability of y might depend on x, violating the assumption of constant variance.

如果残差图显示出曲线模式,说明关系可能是非线性的;如果残差图呈喇叭形散开,说明 y 的变化幅度可能依赖于 x,违反正交方差假定。


10. Assumptions of Linear Regression | 线性回归的假设条件

For the least squares regression model to be valid and for inference to be reliable, several assumptions should be approximately met:

为了使最小二乘回归模型有效且推断可靠,需要近似满足以下几个假设:

1. Linearity: The relationship between x and y is linear. 2. Independence: Observations are independent of one another. 3. Homoscedasticity: The variability of the residuals is roughly constant across all values of x. 4. Normality: For inference purposes, the residuals should be approximately normally distributed. 5. No influential outliers: Individual points should not unduly influence the regression line.

1. 线性性:x 和 y 的关系是线性的。2. 独立性:观测值相互独立。3. 等方差性:对于所有 x 值,残差的变异大致恒定。4. 正态性:为了进行推断,残差应近似服从正态分布。5. 不存在强影响异常值:个别点不应过度影响回归直线。

In international examinations, students are expected to recognise when these assumptions may be violated and to comment on the limitations of applying linear regression in such cases.

在国际考试中,学生需要能识别出这些假设可能被违反的情形,并能对在这些情况下应用线性回归的局限性作出评论。


11. Using a Graphing Calculator (GDC) | 使用图形计算器

Both IB and Cambridge syllabuses place a strong emphasis on using GDC functions to perform linear regression quickly and accurately. Typically, students enter data into lists, select the linear regression tool, and the calculator returns values of a, b, r, and r².

IB 和剑桥的课程大纲都非常强调使用图形计算器快速而准确地进行线性回归。一般来说,学生将数据输入列表,选择线性回归工具,计算器就会返回 a、b、r 和 r² 的值。

For example, on a TI‑Nspire, the command linRegMx (or similar) applied to list variables gives the regression equation in the form ŷ = a + bx. It is crucial to write down the rounded values as required by the question and always show the rounded r².

例如,在 TI‑Nspire 上,对列表变量使用 linRegMx(或类似命令)可以给出形式为 ŷ = a + bx 的回归方程。关键是要按题目要求写下四舍五入后的值,并始终显示出舍入后的 r²。

Students should also be able to plot the regression line on top of a scatter plot and use the GDC to make predictions, such as finding y for a given x, while being mindful of the dangers of extrapolation.

学生还应该能够在散点图上绘制回归直线,并利用计算器进行预测,例如求给定 x 时的 y 值,同时要注意外推的危险。


12. Applications and Common Pitfalls | 应用与常见误区

Linear regression is widely applied in economics, biology, engineering, and social sciences whenever linear trends are observed. For instance, it can model the relationship between advertising spend and sales, or between temperature and energy consumption.

线性回归广泛应用于经济学、生物学、工程学和社会科学中,只要观察到线性趋势即可。例如,它可以用于建立广告投入与销售额、或温度与能耗之间关系的模型。

Common pitfalls include: forcing a linear model on clearly non‑linear data, failing to check the residual plot, misinterpreting correlation as causation, using predictions far outside the range of x (extrapolation), and ignoring the effect of outliers. A single unusual point can dramatically alter the slope and intercept.

常见误区包括:对明显非线性的数据强行使用线性模型,

Published by TutorHao | IB Mathematics Revision Series | aleveler.com

更多咨询请联系16621398022(同微信)

Comments

屏轩国际教育cambridge primary/secondary checkpoint, cat4, ukiset,ukcat,igcse,alevel,PAT,STEP,MAT, ibdp,ap,ssat,sat,sat2课程辅导,国外大学本科硕士研究生博士课程论文辅导

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from aleveler.com

Subscribe now to keep reading and get access to the full archive.

Continue reading