Skip to content

Commit 09ba36c

Browse files
authored
Merge pull request #169 from bashtage/fix-small-issues
Fix small issues
2 parents d8997ad + 7dde8bd commit 09ba36c

File tree

20 files changed

+87
-106
lines changed

20 files changed

+87
-106
lines changed

doc/source/conf.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,16 +207,16 @@
207207

208208
# Example configuration for intersphinx: refer to the Python standard library.
209209
intersphinx_mapping = {
210-
'statsmodels': ('http://www.statsmodels.org/dev/', None),
211-
'matplotlib': ('http://matplotlib.org/', None),
210+
'statsmodels': ('https://www.statsmodels.org/dev/', None),
211+
'matplotlib': ('https://matplotlib.org/', None),
212212
'scipy': ('https://docs.scipy.org/doc/scipy/reference/', None),
213213
'python': ('https://docs.python.org/3', None),
214214
'numpy': ('https://docs.scipy.org/doc/numpy', None),
215-
'pandas': ('http://pandas.pydata.org/pandas-docs/stable/', None),
216-
'xarray': ('http://xarray.pydata.org/en/stable/', None)
215+
'pandas': ('https://pandas.pydata.org/pandas-docs/stable/', None),
216+
'xarray': ('https://xarray.pydata.org/en/stable/', None)
217217
}
218218

219-
extlinks = {'issue': ('https://github.com/bashtage/arch/issues/%s', 'GH')}
219+
extlinks = {'issue': ('https://github.com/bashtage/linearmodels/issues/%s', 'GH')}
220220

221221

