Skip to content

ENH: Add Hausman specification test #249

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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

eirki
Copy link

@eirki eirki commented Feb 27, 2020

This adds the Hausman specification test, commonly used to choose between a fixed effects model and a random effects model. The function includes the options include_constant, sigmamore, and sigmaless - which mirrors Stata.

I haven't updated the documentation, but will be happy to do so if you want.

The function calculating an alternative covariance can perhaps be removed and replaced with adding a parameter to the covariance estimation.

I realize there is already a wu_hausman method for testing exogeneity in IV models, but I could not find a way to re-use it. Maybe the mathematics could be extracted into a shared function. Also I guess I should make the naming consistent.

Finally, I have written tests, but they do not look at the actual numerical results. Do you generally generate these using Stata and then test against them?

@codecov
Copy link

codecov bot commented Feb 27, 2020

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.38%. Comparing base (556bde7) to head (3bf7264).
Report is 430 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #249      +/-   ##
==========================================
- Coverage   99.44%   99.38%   -0.06%     
==========================================
  Files          88       88              
  Lines       15557    15647      +90     
  Branches     1528     1540      +12     
==========================================
+ Hits        15470    15551      +81     
- Misses         38       41       +3     
- Partials       49       55       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bashtage
Copy link
Owner

Should this be a method attached to a RandomEffectsResults class? This would likely simplify the calculations and logic. It also makes sure that we aren't trying to compare invalid models (e.g. a 2-way FE model with a RE model).

@eirki
Copy link
Author

eirki commented Feb 28, 2020

That's a good idea, I've moved it to a method.

I'm trying to generate test data using Stata, but the generated .do-file uses a stats command that I cannot find. Could you point me in the right direction?

@FeiYao-Edinburgh
Copy link

FeiYao-Edinburgh commented Mar 25, 2020

I will keep a big eye on this issue. Hausman tests for FE and RE deserves a add! Currently I need to calculate by myself based on the estimates of FE and RE.

@eirki
Copy link
Author

eirki commented Apr 28, 2020

I have now added tests against pre-calculated values from Stata. Let me know if anything needs to be changed/added!

Base automatically changed from master to main February 22, 2021 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants