Tuesday, August 17, 2021

General Linear Least-Squares Regression

Problem 15.10.


Three disease-carrying organisms decay exponentially in a seawater according to the following model:
p(t) = Ae-1.5t + Be-0.3t + Ce-0.05t 
Use general linear least-squares to estimate the initial concentration of each organism (A, B and C) given the following measurements:


Solution:


Firstly, note that the given model is actually a multiple linear function, where e-1.5t, e-0.3t and e-0.05t are x1, x2 and x3 respectively. And there is no intercept. Let's solve the problem using MATLAB!

The data can be entered as column vectors and the [Z] matrix can be set up as below:
>> t = [0.5 1 2 3 4 5 6 7 9]';
>> p = [6 4.4 3.2 2.7 2 1.9 1.7 1.4 1.1]';
>> x1 = exp(-1.5*t); x2 = exp(-0.3*t); x3 = exp(-0.05*t);
>> Z = [x1 x2 x3]

Z =

    0.4724    0.8607    0.9753
    0.2231    0.7408    0.9512
    0.0498    0.5488    0.9048
    0.0111    0.4066    0.8607
    0.0025    0.3012    0.8187
    0.0006    0.2231    0.7788
    0.0001    0.1653    0.7408
    0.0000    0.1225    0.7047
    0.0000    0.0672    0.6376

Then, the coefficients can be generated using Eq.(15.10) in textbook:
>> a = (Z'*Z)\(Z'*p)

a =

    4.1375 = A
    2.8959 = B
    1.5349 = C

Thus, the least-squares fit is p(t) = 4.1375e-1.5t + 2.8959e-0.3t + 1.5349e-0.05t .

Best-fit line and the data can be plotted as
>> pp = Z*a;
>> plot(t,p,'bo',t,pp,'k-')
>> xlabel('t'),ylabel('p'),title('Decay Exponential Model')

No comments:

Post a Comment

Numerical Integration Formulas

Here are the M-files to implement composite trapezoidal rule for equally spaced data and unequally spaced data.  Composite Trapezoidal Rule ...