MathGroup Archive 1996

[Date Index] [Thread Index] [Author Index]

Search the Archive

problem with NonlinearFit

  • To: mathgroup at
  • Subject: [mg4705] problem with NonlinearFit
  • From: "Brian O'NEILL" <oneill at>
  • Date: Sat, 31 Aug 1996 03:57:27 -0400
  • Sender: owner-wri-mathgroup at

I am having the following problem with the NonlinearFit function, and would
appreciate any tips you might have. (I have appended sample Mathematica code

My goal is to fit a non-monotically decreasing time series with a
monotonically decreasing function (specifically, a sum of decaying
exponenitials plus a constant).  I am approaching the problem by using
NonlinearFit and specifying a general functional form, then attempting to
constrain the search to non-negative coefficients and non-positive
exponents.  However, in general I have run into the following problems:

(1) NonlinearFit will accept parameter specifications of the form {x,xo}, or
of the form {x,minx,maxx}, but not of the form {x,xo,xmin,xmax}.  This means
I can constrain the variables, but I can't start from different points to
test robustness.

(2)The routine stops when it tries to search outside the constraints instead
of continuing the search in a different direction, so that it is important
to be able to specify different initial values to look elsewhere.

I have also tried using MultiplierMethod and posing the problem as a
minimization of least squares errors, but have had even less luck getting
that function to accept constraints (but if you have pointers I would be
happy to use anything that works).

The code is below; any help appreciated.

Brian O'Neill

(* define general functional form - sum of exponentials *)
(* plus a constant, such that all coefficients sum to 1 *)
fn[t_,a1_,a2_,a3_,tau1_,tau2_,tau3_] :=

(* generate data with one negative coefficient to *)
(* produce a bump in the data *)
data = Table[{t,fn[t,0.6,-0.4,0.1,15,30,300]},{t,0,300,10}];
(* take a look at data *)

(* fit data with only positive coefficients allowed, *)
(* supplying no starting points.  this gives a solution, *)
(* but I'd like to look for a better one (depending on the *)
(* data, it sometimes stops searching because it exits the *)
(* parameter bounds) *)
soln = NonlinearFit[data,fn[x,a1,a2,a3,tau1,tau2,tau3],

(* try the same fit again, with same constraints on  *)
(* parameters but supplying starting points in order *)
(* to find a different solution - but the function won't *)
(* take both starting points and constraints....I can't *)
(* find a syntax that works (this is the syntax give in *)
(* the package documentation), nor can I figure out from *)
(* looking at the package what the problem is. *)
soln = NonlinearFit[data,fn[x,a1,a2,a3,tau1,tau2,tau3],

(* take a look at the fit *)

                       Brian O'NEILL
 International Institute for | Email: oneill at
  Applied  Systems Analysis  | Phone: +43  2236 807 0
  A-2361 Laxenburg, Austria  |   Fax: +43  2236 71313


  • Prev by Date: Books
  • Next by Date: Re: Integer Partitioning
  • Previous by thread: Books
  • Next by thread: Re: Integer Partitioning (correction)