-
Notifications
You must be signed in to change notification settings - Fork 13
/
calibrate_growth.m
75 lines (50 loc) · 1.92 KB
/
calibrate_growth.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
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
function zzz = calibrate_growth(xxx, params, moments, flag)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This organizes the paramter values based on what is passed into the
% function
if length(xxx) == 7 % this is the main calibration
params.d = xxx(1);
params.theta =xxx(2);
params.kappa = xxx(3);
params.chi = 1/xxx(4);
params.mu = xxx(5);
params.upsilon = xxx(6);
params.sigma = xxx(7);
elseif length(xxx) == 4 % This is the Sampson calibration
params.d = xxx(1);
params.theta =xxx(2);
params.kappa = xxx(3);
params.chi = 1/xxx(4);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This computes eq and generates all teh relavent moments
Theta_hat = compute_growth_fun_cal(params);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if length(xxx) == 7
moments.quantile_moments = moments.quantile_moments';
moments.quantile_moments = moments.quantile_moments(:);
Theta = [moments.other_moments'; moments.quantile_moments];
omega = eye(length(Theta));
for xxx = 1:length(moments.other_moments)
omega(xxx,xxx) = 100;
end
if flag ~= 0
zzz = (1/length(Theta)).*(log(Theta)-log(Theta_hat))'*omega*(log(Theta)-log(Theta_hat));
else
zzz = [Theta,Theta_hat];
end
elseif length(xxx) == 4 % for sampson
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Theta = [moments.other_moments'];
Theta_hat = Theta_hat(1:4);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
omega = eye(length(Theta));
for xxx = 1:length(moments.other_moments)
omega(xxx,xxx) = 100;
end
if flag ~= 0
zzz = (1/length(Theta)).*(log(Theta)-log(Theta_hat))'*omega*(log(Theta)-log(Theta_hat));
else
zzz = [Theta,Theta_hat];
end
end