Re: Fitting parameters of nonlinear diff equation system

• To: mathgroup at smc.vnet.net
• Subject: [mg81303] Re: Fitting parameters of nonlinear diff equation system
• From: Szabolcs Horvát <szhorvat at gmail.com>
• Date: Tue, 18 Sep 2007 06:02:15 -0400 (EDT)
• Organization: UiB
• References: <fcnl8h\$s85\$1@smc.vnet.net>

```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. The
> 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!).

Suppose that 'deq' contains the differential equations from your
message, and 'tvals' and 'fvals' are the data against which we are
fitting the 'f' function ('tvals' are the 't' values).

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.}}]

FindFit may work too (with 'fun'), but I wanted to avoid NDSolve being
evaluated for each data point, and I do not know how FindFit works
internally.  The diff eq should be solved only once for each set of
parameter values.

--
Szabolcs

```

• Prev by Date: Re: MachinePrecission and FPU
• Next by Date: Re: How to set working directory?
• Previous by thread: Fitting parameters of nonlinear diff equation system
• Next by thread: Re: Re: Fitting parameters of nonlinear diff equation system