       Re: Nonlinear fit versus FindMinimum

• To: mathgroup at smc.vnet.net
• Subject: [mg29435] Re: [mg29408] Nonlinear fit versus FindMinimum
• From: "Mark Harder" <harderm at ucs.orst.edu>
• Date: Tue, 19 Jun 2001 05:35:50 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```Guillermo;
An incomplete answer, since much of your code was too complex for me,
but some clues that may be helpful:
I decided to evaluate model[] with t=0 and FindMinimum's solutions for
e12 and e23; I did this after 2 aborted infinite recursions with NLR.  Note
the results:

In:=
model[0, e12, e23] /. {e12 ->0.5590990394882845`,
e23 -> 0.007630709165369164`}

Out=
(42.7*T\$13398)/E^(100.*t) + (5.458*T\$13398)/E^(24.*t)

Although I gave model[] a complete list of numeric arguments, it returned a
symbolic result in both t and T.  See how the local symbol T\$ has been
evaluated 13398 times? Although I ran your code with a kernel I was using
for something else, I am sure that I didn't use a local T\$ at all (I never
start my own symbols with capitals.)  So your code has generated all these,
most likely during the infinite recursions.  My guess is that when you call
model[] from sseH, which you use in FM, but not in NLR, you provide a way
for model to be evaluated numerically, while the use of the "naked" model[]
by NLR creates the recursions.

Also, in NonlinearRegress, your syntax for the parameter list & their
initials is correct, but it forces NonlinearRegress compute exact gradients
from model, something I am sure it can not do. Notice that  your use of
syntax with FindMinimum avoids this problem, since you give each parameter 2
initials, which tells FM to use a numeric approximation to the gradient.
Nevertheless, when I ran NonlinearRegress in this  correct form, it
still generated a stream of "recursion limit exceeded" errors.  Therefore,
faulty use of syntax is not the present problem, although it will cause you

-mark harder

-----Original Message-----
From: J. Guillermo Sanchez <guillerm at gugu.usal.es>
To: mathgroup at smc.vnet.net
Subject: [mg29435] [mg29408] Nonlinear fit versus FindMinimum

>
>(*Question: I wist fit some parameters of a model  to experimental data.
>I get using FindMinimum but not using NonlinearFit. Why?. Can any body
>give me a hand*)
>
>MultiExpInput[matrixA_, opts2_, t_, x_] := Module[{A1, M1, M2, M9, R,
>i, T}, A1 = matrixA; M1 = MatrixExp[A1*t]; M0 = M1 /. t -> T; M2
>= ExpandAll[M0 . opts2 /. t -> t - T]; R = Chop[M2 /. a_*E^(b_*t +
>c_*T) :> (a*(E^(b*t)*(E^(c*t) - 1)))/c]; Table[ExpandAll[Subscript[x,
>i][t] -> R[[i]]], {i, 1, Length[opts2]}]];
>
>
>inp = 42.7/E^(100.*t) + 5.458/E^(24.*t);
>
>
>data = {{0, 0.002}, {50, 0.106}, {100, 0.077}, {150, 0.056}, {200,
>0.041}, {250, 0.032}, {300, 0.023}, {350, 0.018}, {400, 0.011}, {450,
>0.011}, {500, 0.007}};
>
>
>(*a12 and a23 are the parameters to be fitted*)
>
>mA[a12_, a23_] := {{-1.9404 - a12, 0, 0.0462}, {a12, -a23, 0}, {0,
>a23, -0.05775}};
>
>
>model[t_, A12_, A23_] := MultiExpInput[mA[A12, A23], {inp, 0, 0}, t,
>x][[2,2]];
>
>
>sseH[{(a__)?NumberQ}, list_, model_] :=
>
>Block[{q2}, q2[tiemp_] = model /. t -> tiemp; Plus @@ Apply[(q2[#1] -
>#2)^2 & , list, {1}]];
>
>
>(*^Now, I fit the parameteres and it work*)
>
>FindMinimum[sseH[{e12, e23}, data, model[t, e12, e23]], {e12, 0.8, 1},
>{e23, 0.007, 0.1}]
>
>
>(*Out[]:={0.0000148301,{e12=AE0.559099,e23=AE0.00763071}}*)
>
>
>(*But, I can't using  NonlinearFit*)
>
>Needs["Statistics`NonlinearFit`"]
>
>
>NonlinearRegress[data, model[t, e12, e23], {t}, {e12, 0.8}, {e23,
>0.007}]
>
>

```

• Prev by Date: RE: How to produce "thick" lines in 3D?
• Next by Date: Rows
• Previous by thread: Nonlinear fit versus FindMinimum
• Next by thread: Reentrant Functions