You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ENH: sandwich cov_type code without symmetry of hessian #8789
I never checked whether the generic sandwich code (based on score_obs/momcond and hessian/momcond_deriv is correct for asymmetric hessians.
Do we use the correct transposition of the (inverse) hessian?
I guess there are no unit test for that.
We get asymmetric "hessian" in GMM, conditional moment tests, GEE, RLM , ..., if those are based on moment conditions that do not come from a single objective function (like loglike).
e.g. M-estimator that start with moment conditions and not we a single objective function. (nonlinear robust model with separately specified moment condition for variance)
Also two-stage models have asymmetric derivatives of score_obs, Murphy/Topel and general versions of it (*)
Current GMM does not yet reuse the generic cov_type code.
Current conditional moment tests (CMT) also don't use generic cov_type code.
score_test uses cov_params and symmetric hessian based on the unrestricted loglikelihood but the cov of the null hypothesis restrictions is based on the CMT code.
(*)
Zero-inflated models are not two-stage model, there is one loglikelihood function for both components.
Hurdle model is currently implemented with two separate models, but parameters are independent across submodels, hessian and cov(score) are block-diagonal.
code looks correct, just needs checking that there are unit tests statsmodels\stats\tests\test_sandwich.py (which does not have many unit test) does not fail when I remove the transpose. All (or almost all) applications including their unit tests will be for symmetric hessian.
all sandwiches are computed using _HCCM2 which has the correct transpose
def _HCCM2(hessian_inv, scale):
if scale.ndim == 1:
scale = scale[:,None]
xxi = hessian_inv
H = np.dot(np.dot(xxi, scale), xxi.T)
return H
Activity
josef-pkt commentedon Apr 12, 2023
code looks correct, just needs checking that there are unit tests
statsmodels\stats\tests\test_sandwich.py(which does not have many unit test) does not fail when I remove the transpose. All (or almost all) applications including their unit tests will be for symmetric hessian.all sandwiches are computed using
_HCCM2which has the correct transpose