Trouble with least squares fit to 3D ODE model with 2D observed data

1 visualizzazione (ultimi 30 giorni)
Hi, first time poster here.
I have a compartmental ODE with 3 state variables and I am trying to do a parameter optimization. The three state variables describe counts of tumors in mice at different stages: 1. Unobserved, 2. Small, and 3. Large. There are no data for the unobserved tumors, as the name would suggest. Each individual is observed once and their age is recorded along with the total number of small and large tumors that they have. Some of the indivduals have the same age at time of observation, so there are at times three large and small tumor counts at a given time point.
When I pass the 3D ODE into lsqcurvefit I encounter one of two error messages: "The entries in tspan must strictly increase or decrease" or "The last entry in tspan must be different from the first entry."
When I use instead a 2D compartmental model to describe the data, lsqcurve fit works fine while using the same dataset and input time vector.
I am looking for any ideas on how to fix this problem or another way to optimize the parameters to fit the data.
Non-example of lsqcurvefit:
[B,Rsdnrm,Rsd,ExFlg,OptmInfo,Lmda,Jmat] = lsqcurvefit(@countsGrowth3, [.5 .5 .5], TestX(:,1), TestX(:,2:3));
countsGrowth3 is the 3D ODE function. The second input is the initial guess for the three parameters. TestX is a 3 column matrix where the first column contains the times, second column is the small tumor counts, and the third column is the large tumor counts. This is the version that does not work.
Example of lsqcurvefit:
[B,Rsdnrm,Rsd,ExFlg,OptmInfo,Lmda,Jmat] = lsqcurvefit(@countsGrowth2, [.5 .5], TestX(:,1), TestX(:,2:3));
countsGrowth2 is the 2D ODE function. The second input is the initial guess for the two parameters. TestX is the same matrix as described above.
countsGrowth3 code:
%modeling the tumor growth model for total number of unobserved, small, and
%large tumors.
%dydt(1) is the rate of growth of unobserved tumors
%dydt(2) is the rate of growth of small tumors
%dydt(3) is the rate of growth of large tumors
%U is the parameters for the ODE describing the growth rates of unobserved, small, and large tumor counts
function S = countsGrowth3(t,U)
y0 = [0 0 0];
Sv = ode45(@(t,y) growth(t,y),t,y0);
function dydt = growth(t,y)
dydt = zeros(3,1);
dydt(1) = -U(1)*y(1) + U(3);
dydt(2) = U(1)*y(1) - U(2)*y(2);
dydt(3) = U(2)*y(2);
end
S = Sv(:,2:3);
%only returning the 2nd and 3rd columns, aka the growth count trajectories for the small and large tumors
end
countsGrowth2 code:
function S = countsGrowth2(t,B)
%B is a vector containing the two parameters describing the small and large tumor count growth rates
x0 = [0,0];
[T,S] = ode45(@DifEq, t,x0);
function dS = DifEq(t, x)
xdot = zeros(2,1);
xdot(1) = -B(1)*x(1) + B(2);
xdot(2) = B(1)*x(1);
dS = xdot;
end
end
Thank you in advance for any help!

Risposte (1)

Torsten
Torsten il 1 Ago 2022
[~,Sv] = ode45(@(t,y) growth(t,y),t,y0);
instead of
Sv = ode45(@(t,y) growth(t,y),t,y0);
  1 Commento
Henry
Henry il 29 Ago 2022
Hi, thank you for your response. When I tried this I encountered a different error about unequal array sizes. I ended up finding a different method to minimize my objective function using fmincon instead of lsqcurvefit.

Accedi per commentare.

Categorie

Scopri di più su Historical Contests in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by