Lec 58: Estimation of Parameters II

IIT Roorkee July 201
61 followers
Aug 22, 2024
This lecture focuses on parameter estimation in mathematical modeling. We will explore techniques to estimate the parameters of differential equations using data from Microsoft Excel.
[Music]
[Music]
hello welcome to the course excelling
with mathematical
modeling today we will be discussing an
very important aspect of mathematical
modeling that is estimation of
parameters we have already seen how you
can estimate the parameters in a
function so today we will be taking a
differential equation which will
represent a model and the differential
equation will contain some parameters so
we will see that how you can estimate
those parameters using the data so
basically you will be having
a set of
datas say the the time and the variable
X so this will be some T1 T2 and so on
this will be some X1 X2 and so on so
by looking at the plot of this graph so
you will be plotting this two and you
will be getting some some values some
some graph like
this so by looking at this graph you
have to decide that what kind of model
can fit this particular data so after
you have decided what kind of model it
is say this is the
model then you have to use the method of
list squares to estimate the parameter
values so let's directly go to the Excel
sheet and see that how this is done so
as you can see that I have the data
of equalized stance this is a growth
data and the time is there and the
growth is here so I need to
fit a suitable model and estimate those
parameters with the help of this
data now since it is a growth of this
particular strain so
we will be using the growth model and
the growth model which we have studied
are either logistic growth or gper
growth which are a bit realistic than
the exponential growth so we will be
taking the logistic one and also maybe
the gper Gian one and we can compare
which one is
better so if you try to fit the logistic
growth then your equation will be of the
form DxD DT is equal to R
* x 1 - x by
K so my parameters here is R and K but
before you State this
equation whether it is a logistic one or
whether it is a goian
one that is K
byx where R is the intrinsic growth rate
and K is the cing capacity so this is
the
logistic and this is the G
parge so as I was telling before you
write this equation you just see that
how this
particular data looks like once they are
plotted so I highlight the time
and the
growth and let me plot a scattered
diagram so I go to
insert I choose the scattered diagram
and I plot the
data so this
is I write
parameter
estimation so this is the first part
that is
done next
is I assume that let's this particular
curve is modeled by this equation the
logistic growth that is dxdt equal to RX
into 1 - x by K so I have two parameters
here one is
this R another is this
K so I increase the font
size and metal them and since we will be
using the Oilers method I have to take a
h and the value of
H I have
[Music]
to put say h equal to 1 the next thing
is the predicted growth so this is the
one which you already get from the data
and then you make the prediction with
the help of this particular
equation so the predicted growth so I
just write
here
predicted
growth now in the predicted growth I
need a initial
condition which I coincide with the this
value you could have put something else
also but since you already have the data
so I coincide the first value that at
point five the predicted growth also
coincides with the growth actual data
and then I have to attribute some values
of r and key you choose that
arbitrarily and then I
calculate the rest of the values using
the
formula so the formula is we use Oilers
method and the formula says
that y
1 is = y0 + H
fx0 so this will
be equal
to First
is the initial value y0 or x0 in this
case since I'm following this equation
let's me take it as x0 so
x0
plus h which is 1 and it is a
constant so I make it a
constant multiplied
by
R so this is
R again a
constant R * x0 which is this
value multiplied by 1 -
x0 ided by
k k is again a
constant that's
it so quickly let me check it so this
is y 0 +
K 6 which is
is +
H ultied by
R okay and then I just drag
it
okay so now what you do is
you got the time you have the data now
you have predicted the growth by using
this
model so now let's see what is the
difference between the data and the one
which you have predicted so I will
add the
curve so I will say select
data and I will add
data so I name it as best fit
or let me
write
predicted now x value I choose the
time you highlight this and put the
cursor
down and press enter so X values have
been here the Y values I can press this
and the Y values is the one which is the
predicted
one you highlight all of them and enter
so all the X and the Y values have
been and you click okay so now if you
see the graph you now see
that this is the data and the orangish
one is the predicted value
okay now quickly let
me change
this uh change chart type
okay I want this one to
[Music]
be
data
so put the
legend change the series one to data so
I go to design I select data so this we
have already done so I'm not explaining
much so in series one I Ed it and I name
it as
data okay
okay so the blue one is the data and
orange one is the predicted value let me
change
the data
as points so here is the data I make it
as
points
okay so now I have this particular
figure where this dots in blue are the
data and this is the one which is
predicted so now how to estimate it
using the method of list squares so the
first thing you do is you try to bring a
good match by manipulating these
values see say I put it two and let's
see how the behavior of the graphs okay
so it gives something like this so two
will not work so let me put
0.1 okay again it goes
down
0.5 okay goes
up
0.3 okay somewhat like this 0
.4 okay
0.7 so like this you bring the carve
close to
it to the
data yeah so it is coming
close so you can play with this a bit so
that a little good match is
found uh and then what you do is is we
use the method of Le squares so that
will
be
the value which you got from the data
minus the predicted value which gives
you the residuals you square them which
will give the residual Square you sum
them and then minimize the residual
which is just the error so what I will
do is this is equal
to the data
value and the predicted
value this will be zero obviously
because both are same and if I drag
it I get some
value now this is
residuals but let me d directly
calculate the residual
Square because we will be needing them
actually so I made them
Square so this is the residual
Square I just increase the font size
residuals
square and then what you have to do is
you have to take the sum of this square
of the residual so this is equal
to
sum you highlight this press
shift go drag all the values
this much close the bracket and
enter and you get the
sum so once you get the sum of the res
square of the residuals now I have to
minimize this value and for that I will
be using the solver so go to
data go to the
solver and this kind of window is is
opened so I have to minimize
this sum of the square of the residuals
so I click this and immediately the cell
number is highlighted here so I have to
minimize this
value and by
adjusting the value
of R and KY so
here I will choose this R and key and
immediately it has come here and
then keep all them as it is and click
solve okay so as you can see that it has
automatically adjusted the values using
this solver give a fit so this is the
best fit that you can get for this
particular data and please note this
this is a real life data so it is not
that you will expect that it there will
be an exact match of this curve with all
the datas that is the best that you can
get and the parameter estimated values
is r equal to 61 and K = to
79 so this is how it is
done now let's move to another example
where we take two equations
so let's me copy the
data so this is the time
and this is
the say measured value that is the one
which you get from the
data so this is measured
P now my variables here are some A and B
and I put it in the
form
say d a
DT is equal to some - K1 *
a + K2 *
b² and DB
DT is equal to 2 K1
A- 2 K2
p² so I have this system of equation
system of differential equation ODS
where A and B is my variable and K1 K2
are my parameters so I have to estimate
the values of K1 and K2 and the
parameters which are given I mean the
data which is given is only of B
and not of
e so the first thing is let me see
how these behave so I just go to the
scatter diagram and
this so this is how the data is behaving
and let us now
fit this equation in the data
and see what the values of
A and
B we are getting so they are the
measured values
now sorry predicted values so this is
the measured and this is predicted
a predicted B
for that I need a initial value of
K1 and
K2 so as usual I put them first to be
one one and then we
can always adjust
them so initial
value this is say one 1 and this is
equal to zero so I coincide this value
with the data this I chose
arbitrarily now first let's calculate
the predicted value of a and b so this
is equal
to initially a z plus h so I need a h
which again I take to be one
okay so we attribute some initial value
of this K1 and
K2 and say I put
1.3 and let's us calculate the predicted
value of a and b and we use oil as
method so this is equal
to the initial value of a which is a0
plus h
* multiplied by this part so
minus
K1 which is a
constant
time
A+ K2
which is
constant
time
b² similarly this is equal
to V
0
plus
h multiply
by 2
*
K1 multiplied by
a - 2
*
[Music]
K2
multiplied by B
Square close the bracket and calculate
so highlight this two and drag them to
all these
values and I change the font to
20 so let's now plot
these
values so I will
add data to it so
select add
data predicted
a the X values will start from zero
till
10 and the Y values will start
from so this is the predicted
a and
enter and
okay
and add another value
this
is predicted
B the x value will start from
here all the
times and the Y value is the predicted B
value
and okay and
okay so let's see how the figures look
like so the chart look like this and I
need the
Legends go to
design select data the series edit and
name it to
data and
then the
datas may be in dots but this
change to lines so change chart
type so let the data be scattered
predicted
a be a line and predicted b b also
line
okay and let's see if I change the
color say I want a
green
yeah so this is now
the data the predicted a and the
predicted B so the next step is you have
to calculate the
residuals so now you are dealing with
the data of B and the predicted value of
B so everything will be calculated for B
so this is equal to the residual which
is the measured value or from the data
minus the predicted value and I have to
calculate the square of the residuals so
I Square
them and
enter so this gives me the square values
of the
residuals and the next thing is I have
to calculate the
sum of the
square of the
residuals and
and I get the
sum so next is I have to minimize this
sum of the square of the residuals go to
the data I use the
solver so first I
choose which I have to minimize that is
this
cell so I click this and immediately it
comes here I have to minimize the value
so I click it here and I have to
adjust the variable cell which is my K1
and K2 it came here and then keep them
as it is and just use
solve and okay so now you
see that this is your data and it's a
very good match your predicted a is as
it is where the predicted B is is this
green
line and your estimated value of K1 and
K2 came to be16 and .1 so this is how
you estimate parameter values using data
in the case of differential equations in
my next lecture we will again continue
with estimation of parameter but with
difference equations till then bye-bye
[Music]
