-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample_Parameter_Estimation.m
More file actions
77 lines (67 loc) · 2.84 KB
/
Example_Parameter_Estimation.m
File metadata and controls
77 lines (67 loc) · 2.84 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
% SCRIPT: EXAMPLE_PARAMETER_ESTIMATION
% % Author: Fabian Santiago
% % E-mail: FabianSantiago707@gmail.com
%
% DESCRIPTION
% % This script shows how the functions are used to perform parameter
% % estimation using the simulated data and secondly using the
% % experimental data.
%
% Add adaptive metropolis code to path
addpath('./code/');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%% Parameter Estimation: Simulated Data %%%%%%%%%%
% Load dataset: Weak
load('simulated_data/simdata_mu10p0sig1p0lambda0p70rho0p30smph32p0.mat',...
'propagon_data','sampling_times')
% Setup initial parameter values to begin parameter estimation.
Prms0 = [0.1,0.5]; % Initial parameter estimates [lambda, rho]
Cn = sqrt([0.1406,0;0,0.0156]); % Initial covariance matrix
num_itrs = 6*10^3;
% Perform parameter estimation using Adaptive Metropolis Algorithm
[PRMS,~] = am_alg(propagon_data,sampling_times,Prms0,Cn,num_itrs);
% Plot adaptive Metropolis chains
figure
T = tiledlayout(2,1);
nexttile
plot(PRMS(:,1),'LineWidth',2,'Color',[0,0,.75])
grid on
legend(['$\bar\lambda$ = ',num2str(round(mean(PRMS(:,1)),2))],'Interpreter','latex')
ylabel('Replication Rate, $\lambda$','Interpreter','latex')
xlabel('Number of Iterations','Interpreter','latex')
nexttile
plot(PRMS(:,2),'LineWidth',2,'Color',[.75,0,0])
grid on
legend(['$\bar\rho$ = ',num2str(round(mean(PRMS(:,2)),2))],'Interpreter','latex')
ylabel('Transmission Bias, $\rho$','Interpreter','latex')
xlabel('Number of Iterations','Interpreter','latex')
T.Title.String = 'Simulated Data';
shg
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%% Parameter Estimation: Experimental Data %%%%%%%%%%
% Load dataset: Weak
load('propagon_data_raw/Weak.mat','propagon_data','sampling_times')
% Setup initial parameter values to begin parameter estimation.
Prms0 = [0.1,0.5]; % Initial parameter estimates [lambda, rho]
Cn = sqrt([0.1406,0;0,0.0156]); % Initial covariance matrix
num_itrs = 6*10^3;
% Perform parameter estimation using Adaptive Metropolis Algorithm
[PRMS,~] = am_alg(propagon_data,sampling_times,Prms0,Cn,num_itrs);
% Plot adaptive Metropolis chains
figure
L = tiledlayout(2,1);
nexttile
plot(PRMS(:,1),'LineWidth',2,'Color',[0,0,.75])
grid on
legend(['$\bar\lambda$ = ',num2str(round(mean(PRMS(:,1)),2))],'Interpreter','latex')
ylabel('Replication Rate, $\lambda$','Interpreter','latex')
xlabel('Number of Iterations','Interpreter','latex')
nexttile
plot(PRMS(:,2),'LineWidth',2,'Color',[.75,0,0])
grid on
legend(['$\bar\rho$ = ',num2str(round(mean(PRMS(:,2)),2))],'Interpreter','latex')
ylabel('Transmission Bias, $\rho$','Interpreter','latex')
xlabel('Number of Iterations','Interpreter','latex')
L.Title.String = 'Experimental Data';
set(gca,'TickLabelInterpreter','latex','FontSize',16)
shg