Re: NonlinearFit-Logistic Function-CalcCenter 3

*To*: mathgroup at smc.vnet.net*Subject*: [mg60544] Re: NonlinearFit-Logistic Function-CalcCenter 3*From*: dh <dh at metrohm.ch>*Date*: Tue, 20 Sep 2005 05:18:58 -0400 (EDT)*References*: <dgitnd$2e2$1@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

Hello Oddur, You are wundering why NonlinearFit does give different answers if you replace a parameter by its negative. Well, there does not exists a numerical non-linear fitting routine that always returns optimal parameters. All depends of your starting point. To see why, consider the fitting error (e.g. sum of squares of difference between fitted and given data points) as a function of your parameters. Assume the axis of the error magnitude upwards. Then this function describes a surface and you try to locate parameter values for the lowest point on this surface. That is easy for e.g. a "cup" sized function with one minimum. This is the case for linear fits. Nonlinear fits on the contrary can have any number of dimpels and holes. If you have no idea where the deepest hole is, it is not possible to write a program that always gives the lowest point on the surface for an arbitrary model function. However, quit many numerical algorithms exist, that will try to find the lowest point in the neighberhood of some starting value. The range of sophistication is quit broad here. From the simple "go down hill" (steepes descent) to procedures like "simulated annealing" that tries to find the deepest hole in the negihberhood, there exists a broad palette of algorithms. They all have in common that they need a starting point in some way, and the result may depend on this point. Back to your example. If you do not specify a starting point, NonlinearFit, assumes a starting point of 1. Therefore, by changing a to -a, you are actually changing the starting point and, not astonishing, you may get another result. You can specify a starting point in NonlinearFit by replacing the parameter, say a, by: {a,startingpoint}. You may even give an intervall from where to try different starting points (see manual) by: {a,min,max}. You can get the same answer from NonlinearFit independetn of parametrization, if you specify corresponding starting points. But you should always check the results of any nonlinear fit routine if it is feasible. sincerely, Daniel Oddur Bjarnason wrote: > I thank Bob Hanlon and Valeri Astanoff for their prompt reply and am following their suggestions. > > Purely by chance I found a solution to the problem I had using CalcCenter 3 for nonlinear fitting of data to a logistic function. > > By fitting > > data2={{-0.08,0.05},{0.96,-3.19}, > {1.93,-6.4},{2.98,-10.32}, > {3.97,-11.8},{5.92,-13.98}, > {7.88,-14.12},{11.85,-15.34}, > {15.79,-14.61},{19.7,-15.43}, > {23.67,-15.83}}; > > by NonlinearFit[data2, -a/(1 + b*Exp[-c*t]), t, {a, b, c}] > > instead of > > NonlinearFit[data2, a/(1 + b*Exp[-c*t]), t, {a, b, c}] > > that is by changing the sign of a > > I obtained the function > > -14.917794621733984/(1 + 10.284628991516529*Exp[-1.0072061447043623*t] > > Presumably this method can also be used in Mathematica. > > I must admit that I have not as yet found out why this works. > > Regards, > > Oddur Bjarnason > >