What is Sigma in the Gibbons Ross Shanken (GRS) test? I am trying to figure out what $\Sigma$ means in this GRS formula:
$$F_{GRS} = \frac{T - K - N}{N} \frac{\hat{\alpha}^T \hat{\Sigma}^{-1} \hat{\alpha}} {1 +
\hat{\mu}_{K}^T \hat{\Sigma}_{K}^{-1} \hat{\mu}_{K}} $$
The goal is to determine whether the alphas are statistically different from 0. 
First, we start with a matrix of factors and a matrix of test assets. We regress each excess returns of each test asset on the factors:
$$r_t^e = \hat{\alpha} + \hat{B} r_{Kt}^{e} + \hat{e_t} $$


*

*The alphas from the above regression are the $\hat{\alpha}$.

*$T$ is the number of observations in each factor (or test asset).

*$K$ is the number of factors.

*$N$ is the number of test assets.

*$\hat{\Sigma}_{K}^{-1}$ is the covariance matrix of all the factors,which is $K \times K$

*$\hat{\mu}_{K}$ is the means of each factor, which is $K \times 1$.


I think I have the above right, but I am not sure what $\hat{\Sigma}$ is. I think it is either a covariance matrix of test asset returns or covariance matrix of residuals associated with each test asset from the regression equation above. I tried to convince myself that those are the same thing, but I believe that this is the case only when the coefficients on all factors are 0.
I looked at this thread and it seems that $\hat{\Sigma}$ is a covariance matrix of test asset returns, but I am not sure whether I am reading that code properly.
 A: I just had a glance at the original paper, "Gibbons, Ross, Shanken (GRS) (1989) "A Test of the Efficiency of a Given Portfolio" and it seems to me that $\Sigma$ is the covariance matrix of the idiosyncratic component of asset returns, not the covariance matrix of the asset returns themselves. 
For example, let $r_p$ denote the return on the portfolio you are testing, and let $r_j$ denote the return on the jth asset. GRS consider linear models of the form:
\begin{equation}
r_{j,t} = \alpha_{j,p} + \beta_{j,p} r_{p,t} + e_{j,t} .
\end{equation}
Let $\mathbf{e}_t = (e_{1,t}, ..., e_{j,t}, ..., e_{J,t})^\prime$, (assume $J$ assets) then typically $\Sigma = \mathbb{E} \mathbf{e}_t \mathbf{e}_t^\prime$, where $\Sigma$ is assumed to not depend on $t$.
To obtain an estimator for $\Sigma$, ie $\hat{\Sigma}$, Campbell, Lo, Mackinlay (1990) "The Econometrics of Financial Markets", suggest obtaining the residuals $\hat{e}_{j,t}$ from OLS regressions of the above model for $j = 1, ..., J$, and then just using the sample covariance formula (multivariate version) on these OLS residuals. ie: $T^{-1} \sum_t \hat{\mathbf{e}}_t \hat{\mathbf{e}}_t^\prime$. Obviously for this to be a half decent estimator you will need $T$ (the number of observations) to be much larger than $J$, the number of assets.
The above is my take on the paper (based on a quick glance). I couldn't locate the exact formula that you provide in the question anywhere in the paper, so I can't guarantee that what I have written is correct in your circumstances. However, I strongly suspect it is correct based on what I read in Campbell, Lo and Mackinlay's textbook.
By the way, if you're trying to test the CAPM or a multi-factor asset pricing model, there are much better methods out there than the GRS test. For example, the recent work by Jushan Bai and Serena Ng on high dimensional factor analysis (see Bai and Ng (2006) "Evaluating Latent and Observed Factors in Macroeconomics and Finance" to get started) provides a much better framework for testing hypotheses about common factors in asset returns.
