Professional Documents
Culture Documents
Week 8
Question 1
There are two variables which have five observed value as follows. Please use ordinary least square
method (OLS) to find a line which can linearly fit the set of data.
X 1 3 5 7 9
Y 2 9 3 5 6
Answer 1
II. To find the minimum total error Q and its corresponding 𝑎 and b is the solution.
III. To find minQ, 𝑏0 , and 𝑏1 , there are two conditions which are
𝜕𝑄 𝜕2𝑄
=0 2 >0
𝜕𝑎
{𝜕𝑄 and {𝜕𝜕𝑎2 𝑄 .
=0 >0
𝜕𝑏 𝜕𝑏2
𝜕𝑄 𝜕𝑄
IV. = 2 × ∑(𝑌𝑖 − 𝑎 − 𝑏𝑋𝑖 )(−1), = 2 × ∑(𝑌𝑖 − 𝑎 − 𝑏𝑋𝑖 )(−𝑋𝑖 )
𝜕𝑎 𝜕𝑏
𝜕2𝑄 𝜕 2𝑄
= 2 × ∑ 1 > 0, = 2 × ∑ 𝑋𝑖2 > 0
𝜕𝑎 2 𝜕𝑏2
V. Then, for the first condition, after simplifying the two equations, we can get
𝑎 = 𝑌̅ − 𝑏𝑋̅
{ ∑(𝑋𝑖 −𝑋̅)(𝑌𝑖 −𝑌̅ ).
𝑏 = ∑(𝑋 −𝑋̅)2
𝑖
𝒀̂𝒊 = 𝟒 + 𝟎. 𝟐𝑿𝒊 .