| 1 |
// --+ options: stochastic +-- |
| 2 |
|
| 3 |
/* © 2022 Dynare Team |
| 4 |
* |
| 5 |
* This file is free software: you can redistribute it and/or modify |
| 6 |
* it under the terms of the GNU General Public License as published by |
| 7 |
* the Free Software Foundation, either version 3 of the License, or |
| 8 |
* (at your option) any later version. |
| 9 |
* |
| 10 |
* It is distributed in the hope that it will be useful, but |
| 11 |
* WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
* GNU General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU General Public License |
| 16 |
* along with the file. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
*/ |
| 18 |
|
| 19 |
var Efficiency // $A$ |
| 20 |
EfficiencyGrowth // $X$ |
| 21 |
Population // $L$ |
| 22 |
PopulationGrowth // $N$ |
| 23 |
Output // $Y$ |
| 24 |
PhysicalCapitalStock ; // $K$ |
| 25 |
|
| 26 |
varexo e_x // $\varepsilon_x$ |
| 27 |
e_n ; // $\varepsilon_n$ |
| 28 |
|
| 29 |
parameters alpha // $\alpha$ |
| 30 |
epsilon // $\varepsilon$ |
| 31 |
delta // $\delta$ |
| 32 |
s // $s$ |
| 33 |
rho_x // $\rho_x$ |
| 34 |
rho_n // $\rho_n$ |
| 35 |
EfficiencyGrowth_ss // $X^{\star}$ |
| 36 |
PopulationGrowth_ss ; // $N^{\star}$ |
| 37 |
|
| 38 |
alpha = .33; |
| 39 |
epsilon = .70; |
| 40 |
delta = .02; |
| 41 |
s = .20; |
| 42 |
rho_x = .90; |
| 43 |
rho_n = .95; |
| 44 |
EfficiencyGrowth_ss = 1.02; |
| 45 |
PopulationGrowth_ss = 1.02; |
| 46 |
|
| 47 |
if s>delta*alpha^(-epsilon/(epsilon-1)) |
| 48 |
disp('The model admits a unique positive steady state.') |
| 49 |
end |
| 50 |
|
| 51 |
|
| 52 |
model; |
| 53 |
Efficiency = EfficiencyGrowth*Efficiency(-1); |
| 54 |
EfficiencyGrowth/EfficiencyGrowth_ss = (EfficiencyGrowth(-1)/EfficiencyGrowth_ss)^(rho_x)*exp(e_x); |
| 55 |
Population = PopulationGrowth*Population(-1); |
| 56 |
PopulationGrowth/PopulationGrowth_ss = (PopulationGrowth(-1)/PopulationGrowth_ss)^(rho_n)*exp(e_n); |
| 57 |
Output = (alpha*PhysicalCapitalStock(-1)^((epsilon-1)/epsilon)+(1-alpha)*(Efficiency*Population)^((epsilon-1)/epsilon))^(epsilon/(epsilon-1)); |
| 58 |
PhysicalCapitalStock = (1-delta)*PhysicalCapitalStock(-1) + s*Output; |
| 59 |
end; |
| 60 |
|
| 61 |
histval; |
| 62 |
Efficiency(0) = 1; |
| 63 |
EfficiencyGrowth(0) = 1.02; |
| 64 |
Population(0) = 1; |
| 65 |
PopulationGrowth(0) = 1.02; |
| 66 |
PhysicalCapitalStock(0) = 1; |
| 67 |
end; |
| 68 |
|
| 69 |
shocks; |
| 70 |
var e_x = 0.005; |
| 71 |
var e_n = 0.001; |
| 72 |
end; |
| 73 |
|
| 74 |
TrueData = simul_backward_nonlinear_model([], 100, options_, M_, oo_); |
| 75 |
|
| 76 |
// Set the periods where some of the endogenous variables will be constrained. |
| 77 |
subsample = 2Y:100Y; |
| 78 |
|
| 79 |
// Copy the generated data |
| 80 |
SimulatedData = copy(TrueData); |
| 81 |
|
| 82 |
// Set the constrained paths for the endogenous variables (Output and PhysicalCapitalStock). |
| 83 |
constrainedpaths = SimulatedData{'Output','PhysicalCapitalStock'}(subsample); |
| 84 |
|
| 85 |
// Set the instruments (innovations used to control the paths for the endogenous variables). |
| 86 |
exogenousvariables = dseries(NaN(100, 2), 1Y, {'e_x';'e_n'}); |
| 87 |
|
| 88 |
// Invert the model by calling the model_inversion routine. |
| 89 |
[endogenousvariables, exogenousvariables] = model_inversion(constrainedpaths, exogenousvariables, SimulatedData, M_, options_, oo_); |
| 90 |
|
| 91 |
// Check that all the constraints are satisfied. |
| 92 |
if max(abs(constrainedpaths.Output(subsample).data-endogenousvariables.Output(subsample).data))>1e-12 |
| 93 |
error('Constraint on Output path is not satisfied!') |
| 94 |
end |
| 95 |
|
| 96 |
if max(abs(constrainedpaths.PhysicalCapitalStock(subsample).data-endogenousvariables.PhysicalCapitalStock(subsample).data))>1e-12 |
| 97 |
error('Constraint on PhysicalCapitalStock path is not satisfied!') |
| 98 |
end |
| 99 |
|
| 100 |
// Check the consistency of the deduced innovations with the true innovations. |
| 101 |
|
| 102 |
/* REMARK |
| 103 |
** |
| 104 |
** In this model the two innovatons, on population growth and efficiency growth, cannot be identified simulatneously because |
| 105 |
** what matters for the dynamic of the physical capital stock and the output is the same non linear function of the two innovations. |
| 106 |
** This explains why we only check that the product of Efficiency and Population are the same in the simulated (true) data and in the |
| 107 |
** data returned by the inversion routine. |
| 108 |
*/ |
| 109 |
|
| 110 |
TrueEfficiency = TrueData.Efficiency; |
| 111 |
TruePopulation = TrueData.Population; |
| 112 |
|
| 113 |
TrueEfficiencyTimesPopulation = TrueEfficiency*TruePopulation; |
| 114 |
EfficiencyTimesPopulation = endogenousvariables.Efficiency*endogenousvariables.Population; |
| 115 |
|
| 116 |
if isoctave |
| 117 |
tolerance=2e-5; |
| 118 |
else |
| 119 |
tolerance=1e-5; |
| 120 |
end |
| 121 |
|
| 122 |
if max(abs(TrueEfficiencyTimesPopulation(2Y:100Y).data-EfficiencyTimesPopulation(2Y:100Y).data))>tolerance |
| 123 |
error('Model inversion is not consistent with true innovations.') |
| 124 |
end |