Now most people use n minus two, instead of n.

So it's not the average squared residual,

it's kind of like the average squared residual.

And, and for large n, the difference between one over n minus two, and

one over n is irrelevant.

But for small n, it can make a difference.

The way to think about that is, remember,

if we include the intercept the residuals have to sum to zero.

So, that puts a constraint.

If you know n minus one of them, then, you know the nth.

Well, if you have a line term in there, if you have a co-variant in there, then,

that puts a second constrain on the residuals.

So, you lose two degrees of freedom.

If you put another regression variable in there, you have another constraint,

you lose three degrees of freedom.

So in that sense it's sort of like saying you really don't have n residuals,

you have n minus two of them,

because if you knew n minus two of them you could figure out the last two.

And that's why it's one over n minus 2.

So let me show you how you can grab the residual variation

out of your l m fit and assign it to a variable.

This way if you needed, if you need to work with it in an R program you can

actually grab the number, not just see it on the printout.

So here I've defined my y and my x, and I've defined my

fit as the regression model with y as the outcome and x as the predictor.

Well if you just do summary of fit and you don't do anything else,

you just hit return, it'll print out the summary of the regression model.

Intercepts, slopes, estimated values, and so on, and you'll see the residual

standard deviation estimate among the elements in the printout.

However, if you want to grab it as an object that you can assign to something,

just put dollar sign sigma.

Then you can assign sigma to any other variable.

So if you're using it in a program in some other way.

This works out in this particular example to be 31.84 dollars.