6.7.4. statsmodels.sandbox.regression.gmm¶
Generalized Method of Moments, GMM, and Two-Stage Least Squares for instrumental variables IV2SLS
6.7.4.1. Issues¶
number of parameters, nparams, and starting values for parameters Where to put them? start was initially taken from global scope (bug)
When optimal weighting matrix cannot be calculated numerically In DistQuantilesGMM, we only have one row of moment conditions, not a moment condition for each observation, calculation for cov of moments breaks down. iter=1 works (weights is identity matrix) -> need method to do one iteration with an identity matrix or an
analytical weighting matrix given as parameter.
- -> add result statistics for this case, e.g. cov_params, I have it in the
standalone function (and in calc_covparams which is a copy of it), but not tested yet.
- DONE fitonce in DistQuantilesGMM, params are the same as in direct call to fitgmm
move it to GMM class (once it’s clearer for which cases I need this.)
GMM doesn’t know anything about the underlying model, e.g. y = X beta + u or panel data model. It would be good if we can reuse methods from regressions, e.g. predict, fitted values, calculating the error term, and some result statistics. What’s the best way to do this, multiple inheritance, outsourcing the functions, mixins or delegation (a model creates a GMM instance just for estimation).
6.7.4.2. Unclear¶
dof in Hausman - based on rank - differs between IV2SLS method and function used with GMM or (IV2SLS) - with GMM, covariance matrix difference has negative eigenvalues in iv example, ???
jtest/jval - I’m not sure about the normalization (multiply or divide by nobs) in jtest.
need a test case. Scaling of jval is irrelevant for estimation. jval in jtest looks to large in example, but I have no idea about the size
- bse for fitonce look too large (no time for checking now)
formula for calc_cov_params for the case without optimal weighting matrix is wrong. I don’t have an estimate for omega in that case. And I’m confusing between weights and omega, which are not the same in this case.
Author: josef-pktd License: BSD (3-clause)
6.7.4.3. Functions¶
approx_fprime (x, f[, epsilon, args, kwargs, ...]) |
Gradient of function, or Jacobian if function f returns 1d array |
approx_hess (x, f[, epsilon, args, kwargs]) |
Calculate Hessian with finite difference derivative approximation |
maxabs (x) |
just a shortcut to np.abs(x).max() |
spec_hausman (params_e, params_i, ...[, dof]) |
Hausmans specification test |
6.7.4.4. Classes¶
DistQuantilesGMM (endog, exog, instrument, **kwds) |
Estimate distribution parameters by GMM based on matching quantiles |
GMM (endog, exog, instrument[, k_moms, ...]) |
Class for estimation by Generalized Method of Moments |
GMMResults (*args, **kwds) |
just a storage class right now |
IV2SLS (endog, exog[, instrument]) |
Class for instrumental variables estimation using Two-Stage Least-Squares |
IVGMM (endog, exog, instrument[, k_moms, ...]) |
Basic class for instrumental variables estimation using GMM |
IVGMMResults (*args, **kwds) |
|
IVRegressionResults (model, params[, ...]) |
Results class for for an OLS model. |
LikelihoodModel (endog[, exog]) |
Likelihood model is a subclass of Model. |
LikelihoodModelResults (model, params[, ...]) |
Class to contain results from likelihood models |
LinearIVGMM (endog, exog, instrument[, ...]) |
class for linear instrumental variables models estimated with GMM |
Model (endog[, exog]) |
A (predictive) statistical model. |
NonlinearIVGMM (endog, exog, instrument, ...) |
Class for non-linear instrumental variables estimation wusing GMM |
OLS (endog[, exog, missing, hasconst]) |
A simple ordinary least squares model. |
RegressionResults (model, params[, ...]) |
This class summarizes the fit of a linear regression model. |
RegressionResultsWrapper (results) |
|
resettable_cache |
alias of ResettableCache |