Least squares estimation
How do linear models estimate parameters?
In our Linear models lecture, we used the lm() function in R, but we haven't talked about how it estimates the parameters. It uses this least squares estimation, which we will now discuss the theory for.
This is the equation we use in the linear model to determine the expected value of
For each value of
We are looking for the value of
In the lecture notes, they give some instructions on how to manually calculate this in R. This is what's going on "under the hood" in the lm() function.
The gist of it is that one sum of squares value is given by sum(y - beta*x)^2. Using a for loop over many beta values between 0 and 2 can be used to get the minimum.
Least squares estimate vs maximum likelihood estimate
Under the Gaussian Observation Model, what they call a "maximum likelihood estimate" is the same as these least squares estimate. The proof for that is here, but I think we don't exactly need to know it.
Proof
Since it's a Gaussian observation model, we assume that the values of the response variable
If we assume that all observations are independent, the joint probability density for all observations is given by this function with a big Pi (
This means that the total probability distribution is the product of the distributions of all the
This gives us an idea about the uncertainty of each value of
The maximum likelihood estimate for
Since the normal distribution can be modelled by the probability function:
Then this gets transformed into the least squares estimate from earlier. I don't really understand the math but I think it's not essential.
Note that this is only true for the Gaussian observation model - it's not true for the distribution of a t-test for example, or for other kinds of observation models used in Generalized linear models.