Skip to content

GMM fixes and improvements #1096

Open
Open

Description

@josef-pkt

(some notes to figure out where GMM was left off)

bold and after; update 2015-10-04

required changes:

  • fmin method="nm" is not working well enough, bfgs works well DONE bfgs doesn't for plain gamma distribution
  • code and arguments of methods are inconsistent in use of weights or inverse weights ???* DONE but needs another check
  • fit is pretty useless without options (e.g. maxiter), DONE fit has been refactored to be main access point
    drop it and use fititer as main method? (fititer doesn't return results instance)
  • calc_weightmatrix is missing kernels, and degrees of freedom or small sample corrections (HCi, HAC)
    connect S matrix calculation from stats.sandwich_covariance TODO

IVGMM with start_weight = Z' Z (instrument Z) DONE

  • 1 iteration: same as IV2SLS (except currently nonlinear optimization)
  • = 2 iterations: should be IV2SLS with nonparametric heteroscedasticity

  • option to avoid sandwich cov_params ?
    (i.e. assume start_weight is correctly specified optimal weights)
  • use explicit linear solution in linear regression model

CondGMM TODO? no optimal instruments code

GMM with conditional moment restrictions, similar to IVGMM, but with additional methods to help construct optimal instruments or approximations to them.
(not yet started)

Comparison to Stata Mostly DONE #1105 added test suite against Stata

Since there are so many options it is difficult to figure out how to match reference numbers with Stata.
In some cases, I can match Stata to many digits, in other cases the results are just in the same neighborhood.

  • Stata doesn't center moments by default. I do, following the recommendation in Bruce Hansen's textbook
    (without centering I can match the params of Stata with HAC weights, but not the standard errors.
    Still another option with a different defaults?
  • Optimal weights or not. According to the Stata manual the cov_params is always estimated under the assumption
    of non-optimal weights (W != S^{-1}). My default is to assume has_optimal_weights=True and use S reestimated after the final iteration.

Activity

  1. josef-pkt commented on Oct 7, 2013

    @josef-pkt
    MemberAuthor

    possible bug: has_optimal_weights=False calculation shouldn't have an linalg.inv at the end.
    need a test case

  2. josef-pkt commented on Oct 10, 2013

    @josef-pkt
    MemberAuthor

    Comparison with Stata defaults for gmm twostep wmat(hac nw 4)

    centered = False

    >>> reshac4b = mod.fit([1, -1], maxiter=2, inv_weights=w0inv, weights_method='hac', wargs={'maxlag':4, 'centered':False}, opt_args={'disp':False})
    using HAC
    using HAC
    
    >>> print reshac4b.params; params_st_default
    [ 0.92045265 -4.22337206]
    [0.9204606, -4.222485]
    >>> print reshac4b.bse; bse_st_default    # not the same
    [ 0.01272177  1.49138662]
    [0.0134646, 1.473903]
    

    assume non-optimal weights, has_optimal_weights=False

    >>> bse_no = np.sqrt(np.diag(reshac4b.cov_params(has_optimal_weights=False, method='hac', wargs={'maxlag':4, 'centered':False})))
    using HAC
    >>> print bse_no; bse_st_default
    [ 0.01346497  1.47396493]
    [0.0134646, 1.473903]
    

    looks close enough given numerical optimization and numerical derivatives

  3. josef-pkt commented on Oct 4, 2015

    @josef-pkt
    MemberAuthor

    Most of the things in the description are outdated, PR #1105 added many fixes, cleanup and enhancements.

    One more round of work is necessary to get it out of sandbox.

    What is left of the issues raised in the description here?

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

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions