Skip to content

Commit 181683d

Browse files
authored
Merge pull request #805 from bashtage/lm71-fix-factor-model-inference
BUG: Invert the covariance of the pricing errors on its N - K - nrf d…
2 parents f5bc92a + 43f1b41 commit 181683d

17 files changed

Lines changed: 1472 additions & 75 deletions

‎doc/source/asset-pricing/index.rst‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ model and allows the specification to be testes with a J-statistic of the form
2222

2323
.. math::
2424
25-
J = \hat{\alpha}^{\prime} \hat{\Sigma}_{\alpha} \hat{\alpha} \sim \chi^2_P
25+
J = \hat{\alpha}^{\prime} \hat{\Sigma}_{\alpha}^{-1} \hat{\alpha} \sim \chi^2_P
2626
27-
where there are P portfolios.
27+
where there are P portfolios and :math:`\hat{\Sigma}_{\alpha}` is the covariance
28+
of the estimated pricing errors.
2829

2930
When some factors are not-traded, for example macroeconomic shocks, then a 2-step
3031
procedure is required since the average value of the factors does not
@@ -37,9 +38,13 @@ has a different distribution,
3738

3839
.. math::
3940
40-
J = \hat{\alpha}^{\prime} \hat{\Sigma}_{\alpha} \hat{\alpha} \sim \chi^2_{P-K}
41+
J = \hat{\alpha}^{\prime} \hat{\Sigma}_{\alpha}^{+} \hat{\alpha} \sim \chi^2_{P-K-n_{rf}}
4142
42-
where K is the number of factors.
43+
where K is the number of factors, :math:`n_{rf}` is 1 if the risk-free rate is
44+
estimated and 0 if it is not, and :math:`\hat{\Sigma}_{\alpha}^{+}` is the
45+
generalized inverse of the covariance of the pricing errors, which has rank
46+
:math:`P-K-n_{rf}` since the pricing errors satisfy :math:`K+n_{rf}` linear
47+
restrictions.
4348
:class:`~linearmodels.asset_pricing.model.LinearFactorModel` implements this
4449
two-step estimator.
4550
:class:`~linearmodels.asset_pricing.model.LinearFactorModelGMM` contains a more

‎doc/source/asset-pricing/introduction.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ prior to estimation.
4949
LinearFactorModel Estimation Summary
5050
================================================================================
5151
No. Test Portfolios: 6 R-squared: 0.8879
52-
No. Factors: 3 J-statistic: 39.109
52+
No. Factors: 3 J-statistic: 30.291
5353
No. Observations: 819 P-value 0.0000
5454
Date: Sun, May 21 2017 Distribution: chi2(3)
5555
Time: 21:18:56

‎doc/source/asset-pricing/mathematical-detail.lyx‎

Lines changed: 169 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,27 @@ where
231231
The reported risk premia are just the average returns on the factors, and
232232
the covariance of the risk premia estimates is based on the factor residuals
233233
after demeaning using either the simple estimator or the kernel estimator.
234+
If the covariance is debiased,
235+
\begin_inset Formula $df=K+1$
236+
\end_inset
237+
238+
is the number of regressors of each regression.
239+
The risk premia are sample means, so that their covariance uses
240+
\begin_inset Formula $T-1$
241+
\end_inset
242+
243+
in place of
244+
\begin_inset Formula $T-df$
245+
\end_inset
246+
247+
, and the covariance between the risk premia and the other parameters uses
248+
the geometric mean of the two divisors,
249+
\begin_inset Formula $\sqrt{\left(T-df\right)\left(T-1\right)}$
250+
\end_inset
251+
252+
.
253+
The block of the covariance of the parameters for the risk premia is
254+
then the square of their reported standard errors.
234255

235256
\end_layout
236257

@@ -724,18 +745,19 @@ The J statistic
724745
\end_layout
725746

726747
\begin_layout Standard
727-
The J statistic is virtually identical to the
748+
The J statistic is similar to the
728749
\begin_inset Formula $J$
729750
\end_inset
730751

731-
statistic from traded factor model except that it has a difference distribution.
752+
statistic from traded factor model except that the pricing errors satisfy
753+
linear restrictions and that the statistic has a different distribution.
732754
\end_layout
733755

