Skip to content

Commit 4f9e8f3

Browse files
committed
RLS: Final clean up prior to release
Final documentation cleanup
1 parent 321e241 commit 4f9e8f3

File tree

16 files changed

+186
-58
lines changed

16 files changed

+186
-58
lines changed

.travis.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ env:
1414
- PANDAS=pandas
1515
- COVERAGE=true
1616
- SKIPSLOW=""
17+
- DOCTR_PUSH_TYPE=""
1718
- secure: "aCm98s/mNxRSoTEhpIgfvRKzzJKdDkm/9TufIvgWvnkeiyDQqZwoqRVDIikZ+v6mkFeu7dr7BBojyPXnhkhji+SkNFz5ArtEqahJTvIZhP2nWgktlQSWkaC2Q5GyCWPhdQag/ImYbM4RK1WvtIVcSL7GPL0jLTgFDXY6/Hdl0eQY7kfWtojxIZUJShxn9IPfXE3gGQeWHEOL7SkZ3+8KxBJAUzrdd9J32PiHWZb5BcUupTQcW29ajoco4q1fdL/xPu3GZnys8EClorHxnPptQWfGGlnoJ79Q6H7Jhw6BGIj2fDCG9qX4boEH2zvH8ZKlbuTvMeVcBiLxPE8BpRmx2drX2kDyUo5ywVwA0W/7zsZ2YUYEyHEYL+cr4WVFdoDpwwPKaHOTp8F4Q+lQgkvxZbSlO6dUEMLNxnltgujAAdiaRJKLd2CwA85RjqYGLkMzTqBgYhH+p+7wB6jK8EJgoqxU3k98LfaeqyhsPrdWsxVLleLVAvzhXpNilQfX4NBPf+DYsn9NeyXYzp85H9p+J8DGJMJ42kBdP1r/cz1Y44SrGZhlk1MhLhb+uX7kV7nnmcW87NYoGSr52S5vNVL9iSU980SzJ08wOZwxwkKXOqgEJtMqdHsEuqY9jSQ2m/xAdarpxBsDD+Pw2gPfar+R8Lcptep50pMPFMgddDWV2f4="
1819

1920
matrix:
@@ -55,14 +56,16 @@ before_install:
5556
- pip install sphinx --upgrade
5657
- export PYTHONHASHSEED=0
5758
- export MKL_NUM_THREADS=1
59+
- if [[ ${TRAVIS_TAG} ]]; then export DOCTR_PUSH_TYPE="--no-require-master"; fi
60+
- echo ${DOCTR_PUSH_TYPE}
5861

5962
install:
6063
- python setup.py develop
6164

6265
script:
6366
- pytest -n 2 --cov-config .coveragerc --cov=linearmodels linearmodels --durations=10 ${SKIPSLOW}
6467
- set -e
65-
- if [ ${DOCBUILD} ]; then cd doc && make html && make html && cd .. && doctr deploy doc; fi
68+
- if [ ${DOCBUILD} ]; then cd doc && make html && make html && cd .. && doctr deploy doc ${DOCTR_PUSH_TYPE}; fi
6669

6770
after_success:
6871
- if [ ${COVERAGE} = true ]; then codecov; fi

doc/source/asset-pricing/convert-lyx.cmd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ pandoc -s mathematical-detail.tex -o mathematical-detail.rst
33
copy /Y mathematical-detail.rst mathematical-detail-pre.txt
44
del mathematical-detail.rst
55
python -c "open('mathematical-detail.txt','w').write(''.join(open('mathematical-detail-pre.txt').readlines()[3:]))"
6-
del mathematical-detail-pre.txt
6+
del mathematical-detail-pre.txt
7+
del mathematical-detail.tex
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.. _asset_pricing-module-reference-covariance:
2+
3+
Linear Asset Pricing Model Covariance Estimators
4+
------------------------------------------------
5+
6+
.. module:: linearmodels.asset_pricing.covariance
7+
:synopsis: Covariance estimators for asset pricing models
8+
9+
Heteroskedasticity Robust Covariance Estimation
10+
===============================================
11+
.. autoclass:: HeteroskedasticCovariance
12+
:members:
13+
:inherited-members:
14+
15+
HAC Robust (Kernel) Covariance Estimation
16+
=========================================
17+
.. autoclass:: KernelCovariance
18+
:members:
19+
:inherited-members:

