A couple linear algebra questions (including SAS proc iml)

#1
EDIT: \(\sigma\) should be capital sigma, the covariance matrix, but I can't remember how to write it.

First question

Consider the following mean vector and covariance matrix corresponding to the random vector \((Y = Y_1, Y_2, Y_3)\):

\(\mu\)=
[2
7
6]

and
\(\sigma\)=
[4 3 -3
2 4 -1
-3 -1 6]

Use proc iml to answer the following:
a)determine the elements of the matrix G such that:
GY = (\(Y_1+Y_2+Y_3, Y_3-Y_1, 0.5Y_1-0.5Y_3+2Y_2\))` (I refer to this product as Z)

c)Find the unique symmetric matrix A so that Y'AY=Y'GY
Looking at Z, it's fairly obvious that G=
[1 1 1
-1 0 1
.5 2 -.5]

However, solving algebraically for G:
\(GY=Z
GYY'=ZY'
G(YY')(YY')^{-1}=ZY'(YY')^{-1}
G=ZY'(YY')^{-1}\)

I use the following SAS code to solve for G:
Code:
proc iml;
 y={2, 7, 6};
 sigma={4 3 -3,2 4 -1,-3 -1 6};
 z={15, 4, 12};
 print y sigma z;

 zyt=z*y`;
 inv=inv(y*y`);
 g=zyt*inv;
 check= g*y;
 print g check;
run;
quit;
However, when I run this code, I get an error following 'inv=inv(y*y`)': ERROR: (execution) Matrix should be non-singular.

I know that only singular square matrices can have inverses, but I don't know why this matrix would be non singular.

I also ran similar code and actually got it to work, but it was a weird matrix, just a bunch of decimals.

For c), I tried solving it algebraically again, and eventually it gets to A = G. However, G isn't symmetric. I'm not sure what else to do.


Question 2
Suppose that \(Y_n~N_n(\mu, \sigma)\) and \(A=\sigma^{-1} - \frac{(\sigma^{-1}J\sigma)}{1'_n\sigma^{-1}1_n}\). WHat distribution does Y'AY have?
I know that if \(Y_n~N_n(\mu, \sigma)\) and rank(\(\sigma\))=n, then \(Y'AY~(X^2_{rank(A), \frac{1}{2}\mu'A\mu}\) if and only if \(A\sigma\) is idempotent. So I need to show that A is idempotent. I have no idea where to begin. Expansion makes that whole thing incredibly messy. I thought maybe I could assign the second part to a new variable, so that \(A= \sigma^{-1} - S\) and prove it similarly to how I-H is idempotent. However, I don't know that S is idempotent, and don't know how to show it.

Any help would be greatly appreciated.
 

Dason

Ambassador to the humans
#2
EDIT: \(\sigma\) should be capital sigma, the covariance matrix, but I can't remember how to write it.
Use a capital S when writing \Sigma

I know that only singular square matrices can have inverses, but I don't know why this matrix would be non singular.
y is rank 1 so yy' will be at most rank 1 as well. It's a 3x3 matrix that is of rank 1 so it's singular.