**Overview:**

**How can I check to see a Nonlinear fit succeeded?**

(Real-data doesn't always converge and may need manual review for automation/test/product issues.)

**Detail:**

I would like to script a response after a nonlinear fit fails to converge. If the fit fails, I need to process another way, and/or eventually label for manual review. (I'm sampling a population, then for each part, doing a non-linear fit. Generally if I fail convergence, there was a test issue somewhere; I don't actually want to loosen the convergence criteria.)

('Failed' message: "Failed: Cannot Decrease Objective Function")

Modified script from Numeric Derivatives Only (Help > Scripting Index > "<<Nonlinear")

(Currently running JMP 15.2.1)

```
Names Default To Here( 1 );
dt = Open(
"$SAMPLE_DATA/Nonlinear Examples/US Population.jmp"
);
// Random, intentionally divergent, formula on this dataset
dt << New Column( "Random", Numeric, Formula( Random LogLogistic(5) ) );
dt << New Column( "FancyPredictionFormula",
Numeric,
Continuous,
Formula(
Parameter(
{Rth0 = 735, n = 0.5},
(:year / :pop) * ((1 - ((n - 1) * :pop * Rth0) / (:year
* (300 / :year) ^ n)) ^ (-1 / (n - 1)) - 1)
)
)
);
nonlinear = dt << Nonlinear(
Y( :Name( "Random" ) ),
X( :Name("FancyPredictionFormula") ),
Expand Intermediate Formulas( 1 ),
Numeric Derivatives Only( 1 ),
QuasiNewton SR1,
Interation Limit(50),
Finish,
Plot( 0 ),
Confidence Limits,
Save Estimates
);
// How to check if nonlinear fit succeeded?
```

__Ideal.__

If there is a bool status variable returned by the Nonlinear fit platform somewhere indicating success or failure, that would be the ideal method to verify success, I think.

__Alternative 1.__

I can also tabulate or take a summary of the data to see if all the :Name("FancyPredictionFormula") values are zero. (Values seem to be 0 if the fit fails).

__Alternative 2. __

There's probably a way to check the XML and read the 'failed' message.

Thank you for your time and consideration.

-Aubrey