# Fitting a simple linear regression

A professor in the School of Business in a university polled a dozen colleagues about the number of professional meetings they attended in the past five years $x$ and the number of papers they submitted to refereed journals $y$ during the same period. The summary data are given as follows:

$n = 12$, $\bar{x}= 4$, $\bar{y}=12$, $\sum x^2 = 232$, $\sum xy = 318$.

Fit a simple linear regression model between x and y by finding out the estimates of intercept and slope. Comment on whether attending more professional meetings would result in publishing more papers.

I know that this is a linear regression problem. But I only know how to solve it using given values of $x$ and $y$. The only values given with the problem are the sample $n$, mean of $x$,mean of $y$, summation of $x^2$ and summation of $x*y$. I really don't know how to start with this problem.

HINT: Let's assume your model is $y=\theta x$, then the least-squares solution will be $\hat{\theta}=\min_{\theta} \|Y-\theta X\|_2^2$, where $X$ and $Y$ are column vectors made up of the data points (that you don't have, you only have some sufficient statistics that are extracted from them).

We have:

$\|Y-\theta X\|_2^2=(Y-\theta X)^T(Y-\theta X)=Y^TY-2\theta X^TY + \theta^2 X^TX$.

Note that, $X^TX=\sum x^2=238$, $X^TY=\sum xy=318$, the only missing part is $Y^TY=\sum y^2$, but you don't need that!

Now you problem is $\hat{\theta}=\min_{\theta} ~Y^TY-2*318\theta + 238\theta^2$

$\frac{d}{d\theta}Y^TY-2*318\theta + 238\theta^2=-2*318+ 2*238\theta=0$,

Therefore: $\hat{\theta}=\frac{318}{238}\approx 1.33$

More HINTS: If your model is affine, i.e. $y=\theta_1 x+\theta_2$, then you can use a similar approach to solve it, now let $L=[\underbrace{1,\ldots,1}_{\text{12 times}}]^T$,then your problem is: $\hat{\theta}_1,\hat{\theta}_2=\min_{\theta_1,\theta_2} \|Y-\theta_1 X-\theta_2 L\|_2^2$.

By the same expansion procedure, you can get quadratic forms in $\theta_1$ and $\theta_2$, but this time you'll need $n$, $\bar{x}$ and $\bar{y}$, try it yourself, and let us know if you got stuck!

Hope this helps.