Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sandwich mle #1225

Merged
merged 4 commits into from Dec 20, 2013

Conversation

Projects
None yet
3 participants
@josef-pkt
Copy link
Member

commented Dec 11, 2013

next round of sandwich robust covariance matrices

sandwiches for MLE, mainly discrete models
similar to PR #1189 which added it to Regression models

issues:
#863 for cluster robust based on score
#1158 main overview issue with link to other issues

Changes

  • generalize sandwich_covariance.py to take score, hessian_inv DONE
    • added unit test for Poisson and NegativeBinomial for cluster so far
    • I made it backwards compatible, it still accepts results instance, but requires tuple for (jac, hessian_inv)
  • no use of wresid for WLS, GLS yet
  • add wrapper function that dispatches to individual sandwiches, like the list in RegressionResults.get_robustcov_results, to sandwich_covariance.py. intended as single point of entry for all sandwiches
  • integrate with discrete results classes
  • make additional results use robust statistics, e.g .wald_null instead of LL-Null in summary see #1104

Options, Design Problems

  • degrees of freedom and small sample corrections: Stata uses a different correction for cluster robust after Count regression models than after linear regression models. (small number of group adjustment but no nobs-k_vars adjustment)
  • not checked yet: Which HCx is Stata's robust after Poisson.
  • should we rename jac to score_obs?
  • add cov_type option consistently to fit across all models where it applies.
  • still to figure out: what's the easiest way to get the sandwiches for GLM? need the score equivalent, or WLS results (?)
  • also open non- or limited heteroscedasticity robust cov: AC, SUR structure, variations on (X'uu'X = Sigma * X'X)
    (only example so far is replicating OLS in GMM).
    These cases cannot use score directly, but need X, u in X*u separately, AFAICS.
  • demean score? I just saw this in PR #1214 and don't remember what I read (demeaning by cluster?).
    (Bruce Hansen recommends demeaning for GMM which is the default that I use. Stata uses no demeaning as default in GMM.)
@josef-pkt

This comment has been minimized.

Copy link
Member Author

commented Dec 11, 2013

test failure on TravisCI, I only ran the test suite for the directly affected directories
typo missing .shape
It also means missing test coverage because cov_white is not used yet, since we have HCx as equivalent

======================================================================
ERROR: statsmodels.sandbox.panel.tests.test_random_panel.test_short_panel
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/nose/case.py", line 197, in runTest
    self.test(*self.arg)
  File "/usr/local/lib/python2.7/dist-packages/statsmodels-0.6.0-py2.7-linux-x86_64.egg/statsmodels/sandbox/panel/tests/test_random_panel.py", line 143, in test_short_panel
    cov_white = sw.cov_white_simple(mod2.res_pooled)
  File "/usr/local/lib/python2.7/dist-packages/statsmodels-0.6.0-py2.7-linux-x86_64.egg/statsmodels/stats/sandwich_covariance.py", line 633, in cov_white_simple
    nobs, k_params = xu
ValueError: too many values to unpack
@coveralls

This comment has been minimized.

Copy link

commented Dec 11, 2013

Coverage Status

Coverage remained the same when pulling 4fc34e6 on josef-pkt:sandwich_mle into a14d989 on statsmodels:master.

@josef-pkt

This comment has been minimized.

Copy link
Member Author

commented Dec 20, 2013

rebased and force pushed

@coveralls

This comment has been minimized.

Copy link

commented Dec 20, 2013

Coverage Status

Coverage remained the same when pulling 4de0201 on josef-pkt:sandwich_mle into 8b0f906 on statsmodels:master.

@josef-pkt

This comment has been minimized.

Copy link
Member Author

commented Dec 20, 2013

green, merging as part 1 for getting robust covariances for mle, still needs integration with discrete models

josef-pkt added a commit that referenced this pull request Dec 20, 2013

Merge pull request #1225 from josef-pkt/sandwich_mle
REF/ENH generalize sandwich_covariance to work with mle models (discrete)

@josef-pkt josef-pkt merged commit 903bc22 into statsmodels:master Dec 20, 2013

1 check passed

default The Travis CI build passed
Details

@josef-pkt josef-pkt deleted the josef-pkt:sandwich_mle branch Dec 20, 2013

PierreBdR pushed a commit to PierreBdR/statsmodels that referenced this pull request Sep 2, 2014

Merge pull request statsmodels#1225 from josef-pkt/sandwich_mle
REF/ENH generalize sandwich_covariance to work with mle models (discrete)
@jbrockmendel

This comment has been minimized.

Copy link
Contributor

commented on statsmodels/discrete/tests/test_sandwich_cov.py in 7d2dfb7 Apr 8, 2018

Looks like this commented-out code existed from the initial version of this file. Suggestions for text to document this [unknown noun]? I'll be happy to make a PR. #4356

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.