Skip to content

Commit

Permalink
Add argument to _LM.lm.
Browse files Browse the repository at this point in the history
  • Loading branch information
mlondschien committed Jul 22, 2024
1 parent 94b8f8d commit 2a64fa5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ivmodels/tests/lagrange_multiplier.py
Original file line number Diff line number Diff line change
Expand Up @@ -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``.
Expand Down Expand Up @@ -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

Check warning on line 291 in ivmodels/tests/lagrange_multiplier.py

View check run for this annotation

Codecov / codecov/patch

ivmodels/tests/lagrange_multiplier.py#L291

Added line #L291 was not covered by tests
else:
return res.fun


def lagrange_multiplier_test(
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 2a64fa5

Please sign in to comment.