1
$\begingroup$

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.

$\endgroup$
1
  • 1
    $\begingroup$ NonlinearModelFit[] can handle weighted nonlinear least squares. $\endgroup$ Commented Oct 31, 2015 at 14:04

1 Answer 1

4
$\begingroup$

Fit works using singular value decomposition. FindFit uses the same method for the linear least-squares case, the Levenberg–Marquardt method for nonlinear least-squares, and general FindMinimum methods for other norms.

- source

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}
$\endgroup$
3
  • $\begingroup$ How do I get the list parameters from NonlinearModel? FindFit outputs such a thing $\endgroup$ Commented Oct 31, 2015 at 16:56
  • $\begingroup$ @minusatwelfth see my edit. $\endgroup$
    – paw
    Commented Oct 31, 2015 at 17:12
  • $\begingroup$ @minus, it's all in the docs, if you'd look for them. $\endgroup$ Commented Nov 1, 2015 at 2:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.