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

Compare lr test rebased #1214

Merged
merged 14 commits into from Dec 11, 2013

Conversation

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

commented Nov 30, 2013

rebased and cleaned up version of @bashtage PR #1174

I skipped some redundant commits, and edited the commits during merge conflicts (in almost every commit).

Main change besides cleanup of reverted and unnecessary commits is in default cov_type="nonrobust" especially commit 4d517f5

A second change that I kept from my sandwich branch and didn't change during rebase is that the default is use_t=None not use_t=False. A minor generic reason is that in this case we can identify if the user explicitly specifies use_t. The main reason is that None means default, which will be use_t=True with cov_type='nonrobust' in linear model, but I think also withcov_type='cluster', andFalse` for all other covariances and models.
Still up for debate.

I'd like to merge this before #1173 and #1176 because I saw one duplicate commit too late to drop it.

Discussion on cov_type="nonrobust"

#1189 (comment) and follow-up

I changed "H" for homoscedasticity to "nonrobust", both because I'm not a fan of one letter names (does H mean homo- or heteroscedasticity as in HCx), and because "nonrobust" doesn't imply that we assume homoscedasticity.

To the later point:

  • We can estimate a linear model with WLS that uses an estimated heteroscedasticity function (the wresid would be homoscedastic but not the resid if the specification is correct). However, we can still use either a robust or a nonrobust covariance matrix after estimating with WLS.
  • In Poisson and most other generalized linear models we have an implied heteroscedasticity. "nonrobust" means that the heteroscedasticity of the underlying (Q)MLE model is not assumed to be correctly specified.

Same applies to auto- or cluster correlation.

Plus, Wooldridge talks all the time of using robust or not robust covariance matrices or hypothesis tests.

So far I can think of only "nonrobust" that captures the idea that we are not robust to misspecification of the error covariance matrix. The opposite view would be the model has correctly specified second moments, but I don't know a good short name for that.

Kevin Sheppard and others added some commits Oct 30, 2013

Added test that check whether OLS, GLS and WLS produce the same resul…
…ts when the weight matrix or sigma are diagonal with the same values
LM test now handles robust covariance
Fixed loglikelihood in WLS
Lots of Typo fixed in docstrings
PEP8 fixes
Added _is_nested method to detect nested models
rebase conflicts fixed, hopefully
Added tests for compare_lm_test
Fixed test for summary which was failing due to now mandatory cov_type
Added additional OLS/WLS/GLS equivalence tests
Added _has_constant function which can detect implicit constant
Added _is_nested to test whether models are nested when comparing models
Added compare_lm_test
Merged with get_robustvcv_result which is needed to implement tests
Added large sample likelihood-ratio test
Implemented cov_type for all models including homoskedastic regression.  Use 'H' for the homoskedastic case
heavily edited for 'nonrobust' instead of 'H' during rebase
@josef-pkt

This comment has been minimized.

Copy link
Member Author

commented Nov 30, 2013

I didn't review yet the new functions in detail.

@bashtage do you see anything obvious that I might have messed up during rebase?

The test suite passes, and I would like to merge this soon, so we have again a common code for working on the next parts, with hopefully fewer merge conflicts next time.

@coveralls

This comment has been minimized.

Copy link

commented Nov 30, 2013

Coverage Status

Coverage remained the same when pulling aad6bae on josef-pkt:compare_lr_test_rebased into a14d989 on statsmodels:master.


if has_robust1 or has_robust2:
import warnings
warnings.warn('Likelihood Ratio test is likely invalid with ' +
'robust covariance, proceeding anyway', UserWarning)

# See mailing list discussion October 17,
if large_sample:
return self.compare_lr_test(restricted, use_lr=True)

This comment has been minimized.

Copy link
@josef-pkt

josef-pkt Dec 1, 2013

Author Member

rebase error
this is duplicate from above line 1495 and should be deleted
call to compare_lm_test uses robust cov

@@ -114,6 +135,24 @@ def df_resid(self):
def df_resid(self, value):
self._df_resid = value

def _has_constant(self):

This comment has been minimized.

Copy link
@josef-pkt

josef-pkt Dec 11, 2013

Author Member

I think this should move to some place more general, to base or to tools (in follow-up PR)

This comment has been minimized.

Copy link
@bashtage

bashtage Dec 13, 2013

Contributor

Makes sense. I think that this is a general technique that should be available to other models, e.g. glm.

@josef-pkt josef-pkt referenced this pull request Dec 11, 2013

Merged

Sandwich mle #1225

@coveralls

This comment has been minimized.

Copy link

commented Dec 11, 2013

Coverage Status

Coverage remained the same when pulling 80acfff on josef-pkt:compare_lr_test_rebased into a14d989 on statsmodels:master.

@josef-pkt

This comment has been minimized.

Copy link
Member Author

commented Dec 11, 2013

merging this

Thank you Kevin,
I'm going to merge the other two PR next.
I don't remember now where the WLS=GLS change is because I don't see any test failures.

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

@josef-pkt josef-pkt merged commit fe97936 into statsmodels:master Dec 11, 2013

1 check passed

default The Travis CI build passed
Details

@josef-pkt josef-pkt deleted the josef-pkt:compare_lr_test_rebased branch Dec 16, 2013

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

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.