MathGroup Archive 2007

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

Search the Archive

Re: Re: Fitting parameters of nonlinear diff equation system

  • To: mathgroup at smc.vnet.net
  • Subject: [mg81491] Re: [mg81303] Re: Fitting parameters of nonlinear diff equation system
  • From: "Paul Thomas" <paul.pgt at gmail.com>
  • Date: Wed, 26 Sep 2007 06:32:33 -0400 (EDT)
  • References: <fcnl8h$s85$1@smc.vnet.net> <200709181002.GAA04068@smc.vnet.net>

Hi everyone,

Just wanted to follow up with this. The e-mail below from Szabolcs was very
helpful and it did work, with just a minor syntax change. He suggested the
following code for fitting a system of differential equations with multiple
parameters:

fun[a_, b_, c_] :=
   First[
     f /. NDSolve[
            deq /. {b1 -> a, h -> b, r -> c},
            {v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, f},
            {t, 0, 10} (* dummy values *)
          ]]

opt[a_?NumericQ, b_?NumericQ, c_?NumericQ] :=
   Norm[fun[a, b, c] /@ tvals - fvals]

Now use FindMinimum on 'opt', like this:

FindMinimum[opt[a,b,c], {{a,1.}, {b,2.}, {c,3.}}]

One change I had to make was in the "fun[a_,b_,c_]" equation--instead of
"f/.NDSolve" it should be "f[t]/.NDSolve" etc etc.

The other change I had to make was in the opt equation. I just needed to pu=
t
parentheses around the "(fun[a, b, c] /@ tvals)" term--otherwise it thinks
the "/@" Map command is being applied to tvals-fvals.

I want to thank everyone for their comments, I'm so pleased with this
technique now. I think it works very much like the documentation says
FindFit works, but it is much more flexible in terms of the data you can
input for the fit and also allows a whole system to be solved with data onl=
y
from a single equation. To me, those are both huge advantages. Thanks!

Paul

On 9/18/07, Szabolcs Horv=E1t <szhorvat at gmail.com> wrote:
>
> Paul Thomas wrote:
> > Hi everyone,
> >
> > I have a set of differential equations (posted below) that I can solve
> quite
> > easily using NDSolve if I define all my parameter values. I have three
> > parameters that I am currently estimating and would like to try and fit
> > using actual data I have acquired. The function FindFit though seems to
> only
> > work off of a single, non-differential "model" equation. Is this right?
> Is
> > there any functionality I can use in Mathematica to help me fit the
> > parameters of a system like this? Right now I am using the "Table"
> function
> > to solve the equation using NDSolve over a range for the parameters. Th=
e
> > problem is that I have the multiple parameters that I'd like to fit so
> it's
> > quickly become an enormously tedious set of solutions (as I have to a
> range
> > of each parameter at a range of the other two parameters).
> >
> > Here's one of the sets I've been trying to do this with: The parameters
> I'd
> > be solving for include b1, r, and h. Like I said, I can make good
> estimates
> > of these and I know ranges, but I'd like to do a proper fit so that I
> can
> > quantify sensitivity etc. Thanks,
> >
> > Paul
> >
> >
> > {v1'[t]==-b1 v1[t] f[t],
> > v2'[t]==2 b1 f[t] v1[t]-b1 f[t] v2[t],
> > v3'[t]==2 b1 f[t] v2[t]-b1 f[t] v3[t],
> > v4'[t]==2 b1 f[t] v3[t]-b1 f[t] v4[t],
> > v5'[t]==2b1 f[t]v4[t]-v5[t],
> > v6'[t]==2v5[t]-v6[t],
> > v7'[t]==2v6[t]-v7[t],
> > v8'[t]==2v7[t]-v8[t],
> > v9'[t]==2v8[t]-v9[t],
> > v10'[t]==2v9[t]-v10[t],
> > v11'[t]==2v10[t]-v11[t],
> > v12'[t]==2v11[t]-v12[t],
> > v13'[t]==2v12[t],
> > f'[t]==r f[t](1-f[t]/10000000)-h
> >
> (v1[t]+v2[t]+v3[t]+v4[t]+v5[t]+v6[t]+v7[t]+v8[t]+v9[t]+v10[t]+v11[t]+v12[=
t]+v13[t])
> > f[t],
> >
> v1[0]==30000,v2[0]==0,v3[0]==0,v4[0]==0,v5[0]==0,v6[0=
]==0,v7[0]==0,v8[0]==0,v9[0]==0,v10[0]==0,v11[0]==0=
,v12[0]==0,v13[0]==0,f[0]==1000000}
> >
> >
>
> Hi,
>
> This is untested, but hopefully it will work (let me know if it doesn't!)=


  • Prev by Date: Re: Re: Fitting parameters of nonlinear diff equation system
  • Next by Date: Re: Erroneous Mathematica Kummer's (Hypergeometric1F1)
  • Previous by thread: Re: Re: Fitting parameters of nonlinear diff equation system
  • Next by thread: Re: Re: Fitting parameters of nonlinear diff equation system