Skip to content
Closed
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
16 changes: 16 additions & 0 deletions pyomo/contrib/parmest/parmest.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,11 @@ def compute_covariance_matrix(
cov = np.linalg.pinv(FIM)
logger.warning("The FIM is singular. Using pseudo-inverse instead.")

# check if the covariance matrix is positive semi-definite
eigen_values = np.linalg.eigvalsh(cov)
if any(eig_val < -1e-10 for eig_val in eigen_values):
logger.warning("The covariance matrix is not positive semi-definite.")

cov = pd.DataFrame(cov, index=theta_vals.keys(), columns=theta_vals.keys())

return cov
Expand Down Expand Up @@ -1479,6 +1484,17 @@ def _cov_at_theta(self, method, solver, step):
solver=solver,
tee=self.tee,
)
else:
raise ValueError(
'One or more values are missing from "measurement_error". All values of '
'the measurement errors are required for the "SSE_weighted" objective.'
)
else:
raise AttributeError(
'Experiment model does not have suffix "measurement_error". '
'"measurement_error" is a required suffix for the "SSE_weighted" '
'objective.'
)
else:
raise ValueError(
f"Invalid objective function for covariance calculation. "
Expand Down
Loading