doc/source/asset-pricing/introduction.rst

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,21 @@ prior to estimation.
4949
LinearFactorModel Estimation Summary
5050
================================================================================
5151
No. Test Portfolios: 6 R-squared: 0.8879
52-
No. Factors: 3 J-statistic: 30.694
52+
No. Factors: 3 J-statistic: 39.109
5353
No. Observations: 819 P-value 0.0000
54-
Date: Thu, May 18 2017 Distribution: chi2(3)
55-
Time: 22:23:54
54+
Date: Sun, May 21 2017 Distribution: chi2(3)
55+
Time: 21:18:56
5656
Cov. Estimator: kernel
5757

5858
Risk Premia Estimates
5959
==============================================================================
6060
Parameter Std. Err. T-stat P-value Lower CI Upper CI
6161
------------------------------------------------------------------------------
62-
MktRF 0.0060 0.0113 0.5305 0.5958 -0.0162 0.0282
63-
SMB 0.0001 0.0081 0.0178 0.9858 -0.0157 0.0160
64-
HML 0.0045 0.0032 1.4041 0.1603 -0.0018 0.0108
62+
MktRF 0.0060 0.0016 3.7381 0.0002 0.0029 0.0092
63+
SMB 0.0001 0.0011 0.1281 0.8980 -0.0021 0.0023
64+
HML 0.0045 0.0012 3.7904 0.0002 0.0022 0.0068
6565
==============================================================================
6666

67-
See full_summary for complete results
67+
Covariance estimator:
68+
KernelCovariance, Kernel: bartlett, Bandwidth: 4
69+
See full_summary for complete results

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ FOC of these three steps are
9797

9898
g_{t}=\left[\begin{array}{c}
9999
f_{c,t}\otimes\epsilon_{t}\\
100-
\beta^{\prime}\left(r_{t}-\left[1_{N}\,\beta\right]\lambda\right)\\
100+
\left[1_{N}\,\beta\right]^{\prime}\left(r_{t}-\left[1_{N}\,\beta\right]\lambda\right)\\
101101
r_{t}-\left[1_{N}\,\beta\right]\lambda-\alpha
102102
\end{array}\right]
103103

@@ -141,18 +141,18 @@ Improved Specification using GLS
141141

142142
\left[\begin{array}{c}
143143
f_{c,t}\otimes\epsilon_{t}\\
144-
\beta^{\prime}\Sigma^{-1}\left(r_{t}-\left[1_{N}\,\beta\right]\lambda\right)\\
145-
r_{t}-\left[1_{N}\,\beta\right]\lambda-\alpha
144+
\beta_{c}^{\prime}\Sigma^{-1}\left(r_{t}-\beta_{c}\lambda\right)\\
145+
r_{t}-\beta_{c}\lambda-\alpha
146146
\end{array}\right]
147147

148148
The Jacobian is than
149149

150150
.. math::
151151

