Skip to content

ENH: special case exactly identified GMM, M-estimator estimating equations #7436

Open

Description

@josef-pkt

related
#1790
#2898
#5674

I'm looking at M-estimators that are defined through estimating equations, moment conditions and don't have a specified (or simple) objective function.

computational: We currently don't have a general setup for solving estimating equations (multivariate root finding). Currently we have

  • specific optimizers: e.g. IRLS in GLM and RLM, some in GEE,
  • Our newton only really uses score and hessian but requires objective function

alternative would be to use GMM for the special case of exactly identified model.

One computational issue optimization in GMM
The derivative of GMM objective function is more complicated than just moment condition. It involves already derivative of moment condition. Second derivative of GMM objective function would include second derivatives of moment conditions.
However, cov_params in GMM does not use second derivative (hessian) of objective function. The required matrices are moment condition itself and derivative of moment condition, similarly to MLE.

Current GMM handles exactly identified case, but I guess the computations could be streamlined for the exactly identified case.
Multivariate rootfinding might be computationally more efficient than maximizing GMM objective.

So

  • add new GMM class (if it looks a large enough improvement)
  • try out scipy.optimize multivariate root finders as alternative to optimization

my current motivation: (outlier) robust estimator for GLM (quasi-GLM) which are often defined in the literature by estimating equations.
older case: RLM with variance functions where mean and variance functions are not from an optimization problem (when I was working on #3261 and similar)

Activity

  1. added this to the 0.14 milestone on Dec 6, 2021
  2. josef-pkt commented on Dec 6, 2021

    @josef-pkt
    MemberAuthor

    bump.

    I have an old notebook for this.
    A basic new class shouldn't be too difficult to add, maybe take a model and extra moms as arguments.

    The main application that I have in mind right now is adding extra moment conditions and parameters to the MLE moment conditions.
    e.g. the new get_prediction computes standard errors only as a function of the parameter estimate uncertainty.
    For in-sample statistics we need to take also correlation of moment conditions with the extra, added moment condition into account.
    We do this in special cases like CMT for specification tests, e.g. zero-inflation test by He et al (several articles). or chisquare test on probabilities for y-bins.

    Variable addition score_test also adds extra moment conditions, but doesn't allow arbitrary extra moment conditions.
    We could use that comparison to score_test as unit test case for the GMM version.

    Similar structure as this is in treatment effects, ATE, POM (PR ...), that follows Stata and uses GMM for inference.
    This version has two models plus extra moms. treatment model, outcome model and extra statistic of interest like ATE, POM.

    This is still exactly identified case because we add one extra parameter for each extra moment condition.

  3. josef-pkt commented on Jan 11, 2023

    @josef-pkt
    MemberAuthor

    (random idea while thinking about iteration loops)

    for numerical stability it might be useful to start with rescaled score
    e.g. in GMM, the weight matrix is diag(var(cov_obs(params)))
    edit maybe not var which subtracts mean. In analogy to OLS rescaling exog, we would need the inner product of score_obs without demeaning.

    This might help with badly scaled exog or "exp" scaling problem, e.g. if score_obs is score_factor * exog where we would rescale by weighted var(exog).

    In exactly identified models, the weight matrix does not matter for optimization (score will be zero).

    Extended to overidentified GMM:
    Should we shrink weight matrix towards the above scaling matrix?
    related to making weight matrix more robust to imprecise cov/weight matrix estimation in small samples or with outliers.

    For newton optimization we would also need to rescale the hessian, or more generally when derivative of moment condition is used in optimization.

    Note: This does not apply when we use optimizer with loglike (minimize), only optimizers based on moment conditions or estimating equations (rootfinders or GMM).

  4. josef-pkt commented on Mar 27, 2023

    @josef-pkt
    MemberAuthor

    just parking a reference
    2-step estimators, which are exactly identified.
    We use this in treatment effect, but this is a reference for the specific case of triangular, recursive equations.

    Newey, Whitney K. “A Method of Moments Interpretation of Sequential Estimators.” Economics Letters 14, no. 2 (January 1, 1984): 201–6. https://doi.org/10.1016/0165-1765(84)90083-1.

    generic usage for IV, control function methods.

  5. josef-pkt commented on Apr 16, 2023

    @josef-pkt
    MemberAuthor

    RLM and GMM

    Maronna, Martin, ... robust book
    p 71 cov_params for M-estimator, standard sandwich, not Huber version
    for stacking moment equation for mean function and moment equation for variance function
    psi((x - mu) / sigma), rho_scale(x - mu) / sigma) - delta

    I should have something like this in one of my old PRs but not with GMM.

    exactly identified GMM would be one possible implementation for moment condition base M-estimators.
    (RLM needs score_obs and derivative of moments (fake hessian))

  6. josef-pkt commented on Aug 30, 2023

    @josef-pkt
    MemberAuthor

    recent python package: https://github.com/pzivich/Delicatessen/tree/main
    with arxiv article
    Zivich, Paul N., Mark Klose, Stephen R. Cole, Jessie K. Edwards, and Bonnie E. Shook-Sa. “Delicatessen: M-Estimation in Python.” arXiv, October 10, 2022. https://doi.org/10.48550/arXiv.2203.11300.

    looks interesting, based on brief skimming.
    There should be a large overlap with what we can do with statsmodels.

    Main differences

    • our estimating equations are implemented in models score, score_obs
      • e.g. we need Mixin class or modified methods if we want to add, for example, penalization
    • we don't have a base estimator that does not need an objective function, i.e. no generic rootfinding estimator.
      • GMM is close because it has an "artificial" objective function.
      • our own newton only uses score and hessian, not objective function
      • other fit methods in specific models that don't use objective function, e.g. irls in GLM, RLM, (quantile regression ?)

    To get started with statsmodels: a base class similar to LikelihoodModel that uses rootfinding in fit instead of optimizers.

    example case: RLM with mean and variance estimating equations that are not consistent with objective function.

  7. pzivich commented on Nov 21, 2023

    @pzivich

    Hi @josef-pkt , I was looking for some documentation on estimating equations for GMM and came across this thread. If you have any questions about delicatessen, let me know.

  8. josef-pkt commented on Nov 21, 2023

    @josef-pkt
    MemberAuthor

    @pzivich
    Thanks, I will likely have questions when I get back to this.
    I like your work. With M-estimator sandwiches this gets much closer to econometrics then the traditional literature in the related fields.
    Statsmodels does not yet have much on treatment effects with binary endpoints #8987 but it's on my high priority wishlist.

    GMM works fine but it is generic and does not take advantage of tools and computational shortcuts for the exactly identified case. (MM instead of GMM)

  9. pzivich commented on Nov 21, 2023

    @pzivich

    Thanks! GMM is one of the areas fairly out of my experience since I haven't done much with IV.

    I have a few suggestions on the treatment effects, but I'll add them to the other thread

  10. josef-pkt commented on Nov 21, 2023

    @josef-pkt
    MemberAuthor

    GMM does not need to be IV. The main point of the G is that there are more moment conditions/estimating equations than parameters. IV is a case where this applies.

    For nonlinear models like GLM with non-identity link, the linear IV pattern does not work. My target is control function or residual inclusion if there are endogenous explanatory variables which seems to be the most popular recommendation now.
    #8812 (but still without connecting it to the treatment effect literatur, Rubin, ..., Stata's etreatment)

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