# Linear Regression

In this article, we will use the Einstein summation convention. For example, is equivalent to

In statistics, we have at least three categories of quantities:

- data and labels
- abstract theoretical quantities
- parameters and predictions of models

The convention is that quantities with $\hat {}$ are the model quantities. Sometimes we do not distinguish the abstract theoretical quantities and model quantities.

If it is necessary to use different notations for the abstract theoretical quantities and the model quantities, we would use bold symbols ($\mathbf Y$) or latin sub/super indices ( $Y_a$ ) for theoretical quantities and greek letters ( $Y_\alpha$ ) for model quantities.

So we use the following conventions in this article.

- $\mathbf X$ or $X_{ij}$: data
- $\mathbf Y$ or $Y_{i}$: results
- $\hat{\mathbf Y}$ or $\hat Y_{i}$: predicted results

## A Model

A model is an estimator of the data that maps the inputs $\mathbf X$ to the predicted outputs $\hat{\mathbf Y}$, $\hat{\mathbf Y} = F( \mathbf X )$. The map $F$ might require some parameters, ${\boldsymbol\alpha, \boldsymbol\beta, \cdots }$.

Then we should have an estimator that tells us how good the model is given some parameters. For example, we could define a loss function $L(\mathbf Y,\hat{\mathbf Y} )$ that estimates the deficit between the actual data and the predicted results. Then we minimize this deficit.

So a model usually has

- map,
- esitmator.

## Linear Model

The model is simple

One might want to create a augmented dataset by including a 0th column $X_{i0} = 1$, so that we have with $j=0,1,2,…$.

Using least squares as our estimator, we minimize the RSS loss function $L$ by choosing the suitable parameters $\beta_j$. The loss function is

Minimizing it ‘requires’ $\partial_{\beta_m} L = 0$ and $\partial_{\beta_m}\partial_{\beta_n} L > 0 $.

We have

Solving $- 2 X_{im} ( Y_i - X_{ij}\beta_j ) = 0$, we have

In the abstract matrix notation,