Skip to content

Commit

Permalink
added identity weighting matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
sidd3888 committed Feb 7, 2024
1 parent b77deb8 commit 6e57bbb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/estimagic/estimation/estimate_msm.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def estimate_msm(
# Check and process inputs
# ==================================================================================

if weights not in ["diagonal", "optimal"]:
if weights not in ["diagonal", "optimal", "identity"]:
raise NotImplementedError("Custom weighting matrices are not yet implemented.")

is_optimized = optimize_options is False
Expand Down
4 changes: 3 additions & 1 deletion src/estimagic/estimation/msm_weighting.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def get_weighting_matrix(
Args:
moments_cov (pandas.DataFrame or numpy.ndarray): Square DataFrame or Array
with the covariance matrix of the moment conditions for msm estimation.
method (str): One of "optimal", "diagonal".
method (str): One of "optimal", "diagonal", or "identity".
empirical_moments (pytree): Pytree containing empirical moments. Used to get
the tree structure
clip_value (float): Bound at which diagonal elements of the moments_cov are
Expand Down Expand Up @@ -106,6 +106,8 @@ def get_weighting_matrix(
elif method == "diagonal":
diagonal_values = 1 / np.clip(np.diagonal(_internal_cov), clip_value, np.inf)
array_weights = np.diag(diagonal_values)
elif method == "identity":
array_weights = np.identity(_internal_cov.shape[0])

Check warning on line 110 in src/estimagic/estimation/msm_weighting.py

View check run for this annotation

Codecov / codecov/patch

src/estimagic/estimation/msm_weighting.py#L109-L110

Added lines #L109 - L110 were not covered by tests
else:
raise ValueError(f"Invalid method: {method}")

Expand Down

0 comments on commit 6e57bbb

Please sign in to comment.