Fit time series Q(t) to a logistic function.
Inputs (vectors of same size): t (time) & Q
Outputs: Qpre (logistic model fit to data) and three independent parameters: thalf, Qinf, and a, describing the logistic
Q(t) = Qinf/(1 + exp(-a*(t-thalf)))
Qinf is value as t --> infinity
thalf is time of symmetric inflection point
a is time decay constant
Written by James Conder, Southern Illinois University, Oct. 2010
Cleaned up for publishing May 16, 2013
Andrew, I spent some time looking at it, and think I have fixed the problem. I just uploaded a newer version. Once it is up, please try your dataset on it and let me know how it goes.
Great function, thank you. I too have the issue with outputting a constant value for Qpre, and, as with Darren, changing the scaling of the value for t fixes this. My t values scale between 0 and 1 in steps of 0.001.
Sorry about the plotting calls. I realized that I forgot to remove them just after resubmitting. I guess the follow up submission with those removed is still moving though the system.
Good catch on reversing t. It is one of those bugs introduced when addressing a different problem. I'll fix that bug and put a test example in the help comments in new submission later today.
I've tested out the new code and it works a lot better for my case. One problem I've now identified is that you are not re-reversing t at the end of the function, so the calculated Qpre can be in error.
Other than this, I would suggest for you to include a brief usage example within the Help comments, e.g. constructing data from known parameters, adding some random error and obtaining parameter estimates. Just a few lines to help someone getting started.
Also, you should turn the various plotting calls off by default then have an extra (optional) input parameter for people to use to turn them on.
Thanks for the feedback, Darren. I've made a fix based on your idea of rescaling the vector internally, and submitted an update. It isn't completely obvious to me why Qpre goes to the mean of Q for some scalings of t. In any case, I hope my fix is general and not limited to your special case. Keep me posted.