# NonlinearModelFit errors

I have read through other forum posts and have seen a few things that I thought would help but I am still having issues. I'm trying to fit some calibration data and am at first getting the error shown on the attached picture.

I saw in a forum post that putting constraints on the fit function can help, so I tried restricting the value for "t" as shown in the second picture but I am not getting a fit. Anything else I do to try to constrain the fit does not help.

Any help would be greatly appreciated! Thanks.

There is a missing value for 9000 which is problematic. Further, rescaling helps to deal with overflow errors.

data = {{0, 33.5}, {1000, 33.5}, {2000, 33}, {3000, 30.8}, {4000,
27}, {5000, 22.4}, {6000, 17}, {7000, 12.8}, {8000, 8.8}, {10000,
5.45}, {11000, 4.5}, {12000, 3.7}, {13000, 3}, {14000,
2.5}, {15000, 2.05}, {16000, 1.7}, {17000, 1.4}, {18000,
1.15}, {19000, 0.88}, {20000, 0.72}, {21000, 0.6}, {22000,
0.49}, {23000, 0.42}};
nlm = NonlinearModelFit[{#1/1000, #2} & @@@ data,
a Exp [- b t^2], {{a, 33}, {b, 0.01}}, t]


Visualizing:

lab = Normal[nlm] /. t -> x/1000
Plot[nlm[x], {x, 0, 20}, PlotLabel -> lab,
Epilog -> {Point[{#1/1000, #2} & @@@ data]}, Frame -> True,
FrameTicks -> {Table[{j, 1000 j}, {j, 5, 20, 5}], Automatic}]


Note I typed values of data so may have errors but approach I hope is instructive.

• Thank you so much. I didn't realize it would be a problem having a missing value. I appreciate the input! Mar 25 '15 at 6:18

The message should be your first hint. Nonetheless:

ListLinePlot[data]


See anything strange? The data at point 9000 is incomplete.

Let's interpolate for a test:

interp = Interpolation[data[[Drop[Range@24, {10}]]], 9000];
data[[10]] = {9000, %};

model=NonlinearModelFit[data, a1 Exp[-t^2/t1], {a1, t1}, t]


• unfortunately the fitted model 33.5 $e^(-t^2}$ does not really fit the data as by t much less than 5000 it would by "vanishingly" small...some rescaling and starting values needed Mar 20 '15 at 5:51
• @ubpdqn: Yes, I was not interested in the correctness of the model, just answering the why of the error...
– ciao
Mar 20 '15 at 5:54
• point taken...instructive but leaving room for independent learning...hope you are well:) Mar 20 '15 at 5:57
• @ubpdqn: Yep - If you look at edits, I actually edited out the "this is a terrible model..." - figured OP would benefit from finding that out and experimenting. Thanks for well wishes - smoking a cigar and playing with math - what's not to like ;-)
– ciao
Mar 20 '15 at 6:03