222222
doctest_global_setup = """

doc/source/iv/index.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ specification tests. Other components of the models such as covariance
88
estimators, GMM weighting estimators and the results are presented in
99
:ref:`iv-module-reference`.
1010

11-
:ref:`Basic Examples <iv/examples/basic-examples.ipynb>` shows basic usage
12-
through examples from Wooldridge's introductory text book and
13-
:ref:`Advanced Examples <iv/examples/advanced-examples.ipynb>` shows more
14-
advanced examples following the examples in Cameron and Trivedi's Stata
11+
`Basic Examples`_ shows basic usage through examples from Wooldridge's
12+
introductory text book and `Advanced Examples`_
13+
shows more advanced examples following the examples in Cameron and Trivedi's Stata
1514
introduction.
1615

1716
:ref:`iv-mathematical-notation` contains a concise explanation of the formulas
@@ -28,3 +27,6 @@ tests.
2827
examples/using-formulas.ipynb
2928
reference
3029
mathematical-formula
30+
31+
.. _Basic Examples: iv/examples/basic-examples.ipynb
32+
.. _Advanced Examples: iv/examples/advanced-examples.ipynb

doc/source/panel/index.rst

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,11 @@ reference to available estimation methods.
77
after estimating a model as well as model specification tests. The covariance
88
estimators are presented in :ref:`panel-module-reference-covariance`.
99

10-
:ref:`Basic Examples <panel/examples/examples.ipynb>` shows basic usage
11-
of the models using examples from Wooldridge's text books.
12-
:ref:`Using Formulas <panel/examples/using-formulas.ipynb>` shows how models
13-
can be specified using R-like formulas using patsy.
14-
:ref:`Data Formats <panel/examples/data-formats.ipynb>` described the
10+
`Basic Examples`_ shows basic usage of the models using examples from
11+
Wooldridge's text books. `Using Formulas`_ shows how models can be specified
12+
using R-like formulas using patsy. `Data Formats`_ described the
1513
alternative formats that can be used when specifying models.
1614

17-
1815
:ref:`panel-mathematical-notation` contains a concise explanation of the formulas
1916
used in estimating parameters, estimating covariances and conducting
2017
hypothesis tests.
@@ -36,4 +33,9 @@ until release 0.20.
3633
pandas
3734
reference
3835
mathematical-formula
39-
faq
36+
faq
37+
38+
39+
.. _Basic Examples: panel/examples/examples.ipynb
40+
.. _Using Formulas: panel/examples/using-formulas.ipynb
41+
.. _Data Formats: panel/examples/data-formats.ipynb

examples/iv_advanced-examples.ipynb

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@
2525
{
2626
"cell_type": "code",
2727
"execution_count": null,
28-
"metadata": {
29-
"collapsed": true
30-
},
28+
"metadata": {},
3129
"outputs": [],
3230
"source": [
3331
"from linearmodels import IV2SLS, IVLIML, IVGMM, IVGMMCUE"
@@ -113,9 +111,7 @@
113111
{
114112
"cell_type": "code",
115113
"execution_count": null,
116-
"metadata": {
117-
"collapsed": true
118-
},
114+
"metadata": {},
119115
"outputs": [],
120116
"source": [
121117
"from statsmodels.api import OLS, add_constant\n",
@@ -176,9 +172,7 @@
176172
{
177173
"cell_type": "code",
178174
"execution_count": null,
179-
"metadata": {
180-
"collapsed": true
181-
},
175+
"metadata": {},
182176
"outputs": [],
183177
"source": [
184178
"ivmod = IV2SLS(data.ldrugexp, data[controls], data.hi_empunion, data[['ssiratio','multlc']])\n",
@@ -207,9 +201,7 @@
207201
{
208202
"cell_type": "code",
209203
"execution_count": null,
210-
"metadata": {
211-
"collapsed": true
212-
},
204+
"metadata": {},
213205
"outputs": [],
214206
"source": [
215207
"ivmod = IV2SLS(data.ldrugexp, data[controls], data.hi_empunion, data[['ssiratio','multlc']])\n",
@@ -230,9 +222,7 @@
230222
{
231223
"cell_type": "code",
232224
"execution_count": null,
233-
"metadata": {
234-
"collapsed": true
235-
},
225+
"metadata": {},
236226
"outputs": [],
237227
"source": [
238228
"ivmod =IVGMM(data.ldrugexp, data[controls], data.hi_empunion, data[['ssiratio','multlc']])\n",
@@ -250,9 +240,7 @@
250240
{
251241
"cell_type": "code",
252242
"execution_count": null,
253-
"metadata": {
254-
"collapsed": true
255-
},
243+
"metadata": {},
256244
"outputs": [],
257245
"source": [
258246
"ivmod = IVGMM(data.ldrugexp, data[controls], data.hi_empunion, data[['ssiratio','multlc']], \n",
@@ -560,7 +548,7 @@
560548
"name": "python",
561549
"nbconvert_exporter": "python",
562550
"pygments_lexer": "ipython3",
563-
"version": "3.5.3"
551+
"version": "3.7.0"
564552
},
565553
"nbsphinx": {
566554
"allow_errors": true

examples/iv_basic-examples.ipynb

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,7 @@
318318
{
319319
"cell_type": "code",
320320
"execution_count": null,
321-
"metadata": {
322-
"collapsed": true
323-
},
321+
"metadata": {},
324322
"outputs": [],
325323
"source": [
326324
"dep = ['wage']\n",
@@ -406,7 +404,7 @@
406404
"source": [
407405
"### Formula interface\n",
408406
"\n",
409-
"This model was large and so it might be simpler to use a formula. While formulas are discussed in [detail in another notebook](iv/examples/using-formulas.ipynb), they use the formula language of patsy with an augmentation to specify the endogenous and instrumental variables. The generic form is\n",
407+
"This model was large and so it might be simpler to use a formula. While formulas are discussed in [detail in another notebook](using-formulas.ipynb), they use the formula language of patsy with an augmentation to specify the endogenous and instrumental variables. The generic form is\n",
410408
"\n",
411409
"```\n",
412410
"dependent ~ exog + [endog ~ instr]\n",
@@ -467,9 +465,7 @@
467465
{
468466
"cell_type": "code",
469467
"execution_count": null,
470-
"metadata": {
471-
"collapsed": true
472-
},
468+
"metadata": {},
473469
"outputs": [],
474470
"source": [
475471
"data = mroz.load()\n",
@@ -562,9 +558,7 @@
562558
{
563559
"cell_type": "code",
564560
"execution_count": null,
565-
"metadata": {
566-
"collapsed": true
567-
},
561+
"metadata": {},
568562
"outputs": [],
569563
"source": [
570564
"u = res.resids\n",
@@ -597,9 +591,7 @@
597591
{
598592
"cell_type": "code",
599593
"execution_count": null,
600-
"metadata": {
601-
"collapsed": true
602-
},
594+
"metadata": {},
603595
"outputs": [],
604596
"source": [
605597
"instr = ['fatheduc','motheduc','huseduc']\n",
@@ -746,7 +738,7 @@
746738
"name": "python",
747739
"nbconvert_exporter": "python",
748740
"pygments_lexer": "ipython3",
749-
"version": "3.5.3"
741+
"version": "3.7.0"
750742
}
751743
},
752744
"nbformat": 4,

examples/system_examples.ipynb

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@
5858
{
5959
"cell_type": "code",
6060
"execution_count": null,
61-
"metadata": {
62-
"collapsed": true
63-
},
61+
"metadata": {},
6462
"outputs": [],
6563
"source": [
6664
"from linearmodels.datasets import munnell\n",
@@ -100,9 +98,7 @@
10098
{
10199
"cell_type": "code",
102100
"execution_count": null,
103-
"metadata": {
104-
"collapsed": true
105-
},
101+
"metadata": {},
106102
"outputs": [],
107103
"source": [
108104
"grouped = data.groupby(['REGION','YR'])\n",
@@ -133,9 +129,7 @@
133129
{
134130
"cell_type": "code",
135131
"execution_count": null,
136-
"metadata": {
137-
"collapsed": true
138-
},
132+
"metadata": {},
139133
"outputs": [],
140134
"source": [
141135
"from collections import OrderedDict\n",
@@ -159,9 +153,7 @@
159153
{
160154
"cell_type": "code",
161155
"execution_count": null,
162-
"metadata": {
163-
"collapsed": true
164-
},
156+
"metadata": {},
165157
"outputs": [],
166158
"source": [
167159
"import pandas as pd\n",
@@ -700,7 +692,7 @@
700692
"name": "python",
701693
"nbconvert_exporter": "python",
702694
"pygments_lexer": "ipython3",
703-
"version": "3.5.3"
695+
"version": "3.7.0"
704696
}
705697
},
706698
"nbformat": 4,

linearmodels/asset_pricing/model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -708,8 +708,8 @@ def fit(self, center=True, use_cue=False, steps=2, disp=10, max_iter=1000,
708708
# 1. Starting Values - use 2 pass
709709
mod = LinearFactorModel(self.portfolios, self.factors, risk_free=self._risk_free)
710710
res = mod.fit()
711-
betas = res.betas.values.ravel()
712-
lam = res.risk_premia.values
711+
betas = np.asarray(res.betas).ravel()
712+
lam = np.asarray(res.risk_premia)
713713
mu = self.factors.ndarray.mean(0)
714714
sv = np.r_[betas, lam, mu][:, None]
715715
g = self._moments(sv, excess_returns)

linearmodels/asset_pricing/results.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ def summary(self):
8989
table.extend_right(SimpleTable(vals, stubs=stubs))
9090
smry.tables.append(table)
9191

92-
rp = self.risk_premia.values[:, None]
93-
se = self.risk_premia_se.values[:, None]
94-
tstats = (self.risk_premia / self.risk_premia_se).values
92+
rp = np.asarray(self.risk_premia)[:, None]
93+
se = np.asarray(self.risk_premia_se)[:, None]
94+
tstats = np.asarray(self.risk_premia / self.risk_premia_se)
9595
pvalues = 2 - 2 * stats.norm.cdf(np.abs(tstats))
9696
ci = rp + se * stats.norm.ppf([[0.025, 0.975]])
9797
param_data = np.c_[rp,
@@ -160,8 +160,8 @@ def full_summary(self):
160160
first = True
161161
for row in params.index:
162162
smry.tables.append(SimpleTable(['']))
163-
smry.tables.append(self._single_table(params.loc[row].values[:, None],
164-
se.loc[row].values[:, None],
163+
smry.tables.append(self._single_table(np.asarray(params.loc[row])[:, None],
164+
np.asarray(se.loc[row])[:, None],
165165
row, param_names, first))
166166
first = False
167167

linearmodels/iv/data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def __init__(self, x, var_name='x', nobs=None, convert_dummies=True, drop_first=
101101
x = expand_categoricals(x, drop_first)
102102

103103
self._pandas = x
104-
self._ndarray = self._pandas.values
104+
self._ndarray = np.asarray(self._pandas)
105105
if all_numeric or convert_dummies:
106106
self._ndarray = self._ndarray.astype(np.float64)
107107
self._labels = {i: list(label) for i, label in zip(range(x.ndim), x.axes)}

linearmodels/iv/model.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ def predict(self, params, *, exog=None, endog=None, data=None, eval_env=4):
278278
exog = parser.exog
279279
endog = parser.endog
280280
exog_endog = concat([exog, endog], 1)
281-
x = exog_endog.values
281+
x = asarray(exog_endog)
282282
params = atleast_2d(asarray(params))
283283
if params.shape[0] == 1:
284284
params = params.T
@@ -500,7 +500,7 @@ def _post_estimation(self, params, cov_estimator, cov_type):
500500
index = self._index
501501
eps = self.resids(params)
502502
y = self.dependent.pandas
503-
fitted = DataFrame(y.values - eps, y.index, ['fitted_values'])
503+
fitted = DataFrame(asarray(y) - eps, y.index, ['fitted_values'])
504504
weps = self.wresids(params)
505505
cov = cov_estimator.cov
506506
debiased = cov_estimator.debiased
@@ -824,7 +824,7 @@ def fit(self, *, iter_limit=2, tol=1e-4, initial_weight=None,
824824
wmat = inv(wz.T @ wz / nobs) if initial_weight is None else initial_weight
825825
sv = IV2SLS(self.dependent, self.exog, self.endog, self.instruments,
826826
weights=self.weights)
827-
_params = params = sv.fit().params.values[:, None]
827+
_params = params = asarray(sv.fit().params)[:, None]
828828
# _params = params = self.estimate_parameters(wx, wy, wz, wmat)
829829

830830
iters, norm = 1, 10 * tol + 1
@@ -1117,7 +1117,7 @@ def fit(self, *, starting=None, display=False, cov_type='robust', opt_options=No
11171117
res = IVGMM(self.dependent, exog, endog, instr,
11181118
weights=self.weights, weight_type=self._weight_type,
11191119
**self._weight_config).fit()
1120-
starting = res.params.values
1120+
starting = asarray(res.params)
11211121
else:
11221122
starting = asarray(starting)
11231123
if len(starting) != self.exog.shape[1] + self.endog.shape[1]:

0 commit comments

Comments
 (0)