Consider fitting a line

so that at the points
the line is close to the corresponding values
in sense that we minimize the sum of
squared deviations
over the values of
.
In matrix notation, we let y be the vector whose elements are the
and X be a matrix whose columns contain K explanatory
variable vectors with elements
in the
column. The method of OLS computes a coefficient vector
so
that the fitted vector
minimizes the sum of squared elements
from the deviation vector
. If the rank of X equals K,
then the solution can be written
