Hello,
Working on the math library here, and I have had an immensely difficult time finding how to efficiently implement a logistic curve fit. Note, this isn't a full fledged binary logistic regression (which I can find lots of information on), but rather the fitting of a curve to a set of data with the form L/(1+a*^(-b*x)).
The fitting method in the math library right now linearizes the equation and it doesn't give a very good fit at all so I am trying to replace it.
Does anyone have any helpful pointers to any algorithms for this type of problem?
I have posted the Charlie Patton's code comments below from the 48 math library for those interested (he wrote this originally). I am not 100% certain if the issue is the linearization and a completely different method is needed, or just the L esitmator routine needs replacing/improvement.
* Name: fitlogist
* Algorithm: The basic model is:
* y=L/(1+A*e^(B*x))
* which is equivalent to:
* Ae^(B*x)=(L-y)/y
* so that
* ln(A)+B*x=ln(L/y-1).
*
* Fit a linear model to the transformed data
* ( x(i), ln(L/y(i)-1)) to obtain y=a+bx
* then A=e^a and B=b
*
* Note B normally would be negative
***Name: Lestimate
**
**Category: Logistic Fit Utility
**
**Entry:
**
** Stack: [XY] (sorted)
**
**
** Temp. Env.
**
**
**Exit:
**
** Stack: L% (or %0 if there's a problem with zero divisors)
**
**
** Temp. Env.
**
**Errors:
**
**
**Description/Algorithm:
**
** This utility attempts to estimate the saturation value for a logistic
** equation from sorted statistical samples.
**
** It is assuming that the data Y(X) (stored in pair form X[i],Y[i]) corresponds
** to samples from a differential equation dY(X)/dX = Y(X)*k*(L-Y(X))
**
** Note that this is an autonomous ODE with nodes at Y=0 and Y=L.
** If we plot (1/Y)*(dY(X)/dX) as a function of Y (note that it doesn't really depend
** on X) we will get a straight line with a zero at Y=L. It is this fact we will use
** to approximate L from the data. Namely, replacing dY(X)/dX by it sampled version
** dY(X)/dX ~ Y'[i]=(Y[i+1]-Y[i])/(X[i+1]-X[i])
** we do linear regression on the pair Y[i],Z[i] with Z[i]=Y'[i]/Y[i] and
** find the zero of the corresponding line.
**
**Author: C.M.Patton
**Date Written: April 10, 1995
TW
--
Although I work for the HP calculator department, the comments and opinions I express here are my own.
Edited: 11 Nov 2011, 12:18 p.m.