# Test Goodness of fit for FindFit

Is there any way to get an estimate of the goodness of fit from FindFit, for instance getting the final error? The documentation doesn't provide any hints, and a quick Google search didn't return any useful link either. Am I missing something obvious?

• A discussion of quantifying the quality of fits, including the error residuals, appears here: tutorial/StatisticalModelAnalysis. – David G. Stork Dec 9 '14 at 17:15

## 1 Answer

You can use NonlinearModelFit instead of FindFit.

dt = Table[Prime[x], {x, 20}];
FindFit[dt, a x Log[b + c x], {a, b, c}, x]
(* {a -> 1.42076, b -> 1.65558, c -> 0.534645} *)

nlm = NonlinearModelFit[dt, a x Log[b + c x], {a, b, c}, x];
Normal[nlm]
(* 1.42076 x Log[1.65558+0.534645 x]*)

nlm["ParameterTable"]


Grid[Transpose[{#, nlm[#]} &[{"AdjustedRSquared", "AIC", "BIC", "RSquared"}]], Alignment -> Left]


• Two tiny questions if I may: -1- I am using nlm["ParameterTable"] as well after a nonlinearModelFit, but I get a warning that "The property values {"ParameterTable"} assume an unconstrained model..." probably because I added a constraint while fitting, has this happened to you as well? -2- Is there a built-in way of also estimating the chi-squared per degree of freedom for the fit? Many thanks in advance. – user929304 Jun 17 at 10:53
• You can use NMinimize` function for fitting. Just minimize chi-square_nu over the parameter space to find your parameters. – OkkesDulgerci Aug 29 at 4:38