Okay, so let's start creating some standardized residuals just to show

an example of doing it manually, and then with RS default built-in functions.

So if I do data(mtcars) for the motor train cars data set,

my y is miles per gallon.

In this case, my x is an intercept horsepower in weight, okay?

I define my n and my p, I create my hat matrix, and

then what I'm calling the residual matrix is just being

i minus the hat matrix, and then my e is my residmat times y.

So residmat is the matrix that is orthogonal to

the projection onto the space span by the columns of x.

Okay, and then my residual variance estimate is the sum of the residual

squared divided by n minus p.

And then my standardized residuals are just my residuals divided by

s divided by the square root of the diagonal of the residual matrix, okay?

And then, if I compare those, these are just exactly with what

you get if you take the output of your fitted lm object, okay?

And here, I'm just putting in my design matrix, which includes an intercept,

so I'm subtracting in r as default intercept.

And then the function, r standard, for standardized residuals,

is what returns the standardized residuals as we just calculated in.

You can see here, they're identical.

What you want to look for in standardized residuals, so

I would just want to do something like plot(rstd, by predict(.

And then, I should have assigned my output of my fitted object to a variable,

but I'm just going to refit it there.

And you usually,