diff --git a/ivmodels/tests/lagrange_multiplier.py b/ivmodels/tests/lagrange_multiplier.py index 8a4b780..161e765 100644 --- a/ivmodels/tests/lagrange_multiplier.py +++ b/ivmodels/tests/lagrange_multiplier.py @@ -237,7 +237,7 @@ def derivative(self, beta, gamma=None, jac=True, hess=True): return (self.dof * lm.item(), self.dof * d_lm.flatten(), self.dof * dd_lm) - def lm(self, beta): + def lm(self, beta, return_minimizer=False): """ Compute the Lagrange multiplier test statistic at ``beta``. @@ -287,7 +287,10 @@ def _derivative(gamma): res = min(results, key=lambda r: r.fun) - return res.fun + if return_minimizer: + return res.fun, res.x + else: + return res.fun def lagrange_multiplier_test( @@ -459,6 +462,7 @@ def inverse_lagrange_multiplier_test( lm = _LM(X=np.hstack([X, D]), W=W, y=y, Z=np.hstack([Z, D]), dof=dof) critical_value = scipy.stats.chi2(df=mx + md).ppf(1 - alpha) + if md == 0: liml = lm.liml()[0] else: