Multivariate Analysis

Email questions

question  There is a note at the end of the assignment saying: "Only retain the first two 
eigenvalues and eigenvectors."  I don't see a command for this in the class example  from Wednesday 
and can't find it anywhere in my notes. I know how to recreate the matrices so only the first 
rows or columns remain, but when I try eliminating the first two eigenvalues/vectors, I get a 
conformability error. What is the correct way to retain only two eigenvalues/vectors before 
obtaining the loadings?

There are commands for subsetting matrices in the class notes on Stata matrix commands.  The 
classroom example does not have every single step for doing the homework but here is the outline
of what I did.  After computing the eigenvalues and eigenvectors, I kept only the first two 
eigenvalues (two rows and two columns of the diagonal matrix) and the first two columns of the 
eigenvectors and used those to compute the factor loadings.

question  For hmk 3, I am having an issue with the Mahalanobis.  I can get the  
within SSCP and the mean valus vector difference, but when I come to  do the "md" I get 
a conformability error.

my answer  Remember in class I talked about the quadratic form should be 
(horizontal vector)*(square matrix)*(vertical vector). If your mean vector is already 
horizontal then you don't need to use the transpose of the mean vector.

Sorry for the delay, I have been out of town since Friday morning.

question:  The vector we came up with for the first question gives us close 
numbers but rounded to the 100th and the constant doesn't show up...any clues to get us started?

my answer Did you use the augmented X vector?  You need to append a column of one's to 
get the constant as shown in the unit Regression III: Matrix Formulation.  This was discussed in 

question  We're having technical difficulties with Moodle with #9 of the assignment.  
We were only able to bring up half of the table that's provided on the answer key. 
Specifically, only the bottom left hand side of the diagonal "1's" came
out.  Would you happen to know what the problem is?

my answer
I can't quite tell from your description what is going on, so I'll just make some general 

Is the stand score (Z-score) matrix correct?  If so, then try R = 1/(n-1)*Z'Z.

Another, possibility is if the covariance matrix is correct then you can 
try R = corr(covmat), where covmat is the name of the covariance matrix.

If these suggestions don't solve the problem then you will have to send me more
information including Stata commands and output.

question: We are having are difficult time figuring out how to get the standard scores 
matrix from stata. We've done extensive review of our notes, books, and internet sites and come 
up with a big NADA? Any helpful hints or resources would be greatly appreciated.

Jeffs answer:
Since this is a computer assignment, it is hard to help you without just giving you the 
answer. But let's give it a try. You can get this by multiplying the deviation score matrix 
(D) by the inverse of the diagonal matrix of standard deviations. Check your notes and see if 
this is enough of a clue to get you unstuck. If not, let me know and we'll try something else.

my answer 
A good starting place for this is to remember what the formula for a standard score is.

Z = (X-mean)/s, that is, it is a deviation score deviation score divided by a standard deviation.

So the trick is to figure out how to divide each element of a matrix by its standard deviation. There is a section on one of the matrix pages that goes into dividing column values.

Hope this helps some.

question:  We are having some problems with #7 covariance matrix. Our understanding was 
that this involves obtaining the square roots to extract the covariance. We were attempting 
to follow the handout titled "Matrix Tricks" and attempting to compute the square roots of 
a diagonal matrix. We also thought that we need to use the cholesky command, but we're stuck 
in the steps before this, which is to create a diagonal matrix. I hope this is not too 
confusing, and that we're not completely wrong about the procedures.

my answer:  The best way to get the covariance is to multiply the deviation sscp matrix by 
1/(n-1).  We had a unit in class that went over four ways of computing the deviation sscp.

Here is the matrix formula for the covariance matrix:  S = 1/(n-1)*D'*D

Now there may be a need for the square roots of the diagonal of the covariance matrix 
(e.g., the diagonal matrix of standard deviations).  And yes, that requires the use 
of the Cholesky decompostion function. 

Multivariate Course Page

Phil Ender, 4oct05