Repository navigation
BUG/ENH IV2SLS GMM - #1105
BUG/ENH IV2SLS GMM #1105josef-pkt wants to merge 36 commits into
Conversation
|
Travis failure |
|
We'll need to work with patsy to discuss a formula interface for this (and similar two-stage models) still, correct? |
|
for IV2SLS and similar GMM needs in the general case only a nonlinear function, In zero-inflated count models or similar we would also need two formulas, which might only be a problem if there are common elements that cannot be treated separately. another design decision: |
|
exog/instruments can usually work fine for the linear model. I used inflateX in ZIP, but I don't much care what it ends up as. In the back of my head I have the use case that caused me to give up on SUR long ago, that derived variables do not carry type information with them. E.g., in R, you can do z = y1 - x1 where x1 is endogenous, then only include z in the regression and R knows to instrument it because it's derived from an endogenous variable. We still don't have this capability but we get closer with formulas I think. I'm not sure if this applies directly to GMM. My understanding is that it's always something like E[Z u(B)] = 0. |
|
about Alexandre had a case like this in last years GSOC. I don't want to get too deep into this, because there is still the The most general version of GMM is just based on moment conditions However, in this PR everything relating to GMM is based on extending the |
|
about z = y1 - x1 again That's because I don't distinguish between endogenous in Not yet implemented: |
fix tests to use centered keyword (Stata has non-centered default)
|
Looking at it now, stata has an option whether to include the intercept or not. Default is to exclude so it shouldn't be particular to the "incidental" parameters of the panel models, though that was my intuition as to why it was excluded by default. They don't though allow you to pick variables though. You can compare models with different variables and it will test only the overlapping ones. We should probably check that the names are not generic and reject these kinds of comparisons in this case to ensure we're not testing "x1" vs a different "x1". |
|
I'm not sure what the api would be to allow comparisons across different generically named variables (not pretty). |
|
In the ivreg and gmm Stata references they recommend |
|
My spec_hausman method for IV2SLS uses one scale estimate, the one from OLS, which should be the same as |
|
Ha, that's a good find. The Hausman test does not seem to be all that well regarded in many circles. I knew about sigma(more/less). It seems odd to me to use sigmamore since the more estimator is inconsistent under the alternative hypothesis IIRC, but I haven't looked at the proofs. One of the reasons I wanted to find the Gouriéroux and Monfort textbook/handbook. |
I don't see this in the Stata manual. I think we can check that the variable/parameter names agree and if not raise. however, it might be better to add an option to override this check. In GMM in this PR I don't have automatic param_names yet, and no inherited datahandling. |
|
Ha, that's a good find. The Hausman test does not seem to be all that well The proofs will be under the assumption that the Null holds, so we can use |
|
You might just try inheriting from Model and see how far it gets you. It might be, ideally should be, free. I can help you through this code if/when you get a chance to do this. |
|
Changed to inherit from base.Model. endog and exog are in some cases meaningless, because it's just a way to transport the data to the moment conditions. |
|
Right. We might/do need some special handling for these cases and for systems of equations, etc. You can see the panel PR for how I did this there. Mostly straight-forward just need to overwrite a few methods. I can give a hand here. |
|
test coverage is only 67% so far IV2SLS has essentially full test coverage in |
BUG/ENH Gmm new closes statsmodels#1105
|
merged in #1258 |
see #1066 #1096
Fixes IV2SLS, finishes up, and adds tests against Stata
resettest also needs to be adjusted (reduced form yhat as regressor)Some improvement and refactoring of GMM using IVGMM as test case.
(weights, invweights and cov_moments are still not fully separated, code mixes them up.)
-> refactored, but Stata gmm oneway produces different results for
bseandq,jvalDONE Stata uses different defaults, I get good agreement using the same options
onestep and iid replicates OLS
DONE added LinearIVGMM
DONE unit tests with GMM replicating OLS at >10 decimals
jtestis only valid if optimal GMM (no checks for this)sandwich_covariance, and automatic lag/bandwidth selectionOptimization Difficulties
Trying the datasets.randhie Poisson example as test case:
bfgstakes a long time, usingnmfirst helpsbfgsExamples/Usage