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?
Asked
Active
Viewed 159 times
3
-
1See the wiki-page for linear least squares: https://en.wikipedia.org/wiki/Linear_least_squares_(mathematics) – Bobson Dugnutt Feb 12 '16 at 11:34
1 Answers
0
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?
Nitin Uniyal
- 7,946