Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions statsmodels/base/_parameter_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from scipy import stats


# this is a copy from stats._diagnostic_other
# this is a copy from stats._diagnostic_other to avoid circular imports
def _lm_robust(score, constraint_matrix, score_deriv_inv, cov_score,
cov_params=None):
'''general formula for score/LM test
Expand Down Expand Up @@ -216,7 +216,11 @@ def score_test(self, exog_extra=None, params_constrained=None,
score = score_obs.sum(0)
hessian_factor = model.hessian_factor(params_constrained,
**hess_kwd)
hessian = -np.dot(ex.T * hessian_factor, ex)
# see #4714
from statsmodels.genmod.generalized_linear_model import GLM
if isinstance(model, GLM):
hessian_factor *= -1
hessian = np.dot(ex.T * hessian_factor, ex)

if cov_type == 'nonrobust':
cov_score_test = -hessian
Expand All @@ -241,7 +245,8 @@ def score_test(self, exog_extra=None, params_constrained=None,
pval = stats.chi2.sf(chi2stat, k_constraints)
return chi2stat, pval
else:
raise NotImplementedError('only cov_type "nonrobust" is available')
msg = 'Only cov_type "nonrobust" and "HC0" are available.'
raise NotImplementedError(msg)

if hypothesis == 'joint':
chi2stat = score.dot(np.linalg.solve(cov_score_test, score[:, None]))
Expand Down
Loading