I was trying to fit a set of data onto a logistic equation, however it ended up telling me that the initial value when $t=0$ is greater than the maximum limit, thus I am led to believe that it isn't working.

My approach:

Here are the data points with the top row being day and the second row being height (cm)


I put them into mathematica by the following:


I need to fit this data into this equation

$\frac{C}{1+\frac{C-N_0}{N_0}e^{-rt}}$, where $C$ is defined as the maximum possible height, $N_0$ is the height when $t=0$, $r$ is some constant, $e$ is Euler's Constant and $t$ is time

Since $C$ and $N$ are already used by mathematica, i used $c$ and $n$


The output was:

{c->163.363, n->653566, r->236.408}

What have I done wrong to get these values? Also I am positive I have the correct equation as this is what the assignment tells us is the equation and all the other questions work. (Although they are a different style and we are given $N_0$ and $C$ in those ones)

My expected output for $C$ and $N_0$ I believe is around

{c->256, n->9}

However I am unsure about $r$ but believe it to be under $1$ and positive


This is quite common a problem when doing nonlinear fit. As far as I know, the most general and effective solution for it is to give the fitted parameters a good enough start value, which you've already known for your specific problem:

exp = c/(1 + ((c - n)/n)*E^(-r*t));
FindFit[points, exp, {{c, 256}, {n, 9}, r}, t]
Show[Plot[exp /. %, {t, 7, 84}], ListPlot@points]
{c -> 261.04, n -> 12.3092, r -> 0.0877072}

enter image description here

  • $\begingroup$ Thanks, i didn't know you could give the variables a rough starting value. $\endgroup$ – VikeStep Feb 21 '14 at 11:07

If "diagnostics" or standard errors are required you can use NonlinearModelFit with the starting values:

fun = c n/(n + (c - n) Exp[-r t]);
nlm = NonlinearModelFit[points, fun, {{c, 256}, {n, 9}, r}, t]

Visualizing fit:

Show[ListPlot[points], Plot[nlm[t], {t, 0, 90}]]

enter image description here

You can get model:



3213.19/(12.3092 + 248.73 E^(-0.0877072 t))

You can look at model properties:


For example:


yields 0.999586.



enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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