No interesting data. No scripts. No pictures. Instead I’m going to attack one of my pet peeves. I was recently working on a project, doing a simple regression, when I wanted to look up something about the variance of an estimated parameter. I found myself on the Wikipedia page for variance inflation factor. There was a general description, an equation, but no intuition. I checked several other top hits in a Google search, and it was the same story. By intuition, I mean an explanation at a level where there is no need to remember an equation. Another example is when we divide by one less than the sample size when estimating the variance of a population from a sample, but why? Answer: “because that makes it an unbiased estimator.” Okay, but why? Answer: “because you can calculate the expected value and see it works,” or “that’s how many degrees of freedom you have available for your estimate.” Those are the answers often given to students, but these still just describe the rule without a fundamental explanation. These stats concepts can all be expressed in terms of subspaces, orthogonal complements, projections…you know…linear algebra stuff. This is the language for visualization and intuition (in my opinion). So, returning to my pet peeve, I hate problems that are confusing only because they are presented in an unfamiliar language. Today I’m going to take ordinary least squares (OLS) from a stats perspective (degrees of freedom, sums of squares, , prediction intervals, variance inflation factors, etc…) and make it all more intuitive in the language of linear algebra. OLS is as old as dirt, so I’m sure this all exists somewhere, but it’s certainly less common than the standard presentation, and I may as well put it here for my own reference.
Let’s take a model where is with the first column in the all 1’s vector. We’ll index from to and to so that the th column will be used to estimate the intercept . We assume the error or noise and will see why the entries are assumed normal and iid in a bit. To get the OLS solution, we want the closest to in the column space of and solve . This means the error should be orthogonal to the columns of . In other words . Solving for , this allows us to estimate our paramters by
Our vector of predicted values is then
which is the the projection of onto the column space of . Our residuals are
and is the projection of onto the orthogonal complement of the column space of .
Let’s turn our attention to the error and residuals. We would like to estimate the distribution from which was drawn based on . Note if we knew the true parameters , the error would be drawn from a rotation invariant distribution in , namely by our model assumptions. Letting be the projection onto the orthogonal complement of the column space of , we see . So instead of drawing from a normal distribution in , we drew from that distribution projected onto the orthogonal complement of the columns space of , an dimensional subspace. Intuitively, this is still a normal distribution, but the variance has decreased. The question is by how much has it decreased. It’s not too hard to see , and then by rotation invariance, we expect the squared norm of to be a fraction of the squared norm of according to what fraction of the original dimension we are in: . Putting this all together, our unbiased estimate is
So there’s where a statistician would be throwing around “degrees of freedom.” We divide by degrees of freedom because we’ve projected our error vector onto an dimensional subspace.
Let’s take a closer look at our parameter estimates . We see is nothing more than . Thanks to our mean zero and normal assumptions on yet again, this has expected value and is normal, though almost certainly not iid. In fact, we can calculate
which we estimate by substituting for . With our parameters normally distributed and these estimates for their means and variances, we can find confidence intervals or do hypothesis tests for the parameters.
With , this says something about how may effect our parameter estimates. If the columns of are such that is ill-conditioned, the variance for some of our parameter estimates will be large. This is what statisticians call multicolinearity – which is a name I can get behind as tends to be ill-conditioned when some columns in are nearly linear combinations of others. One statistic often mentioned is a variance inflation factor (VIF). This is typically presented in terms of a statistic obtained by regressing a column of against the remaining columns, but for the th parameter (), this algebraically translates to
where is the projection onto the orthogonal complement of the all-ones column. Here I am using the notation to represent the entry in the jth row and jth column of the given matrix. The matrix subtracts the mean from each column of , so note . If the columns of were orthogonal, for , we would have , and . Thus the VIF is and does as it’s name suggests – it’s a ratio of the estimated variance in over the variance estimate if the columns of were orthogonal. It measures how the variance is “inflated” due to the non-orthogonality of the columns in . One aspect of this still feels a little squishy. Nothing accounts for the all-ones vector . Indeed the VIF for the term (the intercept) usually is not defined and would equal according to what I have above. It feels to me that the variance for the estimate would be “inflated” it if is nearly in the span of the other columns. In fact, I first (incorrectly) calculated which would fix this issue, but you lose the interpretation of VIF as a ratio of variances. It seems the VIF is mainly used as a rule of thumb anyway, so I guess it depends on what you care about. If your intercept estimate is really important, you may not want to use the standard VIF. This bothered me enough that I looked it up, and these are “centered” vs. “non-centered” versions of VIFs. The standard definition is “centered,” and the issues are pretty much exactly as I described above.
Moving on to predictions, since , and the parameter estimates are all normally distributed, is normally distributed with covariance
and again we estimate by substituting for . Note this is the error variance times the projection matrix onto the column space of . Unlike the variance of , this means the variance of our prediction is effected only by the column space of and not at all by any near linear dependence among the columns. In other words, multicolinearity is only an issue with respect to the model parameters and has zero effect on our predictions. So we again have normal distributions with an estimated variance, and we can set up a confidence interval in the usual manner. This is a confidence interval for the expected value of the model as we did not account for the term. If you wanted prediction intervals (which also account for this error in each measurement), just add to the previous covariance matrix for .
Lastly, I want to mention which is a goodness of fit measure. People break up their regression into a bunch of different sums of squares (SS), and use these to calculate . This “break up” of the regression is just , and the partition into SS almost corresponds to . I say almost because when you look at the definition of sums of squares, these vectors are centered (making the norms akin to variance). Thus we take the norms above but after projecting everything onto the orthogonal complement of an all 1’s vector. Recalling that the all 1’s vector is in , is already in this orthogonal complement, and . These are referred to as sum squares total, sum squares regression, and sums squares error respectively. Then
The closer your model’s prediction to , the closer is to 1. A small then clearly shows your prediction does not well match the data and consists mostly of the term. From just an algebra perspective, it seems unnecessary to project these with , but this allows the norms to represent variance which in turn makes them useful for hypothesis testing.
There you go – sums of squares, variance inflation factors, degrees of freedom, and other stats jargon in terms of dimensions of subspaces, lengths of vectors, and properties of certain matrices…so much nicer.