Formulas and Mathematical Detail

There are \(N\) test portfolios, \(r_{t}\) (\(p\) by 1) which are usually assumed to be excess returns (zero-investment portfolios) and \(K\) factors, \(f_{t}\) (\(k\) by 1). For return series there are \(T\) observations.

Linear Factor Model for Traded Factors

This model is a Seemingly Unrelated Regression (SUR). All models share the same regressors so that the model for test portfolio \(i\) is

\[r_{it}=\alpha_{i}+\beta_{i}f_{t}+\epsilon_{it}.\]

Inference is based on the sandwich covariance estimator

\[\hat{\Sigma}=\left(T-df\right)^{-1}G^{-1}SG^{-1}.\]

Define \(f_{c,t}=\left[1\:f_{t}^{\prime}\right]^{\prime}\), then

\[\hat{G}=I_{N}\otimes\Sigma_{f_{c}}\]

and

\[\Sigma_{f_{c}}=T^{-1}\sum_{t=1}^{T}f_{c,t}f_{c,t}^{\prime}\]

Define the stacked vector of scores (or moment conditions)

\[g_{t}=\left[f_{c}\otimes\hat{\epsilon}_{t}\right].\]

If the heteroskedasticity robust estimator is used,

\[\hat{S}=T^{-1}\sum_{t=1}^{T}g_{t}g_{t}^{\prime}.\]

If the HAC estimator is used,

\[\begin{split}\begin{aligned} \hat{S} & =T^{-1}\left\{ \hat{\Gamma}_{0}+\sum_{i=1}^{bw}K\left(\frac{i}{bw}\right)\left(\hat{\Gamma}_{i}+\hat{\Gamma}_{i}^{\prime}\right)\right\} \\ \hat{\Gamma}_{j} & =\sum_{t=j+1}^{T}g_{t}g_{t-j}^{\prime}\end{aligned}\end{split}\]

where \(K\left(\frac{i}{bw}\right)\) is a kernel weighting function and \(bw\) is the bandwidth. The reported risk premia are just the average returns on the factors, and the covariance of the risk premia estimates is based on the factor residuals after demeaning using either the simple estimator or the kernel estimator.

The J statistic

The J statistic is implemented as

\[J=\hat{\alpha}^{\prime}\hat{\Sigma}_{\alpha}^{-1}\hat{\alpha}^{\prime}\sim\chi_{N}^{2}\]

where \(\hat{\Sigma}_{\alpha}\) consists of rows and columns\(1,(k+1)+1,2(k+1)+1,\ldots\) of \(\hat{\Sigma}\).

Linear Factor Model for Non-traded Factors

When factors are not traded, the SUR approach cannot be used since the expected value of the factor is not equal to its risk premium. One solution is to use a multi-step estimator. The first step regresses the test portfolio returns on the factors and a (throw-away) constant. This constant is included only to demean the factors to compute the correct factor loadings. The second stage then uses the estimated factor loadings and the average portfolio returns to estimate the risk premia. This second stage can be (optionally) improved by removing the effects of the demeaned factors from returns when computing risk premia.

The first stage regressions are virtually identical to the SUR regressions except the constant is no longer \(\alpha_{i}\),

\[r_{it}^{e}=c_{i}+\beta_{i}f_{t}+\epsilon_{it}.\]

The second stage regression then uses the estimated coefficients as regressors to estimate the risk premia,

\[\bar{r}_{i}^{e}=\left[1_{N}\,\hat{\beta}\right]\lambda+\eta_{i}.\]

Note that the residual from this regression\(\hat{\eta}_{i}=\hat{\alpha}_{i}\), the excess compensation test portfolio \(i\) is generating. If the risk free rate is assumed to be 0, then the column of 1s is not included and \(\lambda\) is \(K\) by 1.

Inference is conducted by treating this as a 3-step GMM problem where the first two steps were just described and the third estimated the model \(\hat{\alpha}\). The moment conditions corresponding to the FOC of these three steps are

\[\begin{split}g_{t}=\left[\begin{array}{c} f_{c,t}\otimes\epsilon_{t}\\ \left[1_{N}\,\beta\right]^{\prime}\left(r_{t}-\left[1_{N}\,\beta\right]\lambda\right)\\ r_{t}-\left[1_{N}\,\beta\right]\lambda-\alpha \end{array}\right]\end{split}\]

where \(\epsilon_{it}=r_{it}^{e}-c_{i}-\beta_{i}f_{t}\) is \(N\) by 1 , \(\beta\) is \(N\) by \(K\), \(\lambda\) is \(K+1\) by 1 and\(\alpha\) is \(N\) by 1. Inference is based on

\[\hat{\Sigma}=\left(T-df\right)^{-1}G^{-1}S\left(G^{-1}\right)^{\prime}\]

where the Jacobian \(G\) is estimated by

\[\begin{split}\hat{G}=-\left[\begin{array}{ccc} I_{N}\otimes\Sigma_{f_{c}} & 0 & 0\\ G_{21} & \left[1_{N}\,\hat{\beta}\right]^{\prime}\left[1_{N}\,\hat{\beta}\right] & 0\\ I_{N}\otimes\left[0\ \hat{\lambda}\right] & \left[1_{N}\,\hat{\beta}\right] & I_{N} \end{array}\right]\end{split}\]

The block \(G_{21}\)is

