Repository navigation
BUG: Fix multidimensional model cov_params when using pandas - #5956
Conversation
Codecov Report
@@ Coverage Diff @@
## master #5956 +/- ##
==========================================
+ Coverage 83% 83.01% +<.01%
==========================================
Files 604 604
Lines 95262 95299 +37
Branches 10449 10455 +6
==========================================
+ Hits 79072 79109 +37
Misses 13767 13767
Partials 2423 2423
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #5956 +/- ##
==========================================
- Coverage 83.24% 83.01% -0.23%
==========================================
Files 610 604 -6
Lines 95657 95299 -358
Branches 10483 10455 -28
==========================================
- Hits 79625 79109 -516
- Misses 13626 13767 +141
- Partials 2406 2423 +17
Continue to review full report at Codecov.
|
|
@josef-pkt Would be good if you could look at this since it is deep (affects base). |
|
Instead of "xname.yname", I think we'd be better off with a MultiIndex that didn't mangle the names at all (e.g. retained non-str names), see https://github.com/jbrockmendel/sm2/blob/master/sm2/base/data.py#L527 |
Extend PandasData to allow cov_names to be set separately from param_names closes statsmodels#5305 closes statsmodels#2270
Great idea. Much better than munged strings. |
|
As for sm2, that fix doesn't work across the board since VAR and MNLogit use reverse orders for the outer and inner indices. |
Fix cov_params and conf_int when using pandas closes statsmodels#814
| getattr(bivariate_var_result, attr) | ||
|
|
||
|
|
||
| def test_var_cov_params(bivariate_var_data): |
There was a problem hiding this comment.
test name should reflect its about pandas. ill handle in follow-up
|
|
||
| import numpy as np | ||
| import pandas as pd | ||
| from pandas.testing import assert_index_equal |
There was a problem hiding this comment.
pretty much everywhere else we import from pandas.util.testing (and im not sure if we ever use statsmodels.compat.pandas.ptesting). ill take a look in follow-up.
| #_wrap_methods = lm.wrap.union_dicts( | ||
| # _wrap_methods = lm.wrap.union_dicts( | ||
| # lm.RegressionResultsWrapper._wrap_methods, | ||
| # _methods) |
|
minor comments, generally looks good |
| # use range below to ensure sortedness | ||
| ynames = [ynames[key] for key in range(int(self.J))] | ||
| idx = MultiIndex.from_product((ynames[1:], self.data.xnames), | ||
| names=(yname, None)) |
There was a problem hiding this comment.
thoughts on adding level names?
| self.data.xnames[k_trend:]) | ||
|
|
||
| self.data.cov_names = pd.MultiIndex.from_product((self.data.xnames, | ||
| self.data.ynames)) |
There was a problem hiding this comment.
here too level names might be helpful
NumPy's guide.
Details
Notes:
needed for doc changes.
then show that it is fixed with the new code.
verify you changes are well formatted by running
flake8is installed. This command is also available on Windowsusing the Windows System for Linux once
flake8is installed in thelocal Linux environment. While passing this test is not required, it is good practice and it help
improve code quality in
statsmodels.