734756
\begin_layout Standard
735757
\noindent
736758
\begin_inset Formula
737759
\[
738-
J=\hat{\alpha}^{\prime}\hat{\Sigma}_{\alpha}^{-1}\hat{\alpha}^{\prime}\sim\chi_{N-K}^{2}
760+
J=\hat{\alpha}^{\prime}\hat{\Sigma}_{\alpha}^{+}\hat{\alpha}=\left(Q^{\prime}\hat{\alpha}\right)^{\prime}\left(Q^{\prime}\hat{\Sigma}_{\alpha}Q\right)^{-1}\left(Q^{\prime}\hat{\alpha}\right)\sim\chi_{N-K-n_{rf}}^{2}
739761
\]
740762

741763
\end_inset
@@ -745,32 +767,102 @@ J=\hat{\alpha}^{\prime}\hat{\Sigma}_{\alpha}^{-1}\hat{\alpha}^{\prime}\sim\chi_{
745767

746768
\begin_layout Standard
747769
\noindent
748-
The loss of degrees of freedom occurs since
770+
where
771+
\begin_inset Formula $n_{rf}$
772+
\end_inset
773+
774+
is 1 if the risk free rate is estimated and 0 if it is not. The loss of
775+
degrees of freedom occurs since
749776
\begin_inset Formula $\hat{\alpha}=\hat{\eta}$
750777
\end_inset
751778

752779
which are regression residuals from a regression of
753780
\begin_inset Formula $N$
754781
\end_inset
755782

756-
average returns on
757-
\begin_inset Formula $K$
783+
average returns on the
784+
\begin_inset Formula $K+n_{rf}$
758785
\end_inset
759786

760-
factor loadings.
787+
columns of the factor loadings. The second stage estimates make
788+
\begin_inset Formula $\hat{\alpha}$
789+
\end_inset
790+
791+
orthogonal to the
792+
\begin_inset Formula $K+n_{rf}$
793+
\end_inset
794+
795+
columns of
796+
\begin_inset Formula $\Sigma^{-1}\hat{\beta}_{c}$
797+
\end_inset
798+
799+
, where
800+
\begin_inset Formula $\Sigma$
801+
\end_inset
802+
803+
is the covariance used in the GLS version or the identity matrix, so that
804+
\begin_inset Formula $\hat{\alpha}$
805+
\end_inset
806+
807+
lies in a space with
808+
\begin_inset Formula $N-K-n_{rf}$
809+
\end_inset
810+
811+
dimensions and its covariance has rank
812+
\begin_inset Formula $N-K-n_{rf}$
813+
\end_inset
814+
815+
in theory.
816+
\begin_inset Formula $\hat{\Sigma}_{\alpha}$
817+
\end_inset
818+
819+
is the block of
820+
\begin_inset Formula $\hat{\Sigma}$
821+
\end_inset
822+
823+
that contains the covariance of
824+
\begin_inset Formula $\hat{\alpha}$
825+
\end_inset
826+
827+
. The columns of
828+
\begin_inset Formula $Q$
829+
\end_inset
830+
831+
are an orthonormal basis of the space that is orthogonal to the columns of
761832

833+
\begin_inset Formula $\Sigma^{-1}\hat{\beta}_{c}$
834+
\end_inset
835+
836+
, and
837+
\begin_inset Formula $\hat{\Sigma}_{\alpha}^{+}=Q\left(Q^{\prime}\hat{\Sigma}_{\alpha}Q\right)^{-1}Q^{\prime}$
838+
\end_inset
839+
840+
is the generalized inverse of
762841
\begin_inset Formula $\hat{\Sigma}_{\alpha}$
763842
\end_inset
764843

765-
is the bottom right
766-
\begin_inset Formula $K\times K$
844+
with rank
845+
\begin_inset Formula $N-K-n_{rf}$
767846
\end_inset
768847

769-
block of
770-
\begin_inset Formula $\hat{\Sigma}$
848+
. The statistic is the Wald statistic of the
849+
\begin_inset Formula $N-K-n_{rf}$
771850
\end_inset
772851

773-
.
852+
linear combinations of the pricing errors that are not restricted to be
853+
zero. If
854+
\begin_inset Formula $\hat{\Sigma}_{\alpha}$
855+
\end_inset
856+
857+
were exactly singular in the directions of the columns of
858+
\begin_inset Formula $\Sigma^{-1}\hat{\beta}_{c}$
859+
\end_inset
860+
861+
, as the covariance of the pricing errors is in theory,
862+
\begin_inset Formula $\hat{\Sigma}_{\alpha}^{+}$
863+
\end_inset
864+
865+
would be its Moore-Penrose pseudo-inverse.
774866
\end_layout
775867

776868
\begin_layout Subsection
@@ -873,6 +965,71 @@ f_{c,t}\left[1\!\hat{\beta}_{N}\right]
873965

874966
\end_layout
875967

968+
\begin_layout Standard
969+
The pricing errors,
970+
\begin_inset Formula $\hat{\alpha}$
971+
\end_inset
972+
973+
, are the averages of the first moment condition of each portfolio,
974+
\begin_inset Formula $\epsilon_{t}$
975+
\end_inset
976+
977+
. The moment conditions are not zero at the estimates of an over-identified
978+
model, and the covariance of their average accounts for the estimation of
979+
the parameters. For efficient GMM it is
980+
\end_layout
981+
982+
\begin_layout Standard
983+
\begin_inset Formula
984+
\[
985+
\hat{\Sigma}_{g}=S-G\left(G^{\prime}S^{-1}G\right)^{-1}G^{\prime}
986+
\]
987+
988+
\end_inset
989+
990+
991+
\end_layout
992+
993+
\begin_layout Standard
994+
\noindent
995+
where
996+
\begin_inset Formula $S$
997+
\end_inset
998+
999+
and
1000+
\begin_inset Formula $G$
1001+
\end_inset
1002+
1003+
are those of the covariance of the parameters. Both are divided by
1004+
\begin_inset Formula $T-df$
1005+
\end_inset
1006+
1007+
, where
1008+
\begin_inset Formula $df$
1009+
\end_inset
1010+
1011+
is the number of factors if the covariance is debiased and 0 if it is not.
1012+
The standard errors of the pricing errors are the square roots of the
1013+
diagonal elements of
1014+
\begin_inset Formula $\hat{\Sigma}_{g}/\left(T-df\right)$
1015+
\end_inset
1016+
1017+
that correspond to
1018+
\begin_inset Formula $\hat{\alpha}$
1019+
\end_inset
1020+
1021+
. This covariance has rank
1022+
\begin_inset Formula $N-K-n_{rf}$
1023+
\end_inset
1024+
1025+
, the degrees of freedom of the J statistic, where
1026+
\begin_inset Formula $n_{rf}$
1027+
\end_inset
1028+
1029+
is 1 if the risk free rate is estimated and 0 if it is not.
1030+
\end_layout
1031+
1032+
8761033
\begin_layout Standard
8771034
\begin_inset Note Note
8781035
status collapsed

‎doc/source/asset-pricing/mathematical-detail.txt‎

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ and :math:`bw` is the bandwidth. The reported risk premia are just the
4848
average returns on the factors, and the covariance of the risk premia
4949
estimates is based on the factor residuals after demeaning using either
5050
the simple estimator or the kernel estimator.
51+
If the covariance is debiased, :math:`df=K+1` is the number of regressors of
52+
each regression. The risk premia are sample means, so that their covariance
53+
uses :math:`T-1` in place of :math:`T-df`, and the covariance between the
54+
risk premia and the other parameters uses the geometric mean of the two
55+
divisors, :math:`\sqrt{\left(T-df\right)\left(T-1\right)}`. The block of the
56+
covariance of the parameters for the risk premia is then the square of their
57+
reported standard errors.
5158

5259
The J statistic
5360
~~~~~~~~~~~~~~~
@@ -179,16 +186,34 @@ previous section.
179186
The J statistic
180187
~~~~~~~~~~~~~~~
181188

182-
The J statistic is virtually identical to the :math:`J` statistic from
183-
traded factor model except that it has a difference distribution.
189+
The J statistic is similar to the :math:`J` statistic from traded factor
190+
model except that the pricing errors satisfy linear restrictions and that the
191+
statistic has a different distribution.
184192

185-
.. math:: J=\hat{\alpha}^{\prime}\hat{\Sigma}_{\alpha}^{-1}\hat{\alpha}^{\prime}\sim\chi_{N-K}^{2}
193+
.. math:: J=\hat{\alpha}^{\prime}\hat{\Sigma}_{\alpha}^{+}\hat{\alpha}=\left(Q^{\prime}\hat{\alpha}\right)^{\prime}\left(Q^{\prime}\hat{\Sigma}_{\alpha}Q\right)^{-1}\left(Q^{\prime}\hat{\alpha}\right)\sim\chi_{N-K-n_{rf}}^{2}
186194

187-
The loss of degrees of freedom occurs since
195+
where :math:`n_{rf}` is 1 if the risk free rate is estimated and 0 if it is
196+
not. The loss of degrees of freedom occurs since
188197
:math:`\hat{\alpha}=\hat{\eta}` which are regression residuals from a
189-
regression of :math:`N` average returns on :math:`K` factor loadings.
190-
:math:`\hat{\Sigma}_{\alpha}` is the bottom right :math:`K\times K`
191-
block of :math:`\hat{\Sigma}`.
198+
regression of :math:`N` average returns on the :math:`K+n_{rf}` columns of
199+
the factor loadings. The second stage estimates make :math:`\hat{\alpha}`
200+
orthogonal to the :math:`K+n_{rf}` columns of
201+
:math:`\Sigma^{-1}\hat{\beta}_{c}`, where :math:`\Sigma` is the covariance
202+
used in the GLS version or the identity matrix, so that
203+
:math:`\hat{\alpha}` lies in a space with :math:`N-K-n_{rf}` dimensions and
204+
its covariance has rank :math:`N-K-n_{rf}` in theory.
205+
:math:`\hat{\Sigma}_{\alpha}` is the block of :math:`\hat{\Sigma}` that
206+
contains the covariance of :math:`\hat{\alpha}`. The columns of :math:`Q`
207+
are an orthonormal basis of the space that is orthogonal to the columns of
208+
:math:`\Sigma^{-1}\hat{\beta}_{c}`, and
209+
:math:`\hat{\Sigma}_{\alpha}^{+}=Q\left(Q^{\prime}\hat{\Sigma}_{\alpha}Q\right)^{-1}Q^{\prime}`
210+
is the generalized inverse of :math:`\hat{\Sigma}_{\alpha}` with rank
211+
:math:`N-K-n_{rf}`. The statistic is the Wald statistic of the
212+
:math:`N-K-n_{rf}` linear combinations of the pricing errors that are not
213+
restricted to be zero. If :math:`\hat{\Sigma}_{\alpha}` were exactly singular
214+
in the directions of the columns of :math:`\Sigma^{-1}\hat{\beta}_{c}`, as the
215+
covariance of the pricing errors is in theory,
216+
:math:`\hat{\Sigma}_{\alpha}^{+}` would be its Moore-Penrose pseudo-inverse.
192217

193218
GMM Estimation of Linear Factor Models
194219
--------------------------------------
@@ -238,3 +263,20 @@ previous section. The parameter covariance estimator uses the form
238263
appropriate for efficient GMM,
239264

240265
.. math:: \hat{\Sigma}=\left(\hat{G}\hat{^{\prime}S}^{-1}\hat{G}\right)^{-1}.
266+
267+
The pricing errors, :math:`\hat{\alpha}`, are the averages of the first moment
268+
condition of each portfolio, :math:`\epsilon_{t}`. The moment conditions are
269+
not zero at the estimates of an over-identified model, and the covariance of
270+
their average accounts for the estimation of the parameters. For efficient GMM
271+
it is
272+
273+
.. math:: \hat{\Sigma}_{g}=S-G\left(G^{\prime}S^{-1}G\right)^{-1}G^{\prime}
274+
275+
where :math:`S` and :math:`G` are those of the covariance of the parameters.
276+
Both are divided by :math:`T-df`, where :math:`df` is the number of factors
277+
if the covariance is debiased and 0 if it is not. The standard errors of the
278+
pricing errors are the square roots of the diagonal elements of
279+
:math:`\hat{\Sigma}_{g}/\left(T-df\right)` that correspond to
280+
:math:`\hat{\alpha}`. This covariance has rank :math:`N-K-n_{rf}`, the degrees
281+
of freedom of the J statistic, where :math:`n_{rf}` is 1 if the risk free rate
282+
is estimated and 0 if it is not.

‎examples/asset-pricing_examples.ipynb‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@
267267
"source": [
268268
"The risk-free rate can be optionally estimated. This is useful in case excess returns are not available or if the risk-free rate used to construct the excess returns might be misspecified.\n",
269269
"\n",
270-
"Here the estimated risk-free rate is small and insignificant and has little impact on the model J-statistic."
270+
"Here the estimated risk-free rate is small and insignificant, and the model is still rejected."
271271
]
272272
},
273273
{
@@ -292,7 +292,7 @@
292292
"source": [
293293
"The default covariance estimator allows for heteroskedasticity but assumes there is no autocorrelation in the model errors or factor returns. Kernel-based HAC estimators (e.g. Newey-West) can be used by setting `cov_type=\"kernel\"`.\n",
294294
"\n",
295-
"This reduces the J-statistic indicating there might be some serial correlation although the model is still firmly rejected."
295+
"This reduces the J-statistic indicating there might be some serial correlation although the model is still rejected."
296296
]
297297
},
298298
{

0 commit comments

Comments
 (0)