diff --git a/matlab/set_observed_exogenous_variables.m b/matlab/set_observed_exogenous_variables.m new file mode 100644 index 000000000..c9e350f78 --- /dev/null +++ b/matlab/set_observed_exogenous_variables.m @@ -0,0 +1,35 @@ +function DynareModel = set_observed_exogenous_variables(DynareModel) + +% Appends the list of observed exogenous variables in Dynare's model structure (if any). +% +% INPUTS +% - DynareModel [struct] Dynare's model global structure, M_. +% +% OUTPUTS +% - DynareModel [struct] Dynare's model global structure, M_. +% +% SPECIAL REQUIREMENTS +% none + +% Copyright (C) 2019 Dynare Team +% +% This file is part of Dynare. +% +% Dynare is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% (at your option) any later version. +% +% Dynare is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with Dynare. If not, see . + +if isfield(DynareModel, 'exo_partitions') + if isfield(DynareModel.exo_partitions, 'status') + DynareModel.observed_exo_names = DynareModel.exo_names(strcmpi('observed', DynareModel.exo_partitions.status)); + end +end \ No newline at end of file diff --git a/preprocessor b/preprocessor index 9b1b4113d..556789abc 160000 --- a/preprocessor +++ b/preprocessor @@ -1 +1 @@ -Subproject commit 9b1b4113d9954c35f1c839f3657ff0b42f8fd6a9 +Subproject commit 556789abce78c36d79b4ce6f0781f96ce111c43b diff --git a/tests/Makefile.am b/tests/Makefile.am index 4bdb53050..be1f1b7ea 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -432,6 +432,7 @@ MODFILES = \ pac/trend-component-22/example.mod \ pac/trend-component-23/example.mod \ pac/trend-component-24/example.mod \ + write/example1.mod \ ecb/backward-models/irf/solow_1.mod \ ecb/backward-models/irf/solow_2.mod \ dynare-command-options/ramst.mod diff --git a/tests/write/example1.mod b/tests/write/example1.mod new file mode 100644 index 000000000..8ba9f85a3 --- /dev/null +++ b/tests/write/example1.mod @@ -0,0 +1,89 @@ +// --+ options: json=compute, stochastic +-- + +var x1 x2 x1bar x2bar z y x; + +varexo ex1 + ex2 + ex1bar + ex2bar + ez + ey (status='observed') // This shock is observed... + ex (status='observed') // ... this one also. Other shocks will be considered as non observed. +; + +parameters + rho_1 rho_2 rho_3 rho_4 + a_x1_0 a_x1_1 a_x1_2 a_x1_x2_1 a_x1_x2_2 + a_x2_0 a_x2_1 a_x2_2 a_x2_x1_1 a_x2_x1_2 + e_c_m c_z_1 c_z_2 beta + lambda; + +rho_1 = .9; +rho_2 = -.2; +rho_3 = .4; +rho_4 = -.3; + + +a_x1_0 = -.9; +a_x1_1 = .4; +a_x1_2 = .3; +a_x1_x2_1 = .1; +a_x1_x2_2 = .2; + +a_x2_0 = -.9; +a_x2_1 = .2; +a_x2_2 = -.1; +a_x2_x1_1 = -.1; +a_x2_x1_2 = .2; + +beta = .2; +e_c_m = .5; +c_z_1 = .2; +c_z_2 = -.1; + +lambda = 0.5; // Share of optimizing agents. + +trend_component_model(model_name=toto, eqtags=['eq:x1', 'eq:x2', 'eq:x1bar', 'eq:x2bar'], targets=['eq:x1bar', 'eq:x2bar']); + +pac_model(auxiliary_model_name=toto, discount=beta, model_name=pacman); + +model; + +[name='eq:y'] +y = rho_1*y(-1) + rho_2*y(-2) + ey; + +[name='eq:x'] +x = rho_3*x(-1) + rho_4*x(-2) + ex; + +[name='eq:x1'] +diff(x1) = a_x1_0*(x1(-1)-x1bar(-1)) + a_x1_1*diff(x1(-1)) + a_x1_2*diff(x1(-2)) + a_x1_x2_1*diff(x2(-1)) + a_x1_x2_2*diff(x2(-2)) + ex1; + +[name='eq:x2'] +diff(x2) = a_x2_0*(x2(-1)-x2bar(-1)) + a_x2_1*diff(x1(-1)) + a_x2_2*diff(x1(-2)) + a_x2_x1_1*diff(x2(-1)) + a_x2_x1_2*diff(x2(-2)) + ex2; + +[name='eq:x1bar'] +x1bar = x1bar(-1) + ex1bar; + +[name='eq:x2bar'] +x2bar = x2bar(-1) + ex2bar; + +[name='zpac'] +diff(z) = lambda*(e_c_m*(x1(-1)-z(-1)) + c_z_1*diff(z(-1)) + c_z_2*diff(z(-2)) + pac_expectation(pacman)) + (1-lambda)*( y + x) + ez; + +end; + +shocks; + var ex1 = 1.0; + var ex2 = 1.0; + var ex1bar = 1.0; + var ex2bar = 1.0; + var ez = 1.0; + var ey = 0.1; + var ex = 0.1; +end; + +verbatim; + if ~isequal(M_.observed_exo_names, {'ey'; 'ex'}) + error() + end +end;