1
$\begingroup$

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];
$\endgroup$
2
  • $\begingroup$ Looking at ListLogLogPlot[Y15, Joined -> True], it seems that there are two power-law-like regimes with a transition around 5. $\endgroup$
    – Domen
    Jul 18 at 12:38
  • $\begingroup$ "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. $\endgroup$
    – JimB
    Jul 18 at 15:43

2 Answers 2

4
$\begingroup$

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]

Log-log plot of data

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"]

Parameter table

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]]]}]]

Data and segmented regression fit on log-log scale

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]]

Data and segmented regression fit on original scale

$\endgroup$
2
$\begingroup$

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]]

enter image description here

You can still improve it by adding further terms:

$\endgroup$

Your Answer

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

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