Start by writing a program that computes the variance-covariance matrix for pairs of numbers. This part should be relatively easy. As a test, consider the set
0 0 1 0.75 4.5 0.54 -2.25 11.0 -2.0 -1.5 -1.7 -3.5 2.0 15.0 7.5 -1.5 3.7 4.3 -3.7 2.5 -1.0 1.5 -0.7 5.2 1.0 -1.0 3.0 2.0Note that you can think of these as (x,y) coordinates on a grid superimposed over a map, where (0,0) sits on one of the cross-streets.
The sample variance-covariance matrix we calculate from this sample is
9.470838 -1.227701 -1.227701 25.667546In this case, we've divided by N - 1 when computing the sample variances and covariance.
Next, you should write a routine to invert the sample variance-covariance matrix. You don't need to write a general matrix-inversion routine -- only one to invert a 2 x 2 matrix.
At this point your Aunt and Uncle need to talk to you about an unpleasant subject: unsightly plagiarism. For many of these calculations you will find algorithms and code on the web or in books. Using these as references is perfectly fine, but you must cite the references you use. Let us reiterate that point. If you use any reference (code, web page, book, paper, etc.) other than the course web pages you must write down who the original author of the work is, and where/how it was published as part of what you turn in. For code, it is fine simply to give the web page as a comment in the source code you turn in.
Okay, so the next step is to write a piece of code that inverts a 2 x 2 matrix so you can invert your sample variance-covariance matrix. Here is what we get when we invert the example matrix above:
0.106246 0.005082 0.005082 0.039203
Finally, write a program that prints out the equation for your ellipse symbolically. That is, you program prints out the x^2, y^2, xy, x, y and constant terms for your ellipse with the appropriate coefficients. You might want to multiply by (n-2) / (2 * (n-1)) so that your "constant" on the right-hand side becomes an F critical value. Here is the equation our code gets for this test data:
0.686513 * (x - 0.810714)^2 + 0.065673 * (x - 0.810714)*(y - 2.520714) + 0.253310 * (y - 2.520714)^2If you set this equal to different F critical values that you can find with the calculator mentioned in the lecture notes, you will then be able to plot confidence ellipses corresponding to these critical values.
Finally should also turn the code you have written to compute the sample variance-covariance matrix, to invert it, and to print out the terms of the equation describing your ellipse.
As a graduate student assignment, you can compare your answer to that generated by the "CGT" algorithm shown in the Pilot.
While implementing the algorithm is fairly straight forward (your Uncle Norman and Aunt Heloise worked out the details in an afternoon), determining the parameters necessary to make the algorithm work properly on the data will be a bit of a challenge. We spent a few days searching the web for the data necessary to instantiate the CGT equation, and didn't find much.
However.
We did find a thesis or two that at least described enough about the methodology to understand what the parameters represent.
To complete this assignment for Graduate Student credit, you will need to continue this research to the point where you can credibly instantiate the CGT equation and then use it to generate a confidence contour from the data given at the top of this page. If you have questions about what constitutes a "credible instantiation" please feel free to contact us immediately.