0:20

Displacement I guess and horsepower are the predictors, okay?

And I'm going to use rgl.

You need to have rgl installed.

You have to do this locally.

You can't be using, for example, r studio on a web server to do this

because you need, rgl uses your graphics acceleration from your

0:43

graphics card installed on your computer so can't really do it in the browser.

So you need to be running a local version of R to do this sort of stuff, okay.

Or if you're doing it externally, let say on a server,

you need to tunnel the X connection or something like that.

Okay, so let's open up a 3D window in rgl.

Okay, there it is, oops, that big.

1:11

Resize a little bit, there you go.

Okay, and then I want to plot an ellipsoid of the fit,

and it turns out that the function, eclipse 3D can just take in

the fitted object by itself, and

it automatically just takes the first three coefficients, and

fits a simultaneous confidence ellipsoid for those three coefficients.

In this case, we only have three coefficients, so that's fine.

And I'm going to tell it I want color to be red.

The blending, this is not the type one error rate alpha,

this is the alpha blending for how transparent you want the object to be.

In this case I want it to be about 50% transparent.

I want aspect to equal true, that just means how it's going to

rescale the axis so I put it in and there it is, okay?

So this is now our confidence ellipsoid where displacement

is on one axis, the intercept is on the other axis and

the horsepower is on the third axis, okay?

So this is a three dimensional confidence ellipsoid for

those three coefficients simultaneously.

So the probability that the three dimensional point for beta one,

beta naught, beta one, and beta two lies in this confidence region is 95%,

under our assumptions, okay?

So now we can do this directly.

I think we should, given our discussion where we actually went through

the definition of an ellipse we should actually do it a little bit more directly.

So data is now just going to be coefficients from the fitted values.

Let me just show you what the data's are.

There's the betas.

30 for the intercept minus 0.03 for displacement, and

minus 0.24 for horsepower.

And then, my sigma is just going to be the variance,

covariance, of the fitted matrix.

So sigma is the variance covariance matrix of the beta matrix.

So there it is 1.77, you can see it.

Okay, and then N is the number of rows and

E is the number of columns of X.

So in this case it turns out that the specific way the ellipse 3D needs it,

is it needs the A matrix to be sigma times the relevant F quantile.

And then three here is from the three dimensions, it's from

3:41

the rank of the test, okay?

So that is there and I'm really being a little bit inaccurate because

this is really a inverse from the notation we were using in the last lecture.

So keep that in mind.

It took me a little bit of nitpicking to figure this out.

Okay, and then if you want the names to show up you need a vector of the names.

Okay, so let's open up the 3D connection.

4:06

Okay, there that is.

And then, here we're going to do plot3d, so it takes ellipse3d,

and then it's taking A, but I think in our definition is is really A inverse.

It should be A inverse, okay?

And then you want it centered at my beta estimates, okay?

And in this case, my k is the identity matrix.

And then t equal 1 is just saying, define the ellipse as the set of points where

4:36

the ellipse is less than or equal to 1.

This time, I want it to be blue.

And then I want alpha blending to be 0.5 so I want it to

be about 50% transparent, so it rescales the axisis to look nice to be true.

And then this is just setting my label names.

And then I do that, put it up, okay?

And then there it is.

You can see it's the same plot.

But now we've directly used the definition of an ellipse rather than relying

on ellipse3D to do the it for us.

So that's all that it is and hopefully now you can use this to

5:14

do your own three dimensional confidence ellipsoid and hopefully you can also find

another eclipse plotting program to do two dimensional ones if you wanted to.

But this is, I think, a pretty nice way to visualize a three dimensional fit.

I think the way that I would most likely use a three dimensional

hyperellipse in order to visualize a confident set would be in the case where

I wanted to predict three things, and I wanted to see the simultaneous prediction.

I think that would be the most likely instance where I would use

some function like this, okay?

But it's pretty neat, you can impress your friends by using RGL to create