Professional Documents
Culture Documents
(X1 , Y1 ), . . . , (Xn , Yn )
x x
x x
x
Of course, we want to find the line that fits our data best and one can define the
measure of the quality of the fit in many different ways. The most common approach
116
LECTURE 29. SIMPLE LINEAR REGRESSION. 117
and we want to minimize it over all choices of parameters 0 , 1 . The line that mini-
mizes this loss is called the least-squares line. To find the critical points we write:
n
L X
= 2(Yi (0 + 1 Xi )) = 0
0 i=1
n
L X
= 2(Yi (0 + 1 Xi ))Xi = 0
1 i=1
= 1 1X 1X 2 1X
X
X Xi , Y = Yi , X 2 = Xi , XY = Xi Y i
n n n n
then the critical point conditions can be rewritten as
= Y and 0 X
0 + 1 X + 1 X 2 = XY
by taking the derivatives and solving the system of linear equations to find the pa-
rameters 0 , . . . , k .
LECTURE 29. SIMPLE LINEAR REGRESSION. 118
Y = f (X) +
where the random variable is independent of X (it is often called random noise)
and on average it is equal to zero: = 0. For a fixed X, the response variable Y in
this model on average will be equal to f (X) since
Y = f (X) + = 0 + 1 X + ,
Let us find the maximum likelihood estimates of 0 , 1 and 2 that maximize this
likelihood function. First of all, it is obvious that for any 2 we need to minimize
n
X
(Yi 0 1 Xi )2
i=1
LECTURE 29. SIMPLE LINEAR REGRESSION. 119
over 0 , 1 which is the same as finding the least-squares line and, therefore, the MLE
for 0 and 1 are given by
and 1 = XY X Y .
0 = Y 1 X
X2 X2
Finally, to find the MLE of 2 we maximize the likelihood over 2 and get:
n
1X
2
= (Yi 0 1 Xi )2 .
n i=1
Let us now compute the joint distribution of 0 and 1 . Since Xi s are fixed, these
estimates are written as linear combinations of Yi s which have normal distributions
and, as a result, 0 and 1 will have normal distributions. All we need to do is find
their means, variances and covariance. First, if we write 1 as
P
XY X Y 1 (Xi X)Y i
1 = =
X2 X2 n X2 X 2
then its expectation can be computed:
P P
(X i Yi
X) 0 + 1 Xi )
(Xi X)(
(1 ) = =
n(X 2 X 2) n(X 2 X 2)
P P 2
(Xi X) Xi (Xi X) nX 2 nX
= 0 +1 = 1 = 1 .
n(X 2 X 2) n(X 2 X 2) 2)
n(X 2 X
| {z }
=0
2
N 0 , 1 +
0 = Y 1 X
X
2
2)
n n(X 2 X
and
2
X
Cov(0 , 1 ) = .
2)
n(X 2 X