5
$\begingroup$

What methods are there to fit a model of the form $y=A\mathrm e^{Bx}+C\mathrm e^{Dx}+E$?

Here is the actual scientific data to be fitted: http://dl.dropbox.com/u/39499990/Ben%2C%20real%20data.xlsx

B should be in the range of -1 to -100.

D should be in the range of -100 to -500.

E is a constant.

This specific model is of interest as it is an accepted one in the scientific community for describing the biological proccess in hand- Inactivation of a voltage dependent calcium channel. (for reference see for example: A novel molecular inactivation determinant of voltage-gated CaV1.2 L-type Ca2+ channel. A Livneh, R Cohen, and D Atlas; Neuroscience, Jan 2006; 139(4): 1275-87. " The rate of inactivation was analyzed by a biexponential decay -A1exp(-t/Tao1)-A2exp(-t/Tao2)+C " )

Best would be a solution that I could implement in Excel, by the use of build-in functions or VBA code.

$\endgroup$
6
  • $\begingroup$ Presumably the last "$e$" does not mean the same thing as the first two "$e$"s! Some more information about the data and your expectations about $B$ and $D$ would help, because in general fitting functions like this can be tricky. For an example (with a related function) please read the replies at stats.stackexchange.com/questions/7308. $\endgroup$
    – whuber
    Commented May 19, 2012 at 22:20
  • $\begingroup$ I'm working with Michael Litvin on this issue. Here is the actual scientific data to be fitted: dl.dropbox.com/u/39499990/Ben%2C%20real%20data.xlsx B should be in the range of 1-100. D should be in the range of 100-500. E is a contant, not e. $\endgroup$
    – Ben
    Commented May 21, 2012 at 20:25
  • $\begingroup$ One would expect both $B$ and $D$ to be negative, @Ben, given that the data appear to have a negative second derivative. The sum of exponentials looks like it will be a poor fit. Could you disclose the reasons why this form of function is expected? Could you explain the nature of $x$ and $y$ so we can understand what functional forms would be likely and what kinds of errors to expect? $\endgroup$
    – whuber
    Commented May 21, 2012 at 21:20
  • $\begingroup$ The plot looks much more like a rational function than anything involving exponentials. E.g., try $y = -52.5245 - 6.05282/(x - 0.364724)$. (This is not the best possible: the residuals have interesting structure.) $\endgroup$
    – whuber
    Commented May 21, 2012 at 21:44
  • $\begingroup$ @whuber you're right, $B$ and $D$ should be negative. Edited the question. $\endgroup$ Commented May 22, 2012 at 17:51

3 Answers 3

3
$\begingroup$

Best is not a solution in Excel -- spreadsheets are not a good environment for data analysis: http://www.burns-stat.com/pages/Tutor/spreadsheet_addiction.html

The 'nls' function in R would be one choice.

$\endgroup$
0
3
$\begingroup$

I'll show you how to analyze your data with Mathematica. First I'll use your model as requested.

data = Import["Desktop/data.csv"];
y = NonlinearModelFit[data, 
  a Exp[b x] + c Exp[d x] + e, {a, b, c, d, e}, x];

Mathematica returns this error:

NonlinearModelFit::cvmit: Failed to converge to the requested accuracy or precision within 1000 iterations

This means that your model might not be ideal. Let's consider the data to see if we can come up with a better one. The log-plot of the negative of your series (so we can take the logarithm) shows a fairly polynomial curve:

Log-plot of raw data

(Generated using ListLogPlot[# {1, -1} & /@ data])

This suggests that instead of an exponential mixture, we should use a log-linear model:

$ \hat y = -\exp(a+bx+cx^2 + \dots)$

Let's try a cubic polynomial:

nlm = LinearModelFit[{#[[1]], Log[-#[[2]]]} & /@ data, {x, x^2, x^3}, x]

Mathematica returns 71.6838 - 391.293 x + 764.791 x^2 - 501.198 x^3

In other words,

$ \hat y = -\exp(71.6838 - 391.293 x + 764.791 x^2 - 501.198 x^3)$.

Here is a plot of the data, the mixture model (red), and the log-linear model (green):

Final result

(Generated using Show[{ListPlot@data, Plot[y[x], {x, 0.38, 0.57}, PlotStyle -> {Thick, Red}], Plot[-Exp@nlm@x, {x, .35, 0.6}, PlotStyle -> {Thick, Green}]}])

You can get an ever better fit with a quartic polynomial, but you get the idea. The residuals show structure, which means that the model has not squeezed all the information out of the data:

Residual of cubic polynomial

(Generated using ListPlot@nlm["FitResiduals"])

Fortunately, the order virtually disappears by the time you raise the order to six:

Residual of hexic polynomial

$\endgroup$
3
  • $\begingroup$ Nice--but you are working too hard. See new.nutonian.com/download. Use it to explore reasonable fits, then analyze them in greater detail with Mathematica. Incidentally, Mathematica can converge to a modest fit with the double-exponential formula: you need to supply better starting values, that's all. $\endgroup$
    – whuber
    Commented May 21, 2012 at 22:10
  • $\begingroup$ @whuber: Thanks for the software suggestion. I got the double exponential to fit all right (you can see it in the plot), but the fit was not good enough in my opinion so I sought a better model. Did you find a better fit with the mixture model? $\endgroup$
    – Emre
    Commented May 21, 2012 at 22:17
  • $\begingroup$ I found a good five-parameter fit as a rational function of $\exp(x)$ and $\exp(2 x)$. It suggests the second and third data points (from the left) are outliers (there's a hint of that in your last plot) and it slightly overestimates values for larger $x$. A case could be made for finding one fit for the most negative values of $y$ (less than $-300$, say) and another for the rest, but its merit depends on the scientific purposes of the fitting exercise, of which we unfortunately still remain ignorant. $\endgroup$
    – whuber
    Commented May 22, 2012 at 14:24
1
$\begingroup$

Are you looking for methods or software to implement it? It looks like a typical nonlinear regression problem. In SAS this is implemented using proc nlin.

$\endgroup$
1
  • $\begingroup$ Method is interesting, but currently software implementation is more crucial. $\endgroup$ Commented May 20, 2012 at 7:21

Your Answer

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

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