keeping a shared parameter across data sets when estimating parameters

2 visualizzazioni (ultimi 30 giorni)
I am trying to fit data to a non linear ODE system in order to estimate model parameters. I have data for three separate subjects as data1,data2,data3 measured over the same time span. In estimating these parameters I want to keep one of the estimated parameters to be common among all subjects.
I have written the code similar to the one at 'anlaysis.m' in here .
But, still I am getting a different value for the parameter that I want to keep constant.
My code is something like:
%Y has 4 columns. First column is time. Second column is data on
%first subject (data1), third colum is data on second subject (data2)
%third column is data on third subject (data3)
[fit,fval]=fmincon(@(parameters)ssq(parameters,Y),initial,[],[],[],[],lb,ub,[])
function SSE=ssq(parameters,Y)
time=Y(:,1);
SSE=0;
for i=1:3
fitted=model(parameters,time,i);
error1=fitted(:,1)-Y(:,i+1);
SSE1=sum(error1.^2);
SSE=SSE+SSE1;
end
end
function output= model(parameters,t,subject)
t=t(1:9)';
x0=[10^5,0.01];
a_1=parameters(1);%dependent on subject
a_2=parameters(2);%dependent on subject
a_3=parameters(3);%dependent on subject
r1=parameters(4);%common to all subjects
if subject==1
parameters1=[a_1,r1];
[time,pred1] = ode45(@(t,y)Equations(t,y,parameters1),t,x0,options);
output=pred1;
end
if subject==2
parameters2=[a_2,r1];
[time,pred2] = ode45(@(t,y)Equations(t,y,parameters2),t,x0,options);
output=pred2;
end
if subject==3
parameters3=[a_3,r1];
[time,pred3] = ode45(@(t,y)Equations(t,y,parameters3),t,x0,options);
output=pred3;
end
function s=Equations(t,y,eval)
s=zeros(2,1);
% b, k are know constant parameter values. The parameter estimated as
% eval(2) should be constant among all subjects
s(1)=(eval(2)*y(1))-eval(1)*y(2)*y(1);
s(2)=b*(k-y(2))*y(1)-eval(1)*y(2);
end
end
Can someone please explain to me how I can correct the code to evaluate a common parameter as I don't know if it works because it has been running for a very long time? Here, although at the moment I have written it to 3 subjects I actually ahve 10 subjects. So, I need to find an efficient way to deal with this.

Risposte (0)

Categorie

Scopri di più su Optimization Toolbox 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