152-
\hat{G}=-\left[\begin{array}{cccc}
153-
I_{N}\otimes\Sigma_{f_{c}} & 0 & 0 & 0\\
154-
G_{12} & -\hat{\beta}_{c}^{\prime}\Sigma^{-1}\hat{\beta} & \hat{\beta}_{c}^{\prime}\Sigma^{-1}\hat{\beta}_{c} & 0\\
155-
I_{N}\otimes\left[0\ \tilde{\lambda}\right] & -\hat{\beta} & \hat{\beta}_{c} & I_{N}
152+
\hat{G}=-\left[\begin{array}{ccc}
153+
I_{N}\otimes\Sigma_{f_{c}} & 0 & 0\\
154+
G_{12} & \hat{\beta}_{c}^{\prime}\Sigma^{-1}\hat{\beta}_{c} & 0\\
155+
I_{N}\otimes\left[0\ \tilde{\lambda}\right] & \hat{\beta}_{c} & I_{N}
156156
\end{array}\right]
157157

158158
:math:`\beta_{c}=\left[1_{N}\,\beta\right]`.

doc/source/asset-pricing/reference.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ Module Reference
99

1010
models
1111
results
12+
covariance
1213

doc/source/panel/covariance.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,21 @@ Driscoll-Kraay HAC Estimator
2929
.. autoclass:: DriscollKraay
3030
:members:
3131
:inherited-members:
32+
33+
AC Robust Estimator
34+
===================
35+
.. autoclass:: ACCovariance
36+
:members:
37+
:inherited-members:
38+
39+
Fama-MacBeth Covariance Estimator
40+
=================================
41+
.. autoclass:: FamaMacBethCovariance
42+
:members:
43+
:inherited-members:
44+
45+
Fama-MacBeth HAC Covariance Estimator
46+
=====================================
47+
.. autoclass:: FamaMacBethKernelCovariance
48+
:members:
49+
:inherited-members:

doc/source/panel/pandas.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
.. _panel-pandas-differences:
22

3-
Comparison with pandas PanelOLS
4-
===============================
3+
Comparison with pandas PanelOLS and FamaMacBeth
4+
===============================================
55

6-
pandas deprecated ``PanelOLS`` (``pandas.stats.plm.PanelOLS``) in 0.18 and
7-
dropped it in 0.20. :class:`linearmodels.panel.model.PanelOLS` provides
6+
pandas deprecated ``PanelOLS`` (``pandas.stats.plm.PanelOLS``) and
7+
``FamaMacBeth`` (``pandas.stats.plm.FamaMacBeth``) in 0.18 and
8+
dropped it in 0.20. :class:`linearmodels.panel.model.PanelOLS`
9+
and :class:`linearmodels.panel.model.FamaMacBeth` provide
810
a similar set of functionality with a few notable differences:
911

1012
1. When using a MultiIndex DataFrame, this package expects the MultiIndex

doc/source/plan.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Module Plans
22
------------
33
The plan for this modules is to add some key missing linear models. This plan is intentionally
4-
limited since there is no intention to statsmodels.
4+
limited since there is no intention to replicate estimators available in statsmodels.
55

66
Univariate
77
==========
@@ -14,12 +14,6 @@ Univariate
1414
* GMM IV Estimation - :class:`linearmodels.iv.model.IVGMM`
1515
* GMM-CUE Estimation - :class:`linearmodels.iv.model.IVGMMCUE`
1616

17-
In Progress
18-
***********
19-
* 2-step Linear Asset Pricing Model Estimation - :class:`linearmodels.asset_pricing.model.LinearFactorModel`
20-
* Linear Asset Pricing Model Estimation for Traded Factors - :class:`linearmodels.asset_pricing.model.TradedFactorModel`
21-
22-
2317
Panel
2418
=====
2519

@@ -34,6 +28,12 @@ Least Squares Estimators
3428
* Fama-MacBeth - :class:`linearmodels.panel.model.FamaMacBeth`
3529

3630

31+
Asset Pricing
32+
*************
33+
* 2-step Linear Asset Pricing Model Estimation - :class:`linearmodels.asset_pricing.model.LinearFactorModel`
34+
* GMM Linear Asset Pricing Model Estimation - :class:`linearmodels.asset_pricing.model.LinearFactorModelGMM`
35+
* Linear Asset Pricing Model Estimation for Traded Factors - :class:`linearmodels.asset_pricing.model.TradedFactorModel`
36+
3737
Instrumental Variable Estimators
3838
********************************
3939

linearmodels/asset_pricing/covariance.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
"""
2+
Covariance estimators for linear factor models
3+
"""
14
from numpy.linalg import inv
25
from linearmodels.iv.covariance import KERNEL_LOOKUP, kernel_optimal_bandwidth, _cov_kernel
36

@@ -113,7 +116,7 @@ def cov(self):
113116

114117
class KernelCovariance(HeteroskedasticCovariance):
115118
"""
116-
Heteroskedasticity robust covariance estimator
119+
Heteroskedasticity-autocorrelation (HAC) robust covariance estimator
117120
118121
Parameters
119122
----------

0 commit comments

Comments
 (0)