Does anyone know how to program a mathematica algorithm that does the same thing that FindFit does? Is there documentation of it somewhere? I assume it is a least squares algorithm but with very generalized arguments. I ask because I'm trying to use 'weighted' least squares and it basically involves just one more factor.
$\begingroup$
$\endgroup$
1
1 Answer
$\begingroup$
$\endgroup$
3
Fitworks using singular value decomposition.FindFituses the same method for the linear least-squares case, the Levenberg–Marquardt method for nonlinear least-squares, and generalFindMinimummethods for other norms.
NonlinearModelFit allows fitting of weighted data, as J.M. commented
Edit:
The best fit parameters are a property of the model:
p = Table[Prime[x], {x, 20}];
nlm = NonlinearModelFit[p, a x Log[b + c x], {a, b, c}, x];
nlm["BestFitParameters"]
{a -> 1.42076, b -> 1.65558, c -> 0.534645}
-
$\begingroup$ How do I get the list parameters from NonlinearModel? FindFit outputs such a thing $\endgroup$minusatwelfth– minusatwelfth2015-10-31 16:56:58 +00:00Commented Oct 31, 2015 at 16:56
-
$\begingroup$ @minusatwelfth see my edit. $\endgroup$paw– paw2015-10-31 17:12:32 +00:00Commented Oct 31, 2015 at 17:12
-
$\begingroup$ @minus, it's all in the docs, if you'd look for them. $\endgroup$J. M.'s missing motivation– J. M.'s missing motivation2015-11-01 02:04:21 +00:00Commented Nov 1, 2015 at 2:04
NonlinearModelFit[]can handle weighted nonlinear least squares. $\endgroup$