\[G_{21}=\left[G_{21,1}\ G_{21,2}\:\ldots\ G_{21,N}\right]\]
\[G_{21,i}=\left[0_{\left(K+1\right)\times1}\;\left(\left[1\;\hat{\beta}_{i}\right]^{\prime}\lambda^{\prime}-\left[0_{K}\;\bar{u}_{i}I_{K}\right]^{\prime}\right)\right]\]

When the risk free rate is 0, all terms of the form \([1_{N}\;\beta]\) become \(\beta\) and

\[G_{21,i}=\left[0_{K\times1}\;\left(\hat{\beta}_{i}^{\prime}\lambda^{\prime}-\;\bar{u}_{i}I_{K}\right)\right]\]

\(S\) is an estimator of the covariance of the moment conditions, \(g_{t}\), and its form is identical to either the heteroskedasticity consistent estimator or the HAC estimator in the previous section.

Improved Specification using GLS

\[\begin{split}\left[\begin{array}{c} f_{c,t}\otimes\epsilon_{t}\\ \beta_{c}^{\prime}\Sigma^{-1}\left(r_{t}-\beta_{c}\lambda\right)\\ r_{t}-\beta_{c}\lambda-\alpha \end{array}\right]\end{split}\]

The Jacobian is than

\[\begin{split}\hat{G}=-\left[\begin{array}{ccc} I_{N}\otimes\Sigma_{f_{c}} & 0 & 0\\ G_{12} & \hat{\beta}_{c}^{\prime}\Sigma^{-1}\hat{\beta}_{c} & 0\\ I_{N}\otimes\left[0\ \tilde{\lambda}\right] & \hat{\beta}_{c} & I_{N} \end{array}\right]\end{split}\]

\(\beta_{c}=\left[1_{N}\,\beta\right]\). \(\tilde{\lambda}=\left[\lambda_{1},\ldots,\lambda_{K}\right]\) and so does not include the risk-free rate \(\lambda_{0}\) when included in the model. The final piece has the structure

\[G_{21}=\left[G_{21,1}\ G_{21,2}\:\ldots\ G_{21,N}\right]\]
\[G_{21,i}=\left[0_{\left(K+1\right)}\;\tilde{\beta}_{c,i}^{\prime}\tilde{\lambda}^{\prime}-\left[0_{K}\;\bar{u}_{i}I_{K}\right]^{\prime}\right]\]

where \(\tilde{\beta}_{c,i}\) is row \(i\) of \(\Sigma^{-1}\beta_{c}\), \(\bar{u}_{i}=T^{-1}\sum_{t=1}^{T}\tilde{u}_{it}\) and \(\tilde{u}_{it}\) is the element in position \(i\) of \(\tilde{u}_{t}=\Sigma^{-1}\left(r_{t}-\lambda_{0}-\beta\tilde{\lambda}\right)\). Each block has a 0 columns corresponding to \(c_{i}\).

\(S\) is an estimator of the covariance of the moment conditions, \(g_{t}\), and its form is identical to either the heteroskedasticity consistent estimator or the HAC estimator in the previous section.

The J statistic

The J statistic is virtually identical to the \(J\) statistic from traded factor model except that it has a difference distribution.

\[J=\hat{\alpha}^{\prime}\hat{\Sigma}_{\alpha}^{-1}\hat{\alpha}^{\prime}\sim\chi_{N-K}^{2}\]

The loss of degrees of freedom occurs since \(\hat{\alpha}=\hat{\eta}\) which are regression residuals from a regression of \(N\) average returns on \(K\) factor loadings. \(\hat{\Sigma}_{\alpha}\) is the bottom right \(K\times K\) block of \(\hat{\Sigma}\).

GMM Estimation of Linear Factor Models

The GMM estimator solves a set of non-linear moment conditions of the form

\[\begin{split}\left[\begin{array}{c} \epsilon_{t}\otimes f_{c,t}\\ f_{t}-\mu \end{array}\right]\end{split}\]

where

\[\epsilon_{t}=r_{t}-\left[1_{N}\;\beta\right]\lambda-\beta\left(f_{t}-\mu\right)\]

is the vector of pricing errors. The factors can be traded or non-traded. This assumes that the model for expected returns is

\[E\left[r_{it}\right]=\lambda_{0}+\sum_{i=1}^{k}\beta_{i}\lambda_{i}\]

so that the risk-free rate might not be zero. This form is sometimes used with excess returns if there is doubt about the risk-free rate used. The Jacobian is then

\[\begin{split}\hat{G}=T^{-1}\sum_{t=1}^{T}-\left[\begin{array}{ccc} I_{N}\otimes\left(f_{t}-\mu+\tilde{\lambda}\right)f_{c,t} & \left[\begin{array}{c} f_{c,t}\left[1\!\hat{\beta}_{1}\right]\\ \vdots\\ f_{c,t}\left[1\!\hat{\beta}_{N}\right] \end{array}\right] & \left[\begin{array}{c} -f_{c,t}\hat{\beta}_{1}\\ \vdots\\ -f_{c,t}\hat{\beta}_{N} \end{array}\right]\\ 0 & 0 & I_{K} \end{array}\right]\end{split}\]

\(S\) is an estimator of the covariance of the moment conditions, \(g_{t}\), and its form is identical to either the heteroskedasticity consistent estimator or the HAC estimator in the previous section. The parameter covariance estimator uses the form appropriate for efficient GMM,

\[\hat{\Sigma}=\left(\hat{G}\hat{^{\prime}S}^{-1}\hat{G}\right)^{-1}.\]

Sources used in writing the code include [Bryzgalova], [Cochrane] and [JagannathanEtAl].