Skip to content

ENH/REF/SUMM GMM round 3: cleanup and more enhancements #2640

Open

Description

@josef-pkt

Time to finish up and move it out of the sandbox.

I didn't seen a bug about wrong numbers since the last round.

TODO:

  • Documentation: write at least basic explanation and documentation for options, publish notebooks
  • API another review and some adjustments
  • some refactoring
  • check test coverage of inherited methods (e.g. I recently had to fix t_test that raised exception)

unclear yet

  • separation of cov_type from weights method: there is no option even though we have separate calculations
    e.g. AFAIR: maxiter=1 uses initial weightmatrix, but calculated cov_params based on covariance of moments after the fit. This is the main usecase.

Extensions and internal usage

  • hypothesis testing:
    • check Wald test,
    • add score/LM test,
    • refactor compare Q for fixed weights

Internal usage will not be necessary for GMM itself, but provides cases to check how well it works

  • write models that use GMM: I don't have any current plans for this, make IVPoisson official (out of test suite)
  • use GMM for specific inference questions: That's my current objective for internal use of GMM
    • get GMM representation of a model, e.g. easy for GLM
    • conditional moment tests on top of GMM representation of a model
    • covariance matrix of combined equations, example treatment effects, McFadden has some other examples for two stage estimation (e.g. heckman)

Activity

  1. added this to the 0.8 milestone on Oct 4, 2015
  2. josef-pkt commented on Oct 7, 2015

    @josef-pkt
    MemberAuthor

    related to correlation across observations:

    reading Davidson MacKinnon "Econometric Theory and Methods" chapter on GMM again (selective reading and paying attention to different details than before)
    pages 376ff have the general correlated observation case explicitly for nonlinear moment conditions with optimal instruments. It reads now a bit similar to GEE (as more general version) but with the two cases: completely unknown or completely known covariance of errors (up to scale factor).
    (GEE has working correlation which is not assumed to be correctly specified)

    The same correlation across observations structure goes through large parts of the GMM chapter 9.
    (I didn't read this carefully before because of their focus on instruments)

    Possible extension: something like GEEGMM with working correlation or working heteroscedasticity (extend the idea of GMM to noncluster case, which is already allowed in GEE)

    computational definition:

    It looks like Davidson MacKinnon use instruments to convert moment conditions to exactly identified structure, similar to the first order condition of GMM optimization. I haven't tried to figure out the details yet. (It might become "3-D" because IVGMM only allows a 1-D residual. across moments and across observations???, eg. combine two IV moment conditions like in treatment effect models or multi-parameter distributions)

    This might take us already in a similar route as DynamicPanelGMM, for which I haven't even figured out a prototype yet.

  3. josef-pkt commented on Oct 7, 2015

    @josef-pkt
    MemberAuthor

    Going through a bit of the math we can just prewhiten an array of generic moment conditions to get to working independence of observations. see #1948 for correlation and prewhitening tools.
    Calculating auxiliary parameters like autocorrelation coefficients might need more structure than generic moment conditions provide (e.g. 1-D residuals or score_factor)

    As examples: We should be able to replicate GLSAR and GLSHet as GMM models, and be able to extend them to IVGMM versions for endogenous regressors. robust cov_types can still be on top of this if the modeled correlation is only a "working correlation" structure and not assumed to be correctly specified (but it should hold approximately to improve efficiency).

  4. josef-pkt commented on Oct 7, 2015

    @josef-pkt
    MemberAuthor

    Sounds like fun, but something for "GMM round 4" not for a cleanup round 3.

    One related issue: Before I was thinking more about adding more parametric assumptions on the calculation of the weight matrix (and associated cov_params). In this case we would deviate from the nonparametric, "unspecified" correlation or heteroscedasticity. This might result in similar outcome in some models as the prewhiten version, maybe in standard linear model. However, generic GMM works with sums and weights moment conditions, while pre-whitening changes the weight that observations get.
    (e.g. exactly identified GMM replicates OLS parameters but has robust cov_params)
    (In cluster/panel/system models we could treat each cluster as one observation and each observation within the cluster as a moment condition, then correlation across moment conditions would capture correlation within clusters. )

    Davidson and MacKinnon make the point of using optimal instruments also to handle correlated observations clearer than any other book that I remember. To emphasis: parametric assumption and improvements to the estimation of the weight matrix uses more information for "efficient GMM" (ie. optimal weight matrix), but that does not say anything about optimal instruments.

    (to be continued in private repo, to avoid even more detours here.)

  5. modified the milestones: 0.9, 0.8 on Jun 17, 2016
  6. josef-pkt commented on Apr 5, 2018

    @josef-pkt
    MemberAuthor

    #4425 API changes

  7. josef-pkt commented on Aug 29, 2021

    @josef-pkt
    MemberAuthor

    summary needs improvements
    e,g, it doesn't specify with weight type, cov_type has been used.

    running an example with hac
    https://stackoverflow.com/questions/68933669/issue-with-using-statsmodels-sandbox-regression-gmm-gmm-in-python

  8. changed the title [-]ENH/REF GMM round 3: cleanup and more enhancements[/-] [+]ENH/REF/SUMM GMM round 3: cleanup and more enhancements[/+] on Aug 29, 2021
  9. josef-pkt commented on Apr 20, 2023

    @josef-pkt
    MemberAuthor

    implementation detail to check:

    approx_fprime has centered option (default is False)
    GMM.gradient_momcond explicitly computes a centered numdiff.
    Does delegating to approx_fprime with centered=True compute the same numdiff (except maybe different epsilon magnitude)?

    Aside: We are starting to make heavier use for GMM internally, e.g. treatment effect, control function/iv.

  10. modified the milestones: 0.9, 0.15 on Apr 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions