-
Notifications
You must be signed in to change notification settings - Fork 0
/
estimate.m
34 lines (20 loc) · 1.22 KB
/
estimate.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
function thetaOptim = estimate(W, Tw, Idata_est, Rdata_est, Ddata_est, lb, ub, theta0, par_obj, M)
NT = numel(Idata_est);
tFinal = NT-1;
tSpan = 0:tFinal;
tBreaks = (Tw:Tw:Tw*W)-1;
% Estimation ...
fun_handler = @(theta, tSpan)foroptim(theta, tSpan, Idata_est, Rdata_est, Ddata_est, M, tBreaks, par_obj);
optopt = optimoptions('lsqcurvefit', ...
'Display', 'iter', ...
'Algorithm', 'trust-region-reflective', ...
'MaxFunctionEvaluations',20000, ...
'FunctionTolerance', 1e-14, ...
'OptimalityTolerance', 1e-14, ...
'StepTolerance', 1e-14);
[thetaOptim, resnorm, ~, exitflag, output] = lsqcurvefit(fun_handler, theta0, tSpan, [Idata_est; Rdata_est; Ddata_est]./[Idata_est; Rdata_est; Ddata_est], lb, ub, optopt);
end
function out = foroptim(theta, tSpan, Idata_win, Rdata_win, Ddata_win, M, tBreaks, par_obj)
[S, U, I, R, D, x] = simode(theta, Idata_win, Rdata_win, Ddata_win, M, tBreaks, par_obj); %simode(theta, Idata_win, Rdata_win, Ddata_win, M, beta0, gamma, tBreaks);
out = [I; R; D]./[Idata_win; Rdata_win; Ddata_win];
end