# Improving the NonlinearModelFit

I've been trying to fit logarithmic function to the data below:

d1 = {{3457, 4.22}, {3000, 4.33}, {2500, 4.35}, {1200, 4.43}, {600, 4.68}, {300, 5.8}, {150, 8.07}}


I used the following code for the fitting:

nmf1 = NonlinearModelFit[d1, a + b Log[x], {a, b}, x]

g1 = ListPlot[d1];
g2 = Plot[nmf1[x], {x, 0, 3500}];
Show[g1,g2]


where g1 is the $$ListPlot$$ of the data d1. I got the below fit. I am wondering how to improve this fit. The expected function is the natural logarithm, although in this case I managed to do a much better fit with the 1/x. Additionally, I don't have an initial guess at the parameters, which I could use. Any ideas?

Thank you all for help!

• Just an observation: your parameter c is redundant. – b.gates.you.know.what Jan 30 '19 at 8:47
• Right. Thanks for pointing this out. – Nejc Kejzar Jan 30 '19 at 8:48

Why do you expect a logarithmic function?

Rational approximation gives a quite good fit:

nmf1 = NonlinearModelFit[d1, (a + b x)/(1 + c x), {a, b, c}, x,Method -> "NMinimize"];
Show[{ListPlot[d1],Plot[Normal[nmf1], {x, 150, 3500}, PlotRange -> All]}]
` • Ah, I just realized that my model was incorrect. I expected the logarithm, but for the inverse values of y. Still, your solution was and will be helpful in my analysis. May I ask - is the NMinimize the method of least-squares or something else? – Nejc Kejzar Jan 30 '19 at 10:44
• Usually I use "NMinimize" as a robust solver if I don't no initial parameter values. Don't no which method is used. – Ulrich Neumann Jan 30 '19 at 10:47
• Alright, will look into documentation. Thank you for your help! – Nejc Kejzar Jan 30 '19 at 10:48
• You're welcome! – Ulrich Neumann Jan 30 '19 at 11:11