Group Abstract Group Abstract

Message Boards Message Boards

0
|
5.7K Views
|
4 Replies
|
2 Total Likes
View groups...
Share
Share this post:

[?] Understanding fitting with NonlinearModelFit

POSTED BY: winston carr
4 Replies
Posted 6 years ago
POSTED BY: Jim Baldwin

Thanks Jim, I realize it was over parameterized, but I was just playing with the fitting functions for practice before working on a real fitting problem.

I don't understand you comment about the error function, are you referring to my "test data" I made up? Again, I was just trying to understand the syntax and workings of the function, the actual data and fitting here was just a quick example choice.

POSTED BY: winston carr
Posted 6 years ago

I understand that this was test data. I just wanted to point out that typically one chooses an error with a mean of zero. Using RandomReal[{-0.5,0.5}] would accomplish this. (Otherwise, the random component also includes a fixed component that probably is best incorporated in the fixed part of the model. Not required but I think easier to interpret.

Overparameterized models do have problems with convergence (even if the predictions are just fine) so examples without overparameterized models don't have that issue confounding the other issues with model fit.

POSTED BY: Jim Baldwin

Workaround:

 ClearAll["`*"]
 randomNums = Table[{x, Sqrt[5^2 - x^2] + Random[]}, {x, -5, 5, 0.5}];
 nlm = NonlinearModelFit[randomNums, a Re[Sqrt[b r^2 - c x^2]] + d, {a, b, c, d, r}, x] // Quiet
 Show[{ListPlot[randomNums, PlotStyle -> Black], Plot[(nlm // Normal), {x, -5, 5}, PlotStyle -> Red]}]

enter image description here

For more information see: here, here and here.

POSTED BY: Mariusz Iwaniuk
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard