| 1 |
close all |
| 2 |
|
| 3 |
var Efficiency $A$ |
| 4 |
EfficiencyGrowth $X$ |
| 5 |
Population $L$ |
| 6 |
PopulationGrowth $N$ |
| 7 |
Output $Y$ |
| 8 |
PhysicalCapitalStock $K$ ; |
| 9 |
|
| 10 |
varexo e_x $\varepsilon_x$ |
| 11 |
e_n $\varepsilon_n$; |
| 12 |
|
| 13 |
parameters alpha $\alpha$ |
| 14 |
delta $\delta$ |
| 15 |
s $s$ |
| 16 |
rho_x $\rho_x$ |
| 17 |
rho_n $\rho_n$ |
| 18 |
EfficiencyGrowth_ss $X^{\star}$ |
| 19 |
PopulationGrowth_ss $N^{\star}$ ; |
| 20 |
|
| 21 |
alpha = .33; |
| 22 |
delta = .02; |
| 23 |
s = .20; |
| 24 |
rho_x = .90; |
| 25 |
rho_n = .95; |
| 26 |
EfficiencyGrowth_ss = 1.0; |
| 27 |
PopulationGrowth_ss = 1.0; |
| 28 |
|
| 29 |
model; |
| 30 |
Efficiency = EfficiencyGrowth*Efficiency(-1); |
| 31 |
EfficiencyGrowth/EfficiencyGrowth_ss = (EfficiencyGrowth(-1)/EfficiencyGrowth_ss)^(rho_x)*exp(e_x); |
| 32 |
Population = PopulationGrowth*Population(-1); |
| 33 |
PopulationGrowth/PopulationGrowth_ss = (PopulationGrowth(-1)/PopulationGrowth_ss)^(rho_n)*exp(e_n); |
| 34 |
Output = PhysicalCapitalStock(-1)^alpha*(Efficiency*Population)^(1-alpha); |
| 35 |
PhysicalCapitalStock = (1-delta)*PhysicalCapitalStock(-1) + s*Output; |
| 36 |
end; |
| 37 |
|
| 38 |
|
| 39 |
shocks; |
| 40 |
var e_x = 0.005; |
| 41 |
var e_n = 0.001; |
| 42 |
end; |
| 43 |
|
| 44 |
/* |
| 45 |
** FIRST APPROACH (PASS A DSERIES OBJECT FOR THE INITIAL CONDITION) |
| 46 |
*/ |
| 47 |
|
| 48 |
// Define a dseries object. |
| 49 |
ds = dseries(repmat([1, .5, 1, .5, 0, 1], 10, 1), 1990Q1, M_.endo_names, M_.endo_names_tex); |
| 50 |
|
| 51 |
// Alternatively we could build this object with a stochastic simulation of the model. |
| 52 |
/* |
| 53 |
ds = simul_backward_model(dseries([1, .5, 1, .5, 0, 1], 1990Q1, cellstr(M_.endo_names)), 10); |
| 54 |
names=regexp(ds.name, 'e_\w*'); |
| 55 |
idxs = []; |
| 56 |
for j=1:length(names) |
| 57 |
if isempty(names{j}) |
| 58 |
idxs = [idxs j]; |
| 59 |
end |
| 60 |
end |
| 61 |
ds = ds{idxs}; |
| 62 |
*/ |
| 63 |
|
| 64 |
// Set the initial condition for the IRFs using observation 1991Q1 in ds. |
| 65 |
set_historical_values ds 1991Q1; |
| 66 |
|
| 67 |
// Define the shocks for which we want to compute the IRFs |
| 68 |
listofshocks = {'e_x', 'e_n'}; |
| 69 |
|
| 70 |
// Define the variables for which we want to compute the IRFs |
| 71 |
listofvariables = {'Efficiency', 'Population', 'Output'}; |
| 72 |
|
| 73 |
// Compute the IRFs |
| 74 |
irfs = backward_model_irf(ds, dseries(), listofshocks, listofvariables, 50); // 10 is the number of periods (default value is 40). |
| 75 |
|
| 76 |
// Plot an IRF (shock on technology) |
| 77 |
figure(1) |
| 78 |
plot(irfs.e_x.Output) |
| 79 |
legend('Output') |
| 80 |
title('IRF (shock on the growth rate of efficiency)') |
| 81 |
|
| 82 |
/* |
| 83 |
** SECOND APPROACH (USE THE HISTVAL BLOCK FOR SETTING THE INITIAL CONDITION) |
| 84 |
** |
| 85 |
** In this case the first argument of the backward_model_irf routine is a date object (for specifying |
| 86 |
** the period of the initial condition). |
| 87 |
*/ |
| 88 |
|
| 89 |
/* |
| 90 |
histval; |
| 91 |
Efficiency(0) = 1; |
| 92 |
EfficiencyGrowth(0) = .5; |
| 93 |
Population(0) = 1; |
| 94 |
PopulationGrowth(0) = .5; |
| 95 |
PhysicalCapitalStock(0) = 1; |
| 96 |
end; |
| 97 |
*/ |
| 98 |
// Define the shocks for which we want to compute the IRFs |
| 99 |
listofshocks = {'e_x', 'e_n'}; |
| 100 |
|
| 101 |
// Define the variables for which we want to compute the IRFs |
| 102 |
listofvariables = {'Efficiency', 'Population', 'Output'}; |
| 103 |
|
| 104 |
// Compute the IRFs |
| 105 |
irfs = backward_model_irf([], dseries(), listofshocks, listofvariables, 50); // 10 is the number of periods (default value is 40). |
| 106 |
|
| 107 |
// Plot an IRF (shock on technology) |
| 108 |
figure(2) |
| 109 |
plot(irfs.e_x.Output) |
| 110 |
legend('Output') |
| 111 |
title('IRF (shock on the growth rate of efficiency)') |