# Issues with Exp decay fitting using NonlinearModelFt

I am trying to fit a data set to an exponential decay function. The fit not only looks poor visually, but also the fitting parameters have high standard errors. It seems that the fit is getting stuck at some local minima. How to avoid it (I tried different initial values of parameters, but no sucess)?

Also, is there a way to tell Mathematica to keep standard error low at thecost of quality of fit?

Will appreciate any help. Following is the data and function. Thanks

Y15 = {{0.5,29.52},{1.,27.5916},{2.,26.0074},{4.,24.5131},{6.,23.4764},{8.,23.1351},{10.,22.7308},{20.,21.8237},{40.,21.0649},{60.,20.7347},{80.,20.4707},{100.,20.2886},{200.,19.6046}};

nlm15 = NonlinearModelFit[
Y15, {a*Exp[-(2 Pi*o*t)^(n - 1)], {80 > a > 30, 1.5 > n > 1,
1 > t > 0}}, {{a, 30}, {t, 0.5}, {n, 1.1}}, o,
MaxIterations -> Infinity];

• Looking at ListLogLogPlot[Y15, Joined -> True], it seems that there are two power-law-like regimes with a transition around 5. Jul 18 at 12:38
• "Also, is there a way to tell Mathematica to keep standard error low at the cost of quality of fit?" Simply put, that sentence makes no logical sense.
– JimB
Jul 18 at 15:43

As @Domen and @DanielHuber have pointed out, a plot of your data suggests that there might be one relationship for the first half of the data and another for the second half. Although it's not clear from what you've written, I'm assuming that there is no theoretical reason for an exponential decay function but rather that you've noticed a decline that sort of looks like an exponential decay function. Here is the log-log plot of the data:

ListLogLogPlot[Y15]


One possibility is to construct a "segmented regression" where there there are two linear relationships:

f[x_, a_, b1_, b2_, c_] := Piecewise[{{a + b1 x, x <= c}, {a + c (b1 - b2) + b2 x, x > c}}]
nlm = NonlinearModelFit[Log[Y15], f[x, a, b1, b2, c], {a, b1, b2, c}, x];
nlm["ParameterTable"]


Here is a plot of the data and fit on a log-log scale:

Show[ListLogLogPlot[Y15],
LogLogPlot[Exp[nlm[Log[x]]], {x, Min[Y15[[All, 1]]], Max[Y15[[All, 1]]]}]]


Now a plot of the data and fit on the original data scale:

Show[ListPlot[Y15],
Plot[Exp[nlm[Log[z]]], {z, Min[Y15[[All, 1]]], Max[Y15[[All, 1]]]}, PlotRange -> All]]


Your data do not look like an exponential decay. It looks more like a straight line at the beginning and end, and some transition region in between.

Let's try with a linear model fit of $$x^i$$ and $$1/x^i$$:

fun = LinearModelFit[Y15, {1, x, x^2, 1/x, 1/x^2, 1/x^3, 1/x^4}, x]
Plot[fun[x], {x, 0.5, 200}, Epilog -> Point[Y15]]


You can still improve it by adding further terms: