You are on page 1of 1

第 13 組

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

I. ̂𝑖 = 𝑎 + 𝑏𝑋𝑖 and the error from each data is 𝑒𝑖 = (𝑌𝑖 − 𝑌


Assume the fitting line is 𝑌 ̂𝑖 )2 .

II. To find the minimum total error Q and its corresponding 𝑎 and b is the solution.

̂𝑖 )2 = min ∑𝑛𝑖=1(𝑌𝑖 − 𝑎 − 𝑏𝑋𝑖 )2


minQ = min ∑𝑛𝑖=1(𝑌𝑖 − 𝑌

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

Therefore, the second condition is correct.

V. Then, for the first condition, after simplifying the two equations, we can get

𝑎 = 𝑌̅ − 𝑏𝑋̅
{ ∑(𝑋𝑖 −𝑋̅)(𝑌𝑖 −𝑌̅ ).
𝑏 = ∑(𝑋 −𝑋̅)2
𝑖

VI. 𝑋̅ = 5, 𝑌̅ =5, ∑(𝑋𝑖 − 𝑋̅ )(𝑌𝑖 − 𝑌̅) = 8, ∑(𝑋𝑖 − 𝑋̅ )2 = 40


∑(𝑋𝑖 −𝑋̅)(𝑌𝑖 −𝑌̅ ) 8
𝑏= ∑(𝑋𝑖 −𝑋̅ )2
= 40 = 0.2, 𝑎 = 𝑌̅ − 𝑏𝑋̅ = 5 − 0.2 × 5 = 4

VII. With the above calculations, the linearly-fitting line is

𝒀̂𝒊 = 𝟒 + 𝟎. 𝟐𝑿𝒊 .

You might also like