Docsity

Least-Square Regression - Assignment Solution | SOCA 107, Assignments of Introduction to Sociology

Toggle sidebar
bg1
Least-square regression
Question: Given a collection of data points (xi, yi), for i= 1, ..., N determine the value of ain the
function y(x) = log(ax) that best fits this data in a least-square sense.
Solution:
The sum of the square of the residuals (ie the cost function) for this fitting function is a function of a
only:
Sr(a) =
N
X
i=1
[yiโˆ’log(axi)]2.
To minimize Srwith respect to a, we solve for the value of asuch that โˆ‚Sr/โˆ‚a = 0.
โˆ‚Sr
โˆ‚a = 2
N
X
i=1
[yiโˆ’log(axi)] ๎˜’โˆ’
1
a๎˜“= 0,
which can be solved for log(a) as
N
X
i=1
log(a) =
N
X
i=1
[yiโˆ’log(xi)] .
Finally, we find the required value of a,
a= exp 1
N
N
X
i=1
[yiโˆ’log(xi)]!.
1

Partial preview of the text

Download Least-Square Regression - Assignment Solution | SOCA 107 and more Assignments Introduction to Sociology in PDF only on Docsity!

Least-square regression

Question: Given a collection of data points (xi, yi), for i = 1, ..., N determine the value of a in the function y(x) = log(ax) that best fits this data in a least-square sense.

Solution: The sum of the square of the residuals (ie the cost function) for this fitting function is a function of a only:

Sr(a) =

โˆ‘^ N

i=

[yi โˆ’ log(axi)]^2.

To minimize Sr with respect to a, we solve for the value of a such that โˆ‚Sr/โˆ‚a = 0.

โˆ‚Sr โˆ‚a

โˆ‘^ N

i=

[yi โˆ’ log(axi)]

a

which can be solved for log(a) as

โˆ‘^ N

i=

log(a) =

โˆ‘^ N

i=

[yi โˆ’ log(xi)].

Finally, we find the required value of a,

a = exp

N

โˆ‘^ N

i=

[yi โˆ’ log(xi)]