# Programmatically check fit success

**URL:** <https://root-forum.cern.ch/t/programmatically-check-fit-success/54861>\
**Category:** Roofit and RooStats\
**Tags:** bug\
**Created:** [May 15, 2023, 7:10pm UTC](https://root-forum.cern.ch/t/programmatically-check-fit-success/54861 "2023-05-15T19:10:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mwilkins](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/mwilkins/32/28332_2.png) [@mwilkins](https://root-forum.cern.ch/u/mwilkins)\
**Post date:** [May 15, 2023, 7:10pm UTC](https://root-forum.cern.ch/t/programmatically-check-fit-success/54861/1 "2023-05-15T19:10:47Z")

</div>

What is the recommended way to ensure that a fit was successful? That is, I want to ensure it converged and its error matrix is positive-definite. Details below.

* * *

`RooFitResult::status` returns the MINUIT status code, but there is a bug that means I am getting status=0 even if the covariance matrix was forced positive-definite. (See below)

`RooFitResult::covQual` seems like a possible workaround, but I cannot find documentation for the codes (apparently a [common problem](https://root-forum.cern.ch/t/what-does-means-the-roofitresult-covqual-codes/18063)).

I can extract the error matrix using `RooFitResult::covarianceMatrix` or `correlationMatrix`, but I haven’t found a built-in method to determine whether it’s positive definite, much less whether it was _forced_ positive definite.

* * *

Regarding the above bug in `RooFitResult::status`, I have fit results where `RooFitResult::status()==0` and `RooFit::Print` says that the covariance matrix was forced positive-definite. An [old forum answer](https://root-forum.cern.ch/t/meaning-of-values-returned-by-roofitresult-status/16355/2) says that this should not happen, that the status _should_ be 1 in this case, so this seems to be a bug. That said, the codes are [not well documented](https://root-forum.cern.ch/t/where-do-i-find-a-list-of-what-all-the-roofitresult-status-codes-mean/54445), so perhaps I’ve missed something.

---

<div class="post-metadata">

**Author:** ![vpadulan](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/vpadulan/32/25315_2.png) [@vpadulan](https://root-forum.cern.ch/u/vpadulan)\
**Post date:** [May 16, 2023, 8:15am UTC](https://root-forum.cern.ch/t/programmatically-check-fit-success/54861/2 "2023-05-16T08:15:23Z")

</div>

Dear @mwilkins ,

Thanks for reaching out to us! I will let @jonas or @moneta help you on this one.

Cheers,  
Vincenzo

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [May 30, 2023, 8:15am UTC](https://root-forum.cern.ch/t/programmatically-check-fit-success/54861/3 "2023-05-30T08:15:54Z")

</div>

Closed on May 30, 2023, 8:15am UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [June 1, 2023, 4:39pm UTC](https://root-forum.cern.ch/t/programmatically-check-fit-success/54861/4 "2023-06-01T16:39:45Z")

</div>

Hi,

When the `status=0` it means the covariance matrix is fine and it was not made pos defined. It is possible that during the minimization a temporary covariance matrix (note at the minimum) was made pos def. If this is not the case, I would like to look at this in more detailed, looking for example at the full log of the minimization or having an example reproducing this problem.  
For the meaning of `covQual` see [here](https://root.cern.ch/doc/master/Minuit2Minimizer_8cxx_source.html#l01280) (if using Minuit2).

Lorenzo

---

<div class="post-metadata">

**Author:** ![jonas](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jonas/32/24756_2.png) [@jonas](https://root-forum.cern.ch/u/jonas)\
**Post date:** [June 1, 2023, 5:08pm UTC](https://root-forum.cern.ch/t/programmatically-check-fit-success/54861/5 "2023-06-01T17:08:23Z")

</div>

Opened on June 1, 2023, 5:08pm UTC


