       Re: how to use NonlinearRegress w. NDSolve model?

• To: mathgroup at smc.vnet.net
• Subject: [mg21199] Re: [mg21066] how to use NonlinearRegress w. NDSolve model?
• From: "Mark Harder" <harderm at ucs.orst.edu>
• Date: Fri, 17 Dec 1999 01:24:40 -0500 (EST)
• Sender: owner-wri-mathgroup at wolfram.com

```John;
FindMinimum and NonlinearRegress do 2 *different* things:  FM finds the
minimum of the function supplied, with respect to the variables in the
domain of the function.  You properly supplied the function which returns
the sum-of-squares of the residuals from fitting the 3 ODEs to your data
sets, and you say FM worked here, so it must have returned the parameter
vector which minimized the local ssr for your model and data.  On the other
hand, NR  accepts a vector of data and a model function and other arguments,
and it uses an iterative algorithm (by default,Marquardt-Levenburg, although
FM can be used as a search routine instead) to start at a parameter vector
(beginning with your initial guess), and step through parameter space until
the ssr function ,WHICH IT COMPUTES FOR YOU, minimizes locally.  Your
mistake #1 was to supply NR with the same ssr function you gave FM.

Also, you gave what appears to be a *matrix* of dependent varriable values
for your data argument.  I have tried this, in the case where my model
equation was naturally a matrix equation, and it didn't work.  The help menu
(Add ons>Statistics>Nonlinear Fit) on this topic *seems* to say that
although a vector of independent variable values may be given for each
(scalar) dependent variable value, you cannot supply multiple dependent
values for each independent value.  I.E. if the 3 ODE's give 3 values of
y(t) over the same values of t, then
{t1,y1[t1],y2[t1],y3[t1]},{t2,y1(t2),y2(t2),y3(t2)},{ .... won't work --
you will have to list {t,yn(t)} pairs, as in
{{t1,y1[t1]},{t2,y1[t2]},.......,{t1,y2[t2]},{t2,y2[t2]},.....{t1,y3[t1]}...
.{tn,y3[tn]}}.  Of course, the ODE model function must similarly return
solutions in this single-column format as well.

let me know.

Hope that helps,
-Mark

-----Original Message-----
From: John S. Paschkewitz <paschkjs at vaa.wpafb.af.mil>
To: mathgroup at smc.vnet.net
Subject: [mg21199] [mg21066] how to use NonlinearRegress w. NDSolve model?

>Hi,
>
>I am trying to fit a model defined by a set of 10 or so coupled 1st
>order non-linear ODEs to some experimental data.  There are several
>constants in the ODEs that I am trying to obtain by non-linear fitting
>to several sets of data simultaneously.   I have a large number of data
>sets with varying initial conditions.
>
>I've used the FindMinimum method suggested on the Wolfram website to fit
>the model to the data and have had pretty good success with it.
>However, I'd really like to get some more descriptive statistics on the
>quality of the fit.  Is there any way to use NonlinearRegress with the
>model I've got?
>
>Some example inputs are:
>
>ssA1[k3_?NumberQ, k9_?NumberQ, k16_?NumberQ] :=
>  Block[{solA1, d},
>    solA1 = NDSolve[{de1, de2, de3, de4, de5, de6, de7, de8, de9, de10,
>de11,
>            de12, de13, A1a0, A1b0, A1c0, A1d0, e0, f0, g0, h0, i0, j0,
>A1k0,
>            A1l0, m0}, {a, b, c, d, e, f, g, h, i, j, k, l, m}, {t, 0,
>            0.4}][]; Plus @@ Apply[(d[#1] - #2)^2 &, dataA1, {1}] /.
>solA1]
>
>ssA3 and ssA5 are defined similarly.  Each one is fitted against a
>different data set for a different set of i.c.'s.
>
>FindMinimum[(ssA1[k3, k9, k16] + ssA3[k3, k9, k16] + ssA5[k3, k9, k16]),
>{k3,
>    7.0*^-15, 1.0*^-14}, {k9, 3.0*^-11, 3.0*^-10}, {k16, 3.0*^-10,
>    5.0*^-10},  MaxIterations -> 200]
>
>I've tried to use:
>
><< Statistics`NonlinearFit`
>NonlinearRegress[{{dataA1},{dataA3},{dataA5}},  (ssA1[k3, k9, k16] +
>ssA3[k3, k9, k16] + ssA5[k3, k9, k16]), {k3,k9,k16}, {k3,     7.0*^-15,
>1.0*^-14}, {k9, 3.0*^-11, 3.0*^-10}, {k16, 3.0*^-10,
>    5.0*^-10},  MaxIterations -> 200]
>
>but this just returns my input.
>
>I've only been using Mathematica for a couple of weeks, so I'd
>appreciate any suggestions.
>
>Thanks,
>John
>
>John Paschkewitz
>Research Engineer
>AF Research Laboratory
>WPAFB, OH 45433
>
>
>
>

```

• Prev by Date: Re: Q: efficient in-place list element replacement?
• Next by Date: [Fwd: Graphics3D[] objects clipping & PlotRange]
• Previous by thread: how to use NonlinearRegress w. NDSolve model?
• Next by thread: Re: NonLinearFit