A common problem in experimental work is to obtain a mathematical relationship
y
=
f
x
between two variables x and y by "fitting" a curve to points in the plane that correspond to experimentally determined values of x and y, say
x
1
,
y
1
,
x
2
,
y
2
,
...
,
x
n
,
y
n
The curve
y
=
f
x
is called a mathematical model of the data. The general form of the function f is commonly determined by some underlying physical principle, but sometimes it is just determined by the pattern of the data. We are concerned with fitting a straight line
y
=
m
x
+
b
to data. Usually, the data will not lie on a line (possibly due to experimental error or variations in experimental conditions), so the problem is to find a line that fits the data "best" according to some criterion. One criterion for selecting the line of best fit is to choose m and b to minimize the function
g
m
,
b
=
∑
i
=
1
n
m
x
i
+
b
−
y
i
2
This is called the method of least squares, and the resulting line is called the regression line or the least squares line of best fit. Geometrically,
m
x
i
+
b
−
y
i
is the vertical distance between the data point
x
i
,
y
i
and the line
y
=
m
x
+
b
.
These vertical distances arc called the residuals of the data points, so the effect of minimizing
g
m
,
b
is to minimize the sum of the squares of the residuals. In these exercises, we will derive a formula for the regression line.
The purpose of this exercise is to find the values of m and b that produce the regression line.
(a) To minimize
g
m
,
b
,
we start by finding values of m and b such that
∂
g
/
∂
m
=
0
and
∂
g
/
∂
b
=
0.
Show that these equations are satisfied if m and b satisfy the conditions
∑
i
=
1
n
x
i
2
m
+
∑
i
=
1
n
x
i
b
=
∑
i
=
1
n
x
i
y
i
∑
i
=
1
n
x
i
m
+
n
b
=
∑
i
=
1
n
y
i
(b) Let
x
¯
=
x
1
+
x
2
+
⋅
⋅
⋅
+
x
n
/
n
denote the arithmetic average of
x
1
,
x
2
,
...
,
x
n
.
Use the fact that
∑
i
=
1
n
x
i
−
x
¯
2
≥
0
to show that
n
∑
i
=
1
n
x
i
2
−
∑
i
=
1
n
x
i
2
≥
0
with equality if and only if all the
x
i
’s are the same.
(c) Assuming that not all the
x
i
’s are the same, prove that the equations in part (a) have the unique solution
m
=
n
∑
i
=
1
n
x
i
y
i
−
∑
i
=
1
n
x
i
∑
i
=
1
n
y
i
n
∑
i
=
1
n
x
i
2
−
∑
i
=
1
n
x
i
2
b
=
1
n
∑
i
=
1
n
y
i
−
m
∑
i
=
1
n
x
i
[Note: We have shown that g has a critical point at these values of m and b. In the next exercise we will show that g has an absolute minimum at this critical point. Accepting this to be so, we have shown that the line
y
=
m
x
+
b
is the regression line for these values of m and b.]