How do I find the values of $\theta_0$ and $\theta_1$ in linear regression?

160 Views Asked by At

Suppose I am provided with a dataset of $X$ and $Y$ values, and if I would like to use linear regression $\left( hθ(x)=\theta_0+\theta_1 x \right)$, to estimate $Y$ as a function of $X$, then how can I find values for both $\theta_0$ and $\theta_1$ mathematically?

1

There are 1 best solutions below

0
On

The deviation of the approximated function from the actual is given by the difference $y_i-\theta_0-\theta_1x_i$ . Squaring it to get a positive quantity so that after summing it for all data points $i=1,3,...n$, you have

$S=\sum_{i=1}^n (y_i-\theta_0-\theta_1x_i)^2$

You need to minimize $S$ for which

$\partial S/\partial \theta_0=0$ and $\partial S/\partial \theta_1=0$

$ \implies \sum_{i=1}^ny_i=\theta_0 n+ \theta_1\sum_{i=1}^nx_i$......(1)

and

$\implies \sum_{i=1}^n x_iy_i=\theta_0\sum_{i=1}^nx_i+\theta_1\sum_{n=1}^nx_i^2$................(2)

Can you proceed from here?