Cosmetic change.
parent
8f3e56b85b
commit
2c5b58e8ef
|
@ -27,7 +27,7 @@ rho_n = .95;
|
|||
EfficiencyGrowth_ss = 1.01;
|
||||
PopulationGrowth_ss = 1.01;
|
||||
|
||||
model;
|
||||
model(use_dll);
|
||||
Efficiency = EfficiencyGrowth*Efficiency(-1);
|
||||
EfficiencyGrowth/EfficiencyGrowth_ss = (EfficiencyGrowth(-1)/EfficiencyGrowth_ss)^(rho_x)*exp(e_x);
|
||||
Population = PopulationGrowth*Population(-1);
|
||||
|
@ -43,34 +43,43 @@ verbatim;
|
|||
% implementation of fsolve, so we skip this check for Octave
|
||||
|
||||
bgp.write(M_);
|
||||
|
||||
MC = 100;
|
||||
KY = NaN(MC,1);
|
||||
GY = NaN(MC,1);
|
||||
GK = NaN(MC,1);
|
||||
EG = NaN(MC,1);
|
||||
EF = NaN(MC,1);
|
||||
|
||||
if matlab_ver_less_than('9.0')
|
||||
% See https://fr.mathworks.com/help/optim/ug/current-and-legacy-option-name-tables.html
|
||||
options = optimoptions('fsolve','Display','off','Algorithm','levenberg-marquardt','MaxFunEvals',1000000,'MaxIter',100000,'Jacobian','on','TolFun',1e-8,'TolX',1e-8);
|
||||
else
|
||||
options = optimoptions('fsolve','Display','off','Algorithm','levenberg-marquardt','MaxFunctionEvaluations',1000000,'MaxIterations',100000,'SpecifyObjectiveGradient',true,'FunctionTolerance',1e-8,'StepTolerance',1e-8);
|
||||
options = optimoptions('fsolve','Display','off','Algorithm','levenberg-marquardt','MaxFunctionEvaluations',1000000,'MaxIterations',100000,'SpecifyObjectiveGradient',true,'FunctionTolerance',1e-12,'StepTolerance',1e-12);
|
||||
end
|
||||
|
||||
reverseStr = '';
|
||||
|
||||
for i=1:MC
|
||||
y = 1+(rand(6,1)-.5)*.2;
|
||||
g = ones(6,1)+.05*randn(6,1);
|
||||
[y, fval, exitflag] = fsolve(@solow.bgpfun, [y;g], options);
|
||||
if exitflag>0
|
||||
KY(i) = y(6)/y(5);
|
||||
GY(i) = y(11);
|
||||
GK(i) = y(12);
|
||||
EG(i) = y(2);
|
||||
end
|
||||
% Display the progress
|
||||
percentDone = 100 * i / MC;
|
||||
msg = sprintf('Percent done: %3.1f', percentDone);
|
||||
fprintf([reverseStr, msg]);
|
||||
reverseStr = repmat(sprintf('\b'), 1, length(msg));
|
||||
y = 100+(rand(6,1)-.5)*.2;
|
||||
y(2) = 1+.02*rand;
|
||||
y(4) = 1+.02*rand;
|
||||
G = ones(6,1)+.05*randn(6,1);
|
||||
[y, fval, exitflag] = fsolve(@solow.bgpfun, [y;G], options);
|
||||
if exitflag>0
|
||||
KY(i) = y(6)/y(5);
|
||||
GY(i) = y(11);
|
||||
GK(i) = y(12);
|
||||
EG(i) = y(2);
|
||||
EF(i) = y(4);
|
||||
end
|
||||
% Display the progress
|
||||
percentDone = 100 * i / MC;
|
||||
msg = sprintf('Percent done: %3.1f', percentDone);
|
||||
fprintf([reverseStr, msg]);
|
||||
reverseStr = repmat(sprintf('\b'), 1, length(msg));
|
||||
end
|
||||
|
||||
fprintf('\n');
|
||||
% Compute the physical capital stock over output ratio along the BGP as
|
||||
% a function of the deep parameters...
|
||||
|
@ -83,15 +92,12 @@ verbatim;
|
|||
disp(sprintf('mean(K/Y) = %s.', num2str(mu)));
|
||||
disp(sprintf('var(K/Y) = %s.', num2str(s2)));
|
||||
disp(sprintf('Number of failures: %u (over %u problems).', sum(isnan(KY)), MC));
|
||||
assert(abs(mu-theoretical_long_run_ratio)<1e-8);
|
||||
assert(s2<1e-16);
|
||||
assert(abs(mean(GY(~isnan(GY)))-EfficiencyGrowth_ss*PopulationGrowth_ss)<1e-8)
|
||||
assert(var(GY(~isnan(GY)))<1e-16);
|
||||
assert(abs(mean(GK(~isnan(GK)))-EfficiencyGrowth_ss*PopulationGrowth_ss)<1e-8)
|
||||
assert(var(GK(~isnan(GK)))<1e-16);
|
||||
assert(abs(mean(EG(~isnan(EG)))-EfficiencyGrowth_ss)<1e-8)
|
||||
assert(var(EG(~isnan(EG)))<1e-16);
|
||||
|
||||
if (abs(mu-theoretical_long_run_ratio)>1e-8), error('Average long run K/Y ratio is wrong.'), end
|
||||
if (s2>1e-12), warning('Average long run K/Y ratio is wrong.'), end
|
||||
dprintf('Proportion of wrong values for GY is %s.', num2str(sum(abs(GY(~isnan(GY))-EfficiencyGrowth_ss*PopulationGrowth_ss)>1e-6)/sum(~isnan(GY))))
|
||||
dprintf('Proportion of wrong values for GK is %s.', num2str(sum(abs(GK(~isnan(GK))-EfficiencyGrowth_ss*PopulationGrowth_ss)>1e-6)/sum(~isnan(GK))))
|
||||
dprintf('Proportion of wrong values for EG is %s.', num2str(sum(abs(EG(~isnan(EG))-EfficiencyGrowth_ss)>1e-6)/sum(~isnan(EG))))
|
||||
dprintf('Proportion of wrong values for EF is %s.', num2str(sum(abs(EF(~isnan(EF))-PopulationGrowth_ss)>1e-6)/sum(~isnan(EF))))
|
||||
end
|
||||
|
||||
end;
|
||||
|
|
Loading…
Reference in New Issue